xed-panel: Clean up code formatting
This commit is contained in:
parent
d091965175
commit
6893642b16
232
xed/xed-panel.c
232
xed/xed-panel.c
|
@ -64,13 +64,15 @@ struct _XedPanelItem
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Properties */
|
/* Properties */
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_ORIENTATION
|
PROP_ORIENTATION
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
ITEM_ADDED,
|
ITEM_ADDED,
|
||||||
ITEM_REMOVED,
|
ITEM_REMOVED,
|
||||||
CLOSE,
|
CLOSE,
|
||||||
|
@ -85,13 +87,15 @@ 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_BOX)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_panel_finalize (GObject *obj)
|
xed_panel_finalize (GObject *obj)
|
||||||
{
|
{
|
||||||
if (G_OBJECT_CLASS (xed_panel_parent_class)->finalize)
|
if (G_OBJECT_CLASS (xed_panel_parent_class)->finalize)
|
||||||
|
{
|
||||||
(*G_OBJECT_CLASS (xed_panel_parent_class)->finalize) (obj);
|
(*G_OBJECT_CLASS (xed_panel_parent_class)->finalize) (obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -148,8 +152,10 @@ xed_panel_focus_document (XedPanel *panel)
|
||||||
|
|
||||||
view = xed_window_get_active_view (XED_WINDOW (toplevel));
|
view = xed_window_get_active_view (XED_WINDOW (toplevel));
|
||||||
if (view != NULL)
|
if (view != NULL)
|
||||||
|
{
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (view));
|
gtk_widget_grab_focus (GTK_WIDGET (view));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -161,10 +167,11 @@ xed_panel_grab_focus (GtkWidget *w)
|
||||||
|
|
||||||
n = gtk_notebook_get_current_page (GTK_NOTEBOOK (panel->priv->notebook));
|
n = gtk_notebook_get_current_page (GTK_NOTEBOOK (panel->priv->notebook));
|
||||||
if (n == -1)
|
if (n == -1)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (panel->priv->notebook),
|
tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (panel->priv->notebook), n);
|
||||||
n);
|
|
||||||
g_return_if_fail (tab != NULL);
|
g_return_if_fail (tab != NULL);
|
||||||
|
|
||||||
gtk_widget_grab_focus (tab);
|
gtk_widget_grab_focus (tab);
|
||||||
|
@ -311,9 +318,7 @@ set_gtk_image_from_gtk_image (GtkImage *image,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
gtk_image_set_from_stock (image,
|
gtk_image_set_from_stock (image, GTK_STOCK_FILE, GTK_ICON_SIZE_MENU);
|
||||||
GTK_STOCK_FILE,
|
|
||||||
GTK_ICON_SIZE_MENU);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,24 +327,20 @@ sync_title (XedPanel *panel,
|
||||||
XedPanelItem *item)
|
XedPanelItem *item)
|
||||||
{
|
{
|
||||||
if (panel->priv->orientation != GTK_ORIENTATION_VERTICAL)
|
if (panel->priv->orientation != GTK_ORIENTATION_VERTICAL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (item != NULL)
|
if (item != NULL)
|
||||||
{
|
{
|
||||||
gtk_label_set_text (GTK_LABEL (panel->priv->title_label),
|
gtk_label_set_text (GTK_LABEL (panel->priv->title_label), item->name);
|
||||||
item->name);
|
|
||||||
|
|
||||||
set_gtk_image_from_gtk_image (GTK_IMAGE (panel->priv->title_image),
|
set_gtk_image_from_gtk_image (GTK_IMAGE (panel->priv->title_image), GTK_IMAGE (item->icon));
|
||||||
GTK_IMAGE (item->icon));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_label_set_text (GTK_LABEL (panel->priv->title_label),
|
gtk_label_set_text (GTK_LABEL (panel->priv->title_label), _("Empty"));
|
||||||
_("Empty"));
|
gtk_image_set_from_stock (GTK_IMAGE (panel->priv->title_image), GTK_STOCK_FILE, GTK_ICON_SIZE_MENU);
|
||||||
|
|
||||||
gtk_image_set_from_stock (GTK_IMAGE (panel->priv->title_image),
|
|
||||||
GTK_STOCK_FILE,
|
|
||||||
GTK_ICON_SIZE_MENU);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,8 +356,7 @@ notebook_page_changed (GtkNotebook *notebook,
|
||||||
item = gtk_notebook_get_nth_page (notebook, page_num);
|
item = gtk_notebook_get_nth_page (notebook, page_num);
|
||||||
g_return_if_fail (item != NULL);
|
g_return_if_fail (item != NULL);
|
||||||
|
|
||||||
data = (XedPanelItem *)g_object_get_data (G_OBJECT (item),
|
data = (XedPanelItem *)g_object_get_data (G_OBJECT (item), PANEL_ITEM_KEY);
|
||||||
PANEL_ITEM_KEY);
|
|
||||||
g_return_if_fail (data != NULL);
|
g_return_if_fail (data != NULL);
|
||||||
|
|
||||||
sync_title (panel, data);
|
sync_title (panel, data);
|
||||||
|
@ -374,7 +374,9 @@ panel_show (XedPanel *panel,
|
||||||
page = gtk_notebook_get_current_page (nb);
|
page = gtk_notebook_get_current_page (nb);
|
||||||
|
|
||||||
if (page != -1)
|
if (page != -1)
|
||||||
|
{
|
||||||
notebook_page_changed (nb, NULL, page, panel);
|
notebook_page_changed (nb, NULL, page, panel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -382,8 +384,7 @@ 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_orientable_set_orientation (GTK_ORIENTABLE (panel), GTK_ORIENTATION_VERTICAL);
|
||||||
GTK_ORIENTATION_VERTICAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -399,13 +400,8 @@ create_close_button (XedPanel *panel)
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
|
|
||||||
button = xed_close_button_new ();
|
button = xed_close_button_new ();
|
||||||
|
|
||||||
gtk_widget_set_tooltip_text (button, _("Hide panel"));
|
gtk_widget_set_tooltip_text (button, _("Hide panel"));
|
||||||
|
g_signal_connect (button, "clicked", G_CALLBACK (close_button_clicked_cb), panel);
|
||||||
g_signal_connect (button,
|
|
||||||
"clicked",
|
|
||||||
G_CALLBACK (close_button_clicked_cb),
|
|
||||||
panel);
|
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
@ -416,18 +412,13 @@ build_notebook_for_panel (XedPanel *panel)
|
||||||
/* Create the panel notebook */
|
/* Create the panel notebook */
|
||||||
panel->priv->notebook = gtk_notebook_new ();
|
panel->priv->notebook = gtk_notebook_new ();
|
||||||
|
|
||||||
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (panel->priv->notebook),
|
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (panel->priv->notebook), GTK_POS_BOTTOM);
|
||||||
GTK_POS_BOTTOM);
|
gtk_notebook_set_scrollable (GTK_NOTEBOOK (panel->priv->notebook), TRUE);
|
||||||
gtk_notebook_set_scrollable (GTK_NOTEBOOK (panel->priv->notebook),
|
|
||||||
TRUE);
|
|
||||||
gtk_notebook_popup_enable (GTK_NOTEBOOK (panel->priv->notebook));
|
gtk_notebook_popup_enable (GTK_NOTEBOOK (panel->priv->notebook));
|
||||||
|
|
||||||
gtk_widget_show (GTK_WIDGET (panel->priv->notebook));
|
gtk_widget_show (GTK_WIDGET (panel->priv->notebook));
|
||||||
|
|
||||||
g_signal_connect (panel->priv->notebook,
|
g_signal_connect (panel->priv->notebook, "switch-page", G_CALLBACK (notebook_page_changed), panel);
|
||||||
"switch-page",
|
|
||||||
G_CALLBACK (notebook_page_changed),
|
|
||||||
panel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -438,38 +429,19 @@ build_horizontal_panel (XedPanel *panel)
|
||||||
GtkWidget *close_button;
|
GtkWidget *close_button;
|
||||||
|
|
||||||
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
|
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (box), panel->priv->notebook, TRUE, TRUE, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (box),
|
|
||||||
panel->priv->notebook,
|
|
||||||
TRUE,
|
|
||||||
TRUE,
|
|
||||||
0);
|
|
||||||
|
|
||||||
/* Toolbar, close button and first separator */
|
/* Toolbar, close button and first separator */
|
||||||
sidebar = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
|
sidebar = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (sidebar), 4);
|
gtk_container_set_border_width (GTK_CONTAINER (sidebar), 4);
|
||||||
|
gtk_box_pack_start (GTK_BOX (box), sidebar, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (box),
|
|
||||||
sidebar,
|
|
||||||
FALSE,
|
|
||||||
FALSE,
|
|
||||||
0);
|
|
||||||
|
|
||||||
close_button = create_close_button (panel);
|
close_button = create_close_button (panel);
|
||||||
|
gtk_box_pack_start (GTK_BOX (sidebar), close_button, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (sidebar),
|
|
||||||
close_button,
|
|
||||||
FALSE,
|
|
||||||
FALSE,
|
|
||||||
0);
|
|
||||||
|
|
||||||
gtk_widget_show_all (box);
|
gtk_widget_show_all (box);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (panel),
|
gtk_box_pack_start (GTK_BOX (panel), box, TRUE, TRUE, 0);
|
||||||
box,
|
|
||||||
TRUE,
|
|
||||||
TRUE,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -487,55 +459,25 @@ build_vertical_panel (XedPanel *panel)
|
||||||
gtk_box_pack_start (GTK_BOX (panel), title_hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (panel), 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),
|
gtk_box_pack_start (GTK_BOX (title_hbox), icon_name_hbox, TRUE, TRUE, 0);
|
||||||
icon_name_hbox,
|
|
||||||
TRUE,
|
|
||||||
TRUE,
|
|
||||||
0);
|
|
||||||
|
|
||||||
panel->priv->title_image =
|
panel->priv->title_image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU);
|
||||||
gtk_image_new_from_stock (GTK_STOCK_FILE,
|
gtk_box_pack_start (GTK_BOX (icon_name_hbox), panel->priv->title_image, FALSE, TRUE, 0);
|
||||||
GTK_ICON_SIZE_MENU);
|
|
||||||
gtk_box_pack_start (GTK_BOX (icon_name_hbox),
|
|
||||||
panel->priv->title_image,
|
|
||||||
FALSE,
|
|
||||||
TRUE,
|
|
||||||
0);
|
|
||||||
|
|
||||||
dummy_label = gtk_label_new (" ");
|
dummy_label = gtk_label_new (" ");
|
||||||
|
gtk_box_pack_start (GTK_BOX (icon_name_hbox), dummy_label, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (icon_name_hbox),
|
|
||||||
dummy_label,
|
|
||||||
FALSE,
|
|
||||||
FALSE,
|
|
||||||
0);
|
|
||||||
|
|
||||||
panel->priv->title_label = gtk_label_new (_("Empty"));
|
panel->priv->title_label = gtk_label_new (_("Empty"));
|
||||||
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (panel->priv->title_label), 0, 0.5);
|
gtk_misc_set_alignment (GTK_MISC (panel->priv->title_label), 0, 0.5);
|
||||||
gtk_label_set_ellipsize(GTK_LABEL (panel->priv->title_label), PANGO_ELLIPSIZE_END);
|
gtk_label_set_ellipsize(GTK_LABEL (panel->priv->title_label), PANGO_ELLIPSIZE_END);
|
||||||
|
gtk_box_pack_start (GTK_BOX (icon_name_hbox), panel->priv->title_label, TRUE, TRUE, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (icon_name_hbox),
|
|
||||||
panel->priv->title_label,
|
|
||||||
TRUE,
|
|
||||||
TRUE,
|
|
||||||
0);
|
|
||||||
|
|
||||||
close_button = create_close_button (panel);
|
close_button = create_close_button (panel);
|
||||||
|
gtk_box_pack_start (GTK_BOX (title_hbox), close_button, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_start (GTK_BOX (title_hbox),
|
|
||||||
close_button,
|
|
||||||
FALSE,
|
|
||||||
FALSE,
|
|
||||||
0);
|
|
||||||
|
|
||||||
gtk_widget_show_all (title_hbox);
|
gtk_widget_show_all (title_hbox);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (panel),
|
gtk_box_pack_start (GTK_BOX (panel), panel->priv->notebook, TRUE, TRUE, 0);
|
||||||
panel->priv->notebook,
|
|
||||||
TRUE,
|
|
||||||
TRUE,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GObject *
|
static GObject *
|
||||||
|
@ -547,24 +489,22 @@ xed_panel_constructor (GType type,
|
||||||
/* Invoke parent constructor. */
|
/* Invoke parent constructor. */
|
||||||
XedPanelClass *klass = XED_PANEL_CLASS (g_type_class_peek (XED_TYPE_PANEL));
|
XedPanelClass *klass = XED_PANEL_CLASS (g_type_class_peek (XED_TYPE_PANEL));
|
||||||
GObjectClass *parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
|
GObjectClass *parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
|
||||||
GObject *obj = parent_class->constructor (type,
|
GObject *obj = parent_class->constructor (type, n_construct_properties, construct_properties);
|
||||||
n_construct_properties,
|
|
||||||
construct_properties);
|
|
||||||
|
|
||||||
/* Build the panel, now that we know the orientation
|
/* Build the panel, now that we know the orientation (_init has been called previously) */
|
||||||
(_init has been called previously) */
|
|
||||||
XedPanel *panel = XED_PANEL (obj);
|
XedPanel *panel = XED_PANEL (obj);
|
||||||
|
|
||||||
build_notebook_for_panel (panel);
|
build_notebook_for_panel (panel);
|
||||||
if (panel->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
if (panel->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
|
{
|
||||||
build_horizontal_panel (panel);
|
build_horizontal_panel (panel);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
build_vertical_panel (panel);
|
build_vertical_panel (panel);
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect (panel,
|
g_signal_connect (panel, "show", G_CALLBACK (panel_show), NULL);
|
||||||
"show",
|
|
||||||
G_CALLBACK (panel_show),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -591,7 +531,9 @@ build_tab_label (XedPanel *panel,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
GtkWidget *icon)
|
GtkWidget *icon)
|
||||||
{
|
{
|
||||||
GtkWidget *hbox, *label_hbox, *label_ebox;
|
GtkWidget *hbox;
|
||||||
|
GtkWidget *label_hbox;
|
||||||
|
GtkWidget *label_ebox;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
|
|
||||||
/* set hbox spacing and label padding (see below) so that there's an
|
/* set hbox spacing and label padding (see below) so that there's an
|
||||||
|
@ -624,7 +566,9 @@ build_tab_label (XedPanel *panel,
|
||||||
gtk_widget_show_all (hbox);
|
gtk_widget_show_all (hbox);
|
||||||
|
|
||||||
if (panel->priv->orientation == GTK_ORIENTATION_VERTICAL)
|
if (panel->priv->orientation == GTK_ORIENTATION_VERTICAL)
|
||||||
|
{
|
||||||
gtk_widget_hide(label);
|
gtk_widget_hide(label);
|
||||||
|
}
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (item), "label", label);
|
g_object_set_data (G_OBJECT (item), "label", label);
|
||||||
g_object_set_data (G_OBJECT (item), "hbox", hbox);
|
g_object_set_data (G_OBJECT (item), "hbox", hbox);
|
||||||
|
@ -664,8 +608,7 @@ xed_panel_add_item (XedPanel *panel,
|
||||||
if (image == NULL)
|
if (image == NULL)
|
||||||
{
|
{
|
||||||
/* default to empty */
|
/* default to empty */
|
||||||
data->icon = gtk_image_new_from_stock (GTK_STOCK_FILE,
|
data->icon = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU);
|
||||||
GTK_ICON_SIZE_MENU);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -675,9 +618,7 @@ xed_panel_add_item (XedPanel *panel,
|
||||||
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
|
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
|
||||||
gtk_widget_set_size_request (data->icon, w, h);
|
gtk_widget_set_size_request (data->icon, w, h);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (item),
|
g_object_set_data (G_OBJECT (item), PANEL_ITEM_KEY, data);
|
||||||
PANEL_ITEM_KEY,
|
|
||||||
data);
|
|
||||||
|
|
||||||
tab_label = build_tab_label (panel, item, data->name, data->icon);
|
tab_label = build_tab_label (panel, item, data->name, data->icon);
|
||||||
|
|
||||||
|
@ -686,12 +627,11 @@ xed_panel_add_item (XedPanel *panel,
|
||||||
gtk_misc_set_alignment (GTK_MISC (menu_label), 0.0, 0.5);
|
gtk_misc_set_alignment (GTK_MISC (menu_label), 0.0, 0.5);
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (item))
|
if (!gtk_widget_get_visible (item))
|
||||||
|
{
|
||||||
gtk_widget_show (item);
|
gtk_widget_show (item);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_notebook_append_page_menu (GTK_NOTEBOOK (panel->priv->notebook),
|
gtk_notebook_append_page_menu (GTK_NOTEBOOK (panel->priv->notebook), item, tab_label, menu_label);
|
||||||
item,
|
|
||||||
tab_label,
|
|
||||||
menu_label);
|
|
||||||
|
|
||||||
g_signal_emit (G_OBJECT (panel), signals[ITEM_ADDED], 0, item);
|
g_signal_emit (G_OBJECT (panel), signals[ITEM_ADDED], 0, item);
|
||||||
}
|
}
|
||||||
|
@ -715,8 +655,7 @@ xed_panel_add_item_with_stock_icon (XedPanel *panel,
|
||||||
|
|
||||||
if (stock_id != NULL)
|
if (stock_id != NULL)
|
||||||
{
|
{
|
||||||
icon = gtk_image_new_from_stock (stock_id,
|
icon = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
|
||||||
GTK_ICON_SIZE_MENU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xed_panel_add_item (panel, item, name, icon);
|
xed_panel_add_item (panel, item, name, icon);
|
||||||
|
@ -742,32 +681,31 @@ xed_panel_remove_item (XedPanel *panel,
|
||||||
g_return_val_if_fail (XED_IS_PANEL (panel), FALSE);
|
g_return_val_if_fail (XED_IS_PANEL (panel), FALSE);
|
||||||
g_return_val_if_fail (GTK_IS_WIDGET (item), FALSE);
|
g_return_val_if_fail (GTK_IS_WIDGET (item), FALSE);
|
||||||
|
|
||||||
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (panel->priv->notebook),
|
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (panel->priv->notebook), item);
|
||||||
item);
|
|
||||||
|
|
||||||
if (page_num == -1)
|
if (page_num == -1)
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
data = (XedPanelItem *)g_object_get_data (G_OBJECT (item),
|
data = (XedPanelItem *)g_object_get_data (G_OBJECT (item), PANEL_ITEM_KEY);
|
||||||
PANEL_ITEM_KEY);
|
|
||||||
g_return_val_if_fail (data != NULL, FALSE);
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
|
|
||||||
g_free (data->name);
|
g_free (data->name);
|
||||||
g_free (data);
|
g_free (data);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (item),
|
g_object_set_data (G_OBJECT (item), PANEL_ITEM_KEY, NULL);
|
||||||
PANEL_ITEM_KEY,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* ref the item to keep it alive during signal emission */
|
/* ref the item to keep it alive during signal emission */
|
||||||
g_object_ref (G_OBJECT (item));
|
g_object_ref (G_OBJECT (item));
|
||||||
|
|
||||||
gtk_notebook_remove_page (GTK_NOTEBOOK (panel->priv->notebook),
|
gtk_notebook_remove_page (GTK_NOTEBOOK (panel->priv->notebook), page_num);
|
||||||
page_num);
|
|
||||||
|
|
||||||
/* if we removed all the pages, reset the title */
|
/* if we removed all the pages, reset the title */
|
||||||
if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->priv->notebook)) == 0)
|
if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->priv->notebook)) == 0)
|
||||||
|
{
|
||||||
sync_title (panel, NULL);
|
sync_title (panel, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_emit (G_OBJECT (panel), signals[ITEM_REMOVED], 0, item);
|
g_signal_emit (G_OBJECT (panel), signals[ITEM_REMOVED], 0, item);
|
||||||
|
|
||||||
|
@ -794,14 +732,14 @@ xed_panel_activate_item (XedPanel *panel,
|
||||||
g_return_val_if_fail (XED_IS_PANEL (panel), FALSE);
|
g_return_val_if_fail (XED_IS_PANEL (panel), FALSE);
|
||||||
g_return_val_if_fail (GTK_IS_WIDGET (item), FALSE);
|
g_return_val_if_fail (GTK_IS_WIDGET (item), FALSE);
|
||||||
|
|
||||||
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (panel->priv->notebook),
|
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (panel->priv->notebook), item);
|
||||||
item);
|
|
||||||
|
|
||||||
if (page_num == -1)
|
if (page_num == -1)
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->priv->notebook),
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->priv->notebook), page_num);
|
||||||
page_num);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -825,14 +763,14 @@ xed_panel_item_is_active (XedPanel *panel,
|
||||||
g_return_val_if_fail (XED_IS_PANEL (panel), FALSE);
|
g_return_val_if_fail (XED_IS_PANEL (panel), FALSE);
|
||||||
g_return_val_if_fail (GTK_IS_WIDGET (item), FALSE);
|
g_return_val_if_fail (GTK_IS_WIDGET (item), FALSE);
|
||||||
|
|
||||||
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (panel->priv->notebook),
|
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (panel->priv->notebook), item);
|
||||||
item);
|
|
||||||
|
|
||||||
if (page_num == -1)
|
if (page_num == -1)
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
cur_page = gtk_notebook_get_current_page (
|
cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (panel->priv->notebook));
|
||||||
GTK_NOTEBOOK (panel->priv->notebook));
|
|
||||||
|
|
||||||
return (page_num == cur_page);
|
return (page_num == cur_page);
|
||||||
}
|
}
|
||||||
|
@ -878,14 +816,13 @@ _xed_panel_get_active_item_id (XedPanel *panel)
|
||||||
|
|
||||||
g_return_val_if_fail (XED_IS_PANEL (panel), 0);
|
g_return_val_if_fail (XED_IS_PANEL (panel), 0);
|
||||||
|
|
||||||
cur_page = gtk_notebook_get_current_page (
|
cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (panel->priv->notebook));
|
||||||
GTK_NOTEBOOK (panel->priv->notebook));
|
|
||||||
if (cur_page == -1)
|
if (cur_page == -1)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
item = gtk_notebook_get_nth_page (
|
item = gtk_notebook_get_nth_page (GTK_NOTEBOOK (panel->priv->notebook), cur_page);
|
||||||
GTK_NOTEBOOK (panel->priv->notebook),
|
|
||||||
cur_page);
|
|
||||||
|
|
||||||
/* FIXME: for now we use as the hash of the name as id.
|
/* FIXME: for now we use as the hash of the name as id.
|
||||||
* However the name is not guaranteed to be unique and
|
* However the name is not guaranteed to be unique and
|
||||||
|
@ -894,8 +831,7 @@ _xed_panel_get_active_item_id (XedPanel *panel)
|
||||||
* ad hoc id argument.
|
* ad hoc id argument.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
data = (XedPanelItem *)g_object_get_data (G_OBJECT (item),
|
data = (XedPanelItem *)g_object_get_data (G_OBJECT (item), PANEL_ITEM_KEY);
|
||||||
PANEL_ITEM_KEY);
|
|
||||||
g_return_val_if_fail (data != NULL, 0);
|
g_return_val_if_fail (data != NULL, 0);
|
||||||
|
|
||||||
return g_str_hash (data->name);
|
return g_str_hash (data->name);
|
||||||
|
@ -910,27 +846,25 @@ _xed_panel_set_active_item_by_id (XedPanel *panel,
|
||||||
g_return_if_fail (XED_IS_PANEL (panel));
|
g_return_if_fail (XED_IS_PANEL (panel));
|
||||||
|
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
n = gtk_notebook_get_n_pages (
|
n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->priv->notebook));
|
||||||
GTK_NOTEBOOK (panel->priv->notebook));
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
GtkWidget *item;
|
GtkWidget *item;
|
||||||
XedPanelItem *data;
|
XedPanelItem *data;
|
||||||
|
|
||||||
item = gtk_notebook_get_nth_page (
|
item = gtk_notebook_get_nth_page (GTK_NOTEBOOK (panel->priv->notebook), i);
|
||||||
GTK_NOTEBOOK (panel->priv->notebook), i);
|
|
||||||
|
|
||||||
data = (XedPanelItem *)g_object_get_data (G_OBJECT (item),
|
data = (XedPanelItem *)g_object_get_data (G_OBJECT (item), PANEL_ITEM_KEY);
|
||||||
PANEL_ITEM_KEY);
|
|
||||||
g_return_if_fail (data != NULL);
|
g_return_if_fail (data != NULL);
|
||||||
|
|
||||||
if (g_str_hash (data->name) == id)
|
if (g_str_hash (data->name) == id)
|
||||||
{
|
{
|
||||||
gtk_notebook_set_current_page (
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->priv->notebook), i);
|
||||||
GTK_NOTEBOOK (panel->priv->notebook), i);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue