xed-panel: Clean up the layout of the panels
Make sure the bottom panel lays out properly when we actually have a plugin that lives there
This commit is contained in:
parent
f9a658f823
commit
26f8139317
105
xed/xed-panel.c
105
xed/xed-panel.c
|
@ -47,6 +47,8 @@ struct _XedPanelPrivate
|
||||||
{
|
{
|
||||||
GtkOrientation orientation;
|
GtkOrientation orientation;
|
||||||
|
|
||||||
|
GtkWidget *main_box;
|
||||||
|
|
||||||
/* Title bar (vertical panel only) */
|
/* Title bar (vertical panel only) */
|
||||||
GtkWidget *title_image;
|
GtkWidget *title_image;
|
||||||
GtkWidget *title_label;
|
GtkWidget *title_label;
|
||||||
|
@ -87,7 +89,7 @@ static GObject *xed_panel_constructor (GType type,
|
||||||
GObjectConstructParam *construct_properties);
|
GObjectConstructParam *construct_properties);
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (XedPanel, xed_panel, GTK_TYPE_BOX)
|
G_DEFINE_TYPE (XedPanel, xed_panel, GTK_TYPE_BIN)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_panel_finalize (GObject *obj)
|
xed_panel_finalize (GObject *obj)
|
||||||
|
@ -158,6 +160,71 @@ xed_panel_focus_document (XedPanel *panel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_panel_get_size (GtkWidget *widget,
|
||||||
|
GtkOrientation orientation,
|
||||||
|
gint *minimum,
|
||||||
|
gint *natural)
|
||||||
|
{
|
||||||
|
GtkBin *bin = GTK_BIN (widget);
|
||||||
|
GtkWidget *child;
|
||||||
|
|
||||||
|
if (minimum)
|
||||||
|
{
|
||||||
|
*minimum = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (natural)
|
||||||
|
{
|
||||||
|
*natural = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
child = gtk_bin_get_child (bin);
|
||||||
|
if (child && gtk_widget_get_visible (child))
|
||||||
|
{
|
||||||
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
|
{
|
||||||
|
gtk_widget_get_preferred_width (child, minimum, natural);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_widget_get_preferred_height (child, minimum, natural);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_panel_get_preferred_width (GtkWidget *widget,
|
||||||
|
gint *minimum,
|
||||||
|
gint *natural)
|
||||||
|
{
|
||||||
|
xed_panel_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum, natural);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_panel_get_preferred_height (GtkWidget *widget,
|
||||||
|
gint *minimum,
|
||||||
|
gint *natural)
|
||||||
|
{
|
||||||
|
xed_panel_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum, natural);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_panel_size_allocate (GtkWidget *widget,
|
||||||
|
GtkAllocation *allocation)
|
||||||
|
{
|
||||||
|
GtkBin *bin = GTK_BIN (widget);
|
||||||
|
GtkWidget *child;
|
||||||
|
|
||||||
|
GTK_WIDGET_CLASS (xed_panel_parent_class)->size_allocate (widget, allocation);
|
||||||
|
|
||||||
|
child = gtk_bin_get_child (bin);
|
||||||
|
if (child && gtk_widget_get_visible (child))
|
||||||
|
{
|
||||||
|
gtk_widget_size_allocate (child, allocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_panel_grab_focus (GtkWidget *w)
|
xed_panel_grab_focus (GtkWidget *w)
|
||||||
{
|
{
|
||||||
|
@ -191,23 +258,25 @@ xed_panel_class_init (XedPanelClass *klass)
|
||||||
object_class->get_property = xed_panel_get_property;
|
object_class->get_property = xed_panel_get_property;
|
||||||
object_class->set_property = xed_panel_set_property;
|
object_class->set_property = xed_panel_set_property;
|
||||||
|
|
||||||
g_object_class_install_property (object_class,
|
widget_class->get_preferred_width = xed_panel_get_preferred_width;
|
||||||
PROP_ORIENTATION,
|
widget_class->get_preferred_height = xed_panel_get_preferred_height;
|
||||||
g_param_spec_enum ("panel-orientation",
|
widget_class->size_allocate = xed_panel_size_allocate;
|
||||||
"Panel Orientation",
|
|
||||||
"The panel's orientation",
|
|
||||||
GTK_TYPE_ORIENTATION,
|
|
||||||
GTK_ORIENTATION_VERTICAL,
|
|
||||||
G_PARAM_WRITABLE |
|
|
||||||
G_PARAM_READABLE |
|
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
|
||||||
G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
widget_class->grab_focus = xed_panel_grab_focus;
|
widget_class->grab_focus = xed_panel_grab_focus;
|
||||||
|
|
||||||
klass->close = xed_panel_close;
|
klass->close = xed_panel_close;
|
||||||
klass->focus_document = xed_panel_focus_document;
|
klass->focus_document = xed_panel_focus_document;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_ORIENTATION,
|
||||||
|
g_param_spec_enum ("orientation",
|
||||||
|
"Panel Orientation",
|
||||||
|
"The panel's orientation",
|
||||||
|
GTK_TYPE_ORIENTATION,
|
||||||
|
GTK_ORIENTATION_VERTICAL,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
signals[ITEM_ADDED] =
|
signals[ITEM_ADDED] =
|
||||||
g_signal_new ("item_added",
|
g_signal_new ("item_added",
|
||||||
G_OBJECT_CLASS_TYPE (klass),
|
G_OBJECT_CLASS_TYPE (klass),
|
||||||
|
@ -384,7 +453,9 @@ xed_panel_init (XedPanel *panel)
|
||||||
{
|
{
|
||||||
panel->priv = XED_PANEL_GET_PRIVATE (panel);
|
panel->priv = XED_PANEL_GET_PRIVATE (panel);
|
||||||
|
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (panel), GTK_ORIENTATION_VERTICAL);
|
panel->priv->main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||||
|
gtk_widget_show (panel->priv->main_box);
|
||||||
|
gtk_container_add (GTK_CONTAINER (panel), panel->priv->main_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -441,7 +512,7 @@ build_horizontal_panel (XedPanel *panel)
|
||||||
|
|
||||||
gtk_widget_show_all (box);
|
gtk_widget_show_all (box);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (panel), box, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (panel->priv->main_box), box, TRUE, TRUE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -456,7 +527,7 @@ build_vertical_panel (XedPanel *panel)
|
||||||
title_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
title_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (title_hbox), 5);
|
gtk_container_set_border_width (GTK_CONTAINER (title_hbox), 5);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (panel), title_hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (panel->priv->main_box), title_hbox, FALSE, FALSE, 0);
|
||||||
|
|
||||||
icon_name_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
icon_name_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (title_hbox), icon_name_hbox, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (title_hbox), icon_name_hbox, TRUE, TRUE, 0);
|
||||||
|
@ -477,7 +548,7 @@ build_vertical_panel (XedPanel *panel)
|
||||||
|
|
||||||
gtk_widget_show_all (title_hbox);
|
gtk_widget_show_all (title_hbox);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (panel), panel->priv->notebook, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (panel->priv->main_box), panel->priv->notebook, TRUE, TRUE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GObject *
|
static GObject *
|
||||||
|
|
102
xed/xed-panel.h
102
xed/xed-panel.h
|
@ -2,7 +2,7 @@
|
||||||
* xed-panel.h
|
* xed-panel.h
|
||||||
* This file is part of xed
|
* This file is part of xed
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005 - Paolo Maggi
|
* Copyright (C) 2005 - Paolo Maggi
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,14 +16,14 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modified by the xed Team, 2005. See the AUTHORS file for a
|
* Modified by the xed Team, 2005. See the AUTHORS file for a
|
||||||
* list of people on the xed Team.
|
* list of people on the xed Team.
|
||||||
* See the ChangeLog files for a list of changes.
|
* See the ChangeLog files for a list of changes.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
@ -38,12 +38,12 @@ G_BEGIN_DECLS
|
||||||
/*
|
/*
|
||||||
* Type checking and casting macros
|
* Type checking and casting macros
|
||||||
*/
|
*/
|
||||||
#define XED_TYPE_PANEL (xed_panel_get_type())
|
#define XED_TYPE_PANEL (xed_panel_get_type())
|
||||||
#define XED_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_PANEL, XedPanel))
|
#define XED_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_PANEL, XedPanel))
|
||||||
#define XED_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_PANEL, XedPanelClass))
|
#define XED_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_PANEL, XedPanelClass))
|
||||||
#define XED_IS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_PANEL))
|
#define XED_IS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_PANEL))
|
||||||
#define XED_IS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_PANEL))
|
#define XED_IS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_PANEL))
|
||||||
#define XED_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_PANEL, XedPanelClass))
|
#define XED_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_PANEL, XedPanelClass))
|
||||||
|
|
||||||
/* Private structure type */
|
/* Private structure type */
|
||||||
typedef struct _XedPanelPrivate XedPanelPrivate;
|
typedef struct _XedPanelPrivate XedPanelPrivate;
|
||||||
|
@ -53,12 +53,12 @@ typedef struct _XedPanelPrivate XedPanelPrivate;
|
||||||
*/
|
*/
|
||||||
typedef struct _XedPanel XedPanel;
|
typedef struct _XedPanel XedPanel;
|
||||||
|
|
||||||
struct _XedPanel
|
struct _XedPanel
|
||||||
{
|
{
|
||||||
GtkBox vbox;
|
GtkBin parent;
|
||||||
|
|
||||||
/*< private > */
|
/*< private > */
|
||||||
XedPanelPrivate *priv;
|
XedPanelPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -66,64 +66,64 @@ struct _XedPanel
|
||||||
*/
|
*/
|
||||||
typedef struct _XedPanelClass XedPanelClass;
|
typedef struct _XedPanelClass XedPanelClass;
|
||||||
|
|
||||||
struct _XedPanelClass
|
struct _XedPanelClass
|
||||||
{
|
{
|
||||||
GtkBoxClass parent_class;
|
GtkBinClass parent_class;
|
||||||
|
|
||||||
void (* item_added) (XedPanel *panel,
|
void (* item_added) (XedPanel *panel,
|
||||||
GtkWidget *item);
|
GtkWidget *item);
|
||||||
void (* item_removed) (XedPanel *panel,
|
void (* item_removed) (XedPanel *panel,
|
||||||
GtkWidget *item);
|
GtkWidget *item);
|
||||||
|
|
||||||
/* Keybinding signals */
|
/* Keybinding signals */
|
||||||
void (* close) (XedPanel *panel);
|
void (* close) (XedPanel *panel);
|
||||||
void (* focus_document) (XedPanel *panel);
|
void (* focus_document) (XedPanel *panel);
|
||||||
|
|
||||||
/* Padding for future expansion */
|
/* Padding for future expansion */
|
||||||
void (*_xed_reserved1) (void);
|
void (*_xed_reserved1) (void);
|
||||||
void (*_xed_reserved2) (void);
|
void (*_xed_reserved2) (void);
|
||||||
void (*_xed_reserved3) (void);
|
void (*_xed_reserved3) (void);
|
||||||
void (*_xed_reserved4) (void);
|
void (*_xed_reserved4) (void);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public methods
|
* Public methods
|
||||||
*/
|
*/
|
||||||
GType xed_panel_get_type (void) G_GNUC_CONST;
|
GType xed_panel_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget *xed_panel_new (GtkOrientation orientation);
|
GtkWidget *xed_panel_new (GtkOrientation orientation);
|
||||||
|
|
||||||
void xed_panel_add_item (XedPanel *panel,
|
void xed_panel_add_item (XedPanel *panel,
|
||||||
GtkWidget *item,
|
GtkWidget *item,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
GtkWidget *image);
|
GtkWidget *image);
|
||||||
|
|
||||||
void xed_panel_add_item_with_stock_icon (XedPanel *panel,
|
void xed_panel_add_item_with_stock_icon (XedPanel *panel,
|
||||||
GtkWidget *item,
|
GtkWidget *item,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
const gchar *stock_id);
|
const gchar *stock_id);
|
||||||
|
|
||||||
gboolean xed_panel_remove_item (XedPanel *panel,
|
gboolean xed_panel_remove_item (XedPanel *panel,
|
||||||
GtkWidget *item);
|
GtkWidget *item);
|
||||||
|
|
||||||
gboolean xed_panel_activate_item (XedPanel *panel,
|
gboolean xed_panel_activate_item (XedPanel *panel,
|
||||||
GtkWidget *item);
|
GtkWidget *item);
|
||||||
|
|
||||||
gboolean xed_panel_item_is_active (XedPanel *panel,
|
gboolean xed_panel_item_is_active (XedPanel *panel,
|
||||||
GtkWidget *item);
|
GtkWidget *item);
|
||||||
|
|
||||||
GtkOrientation xed_panel_get_orientation (XedPanel *panel);
|
GtkOrientation xed_panel_get_orientation (XedPanel *panel);
|
||||||
|
|
||||||
gint xed_panel_get_n_items (XedPanel *panel);
|
gint xed_panel_get_n_items (XedPanel *panel);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Non exported functions
|
* Non exported functions
|
||||||
*/
|
*/
|
||||||
gint _xed_panel_get_active_item_id (XedPanel *panel);
|
gint _xed_panel_get_active_item_id (XedPanel *panel);
|
||||||
|
|
||||||
void _xed_panel_set_active_item_by_id (XedPanel *panel,
|
void _xed_panel_set_active_item_by_id (XedPanel *panel,
|
||||||
gint id);
|
gint id);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue