[gnome-panel/wip/segeiger/panel-add-to-dialog: 4/6] PanelAddtoDialog: Implement composite template and widget class
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/segeiger/panel-add-to-dialog: 4/6] PanelAddtoDialog: Implement composite template and widget class
- Date: Fri, 17 Jul 2015 13:03:37 +0000 (UTC)
commit a4969c9eb96c0d6a216339ac2b29625a5dae37a3
Author: Sebastian Geiger <sbastig gmx net>
Date: Thu Jul 16 22:03:32 2015 +0200
PanelAddtoDialog: Implement composite template and widget class
gnome-panel/panel-add-to-dialog.ui | 10 +-
gnome-panel/panel-addto-dialog.c | 456 +++++++++++++++---------------------
gnome-panel/panel-addto-dialog.h | 8 +-
gnome-panel/panel.gresource.xml | 1 +
4 files changed, 209 insertions(+), 266 deletions(-)
---
diff --git a/gnome-panel/panel-add-to-dialog.ui b/gnome-panel/panel-add-to-dialog.ui
index 58b3db5..6833b9e 100644
--- a/gnome-panel/panel-add-to-dialog.ui
+++ b/gnome-panel/panel-add-to-dialog.ui
@@ -51,6 +51,8 @@
<object class="GtkEntry" id="search_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <signal name="activate" handler="panel_addto_search_entry_activated" swapped="yes"/>
+ <signal name="changed" handler="panel_addto_search_entry_changed" swapped="yes"/>
</object>
<packing>
<property name="expand">True</property>
@@ -78,8 +80,11 @@
<property name="model">liststore</property>
<property name="headers_visible">False</property>
<property name="search_column">1</property>
+ <signal name="row-activated" handler="panel_addto_selection_activated" swapped="yes"/>
<child internal-child="selection">
- <object class="GtkTreeSelection" id="tree_view_selection"/>
+ <object class="GtkTreeSelection" id="tree_view_selection">
+ <signal name="changed" handler="panel_addto_selection_changed" swapped="yes"/>
+ </object>
</child>
<child>
<object class="GtkTreeViewColumn" id="tree_view_column_icon">
@@ -140,6 +145,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
+ <signal name="clicked" handler="panel_addto_dialog_button_back" swapped="yes"/>
</object>
<packing>
<property name="expand">True</property>
@@ -154,6 +160,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
+ <signal name="clicked" handler="panel_addto_dialog_button_add" swapped="yes"/>
</object>
<packing>
<property name="expand">True</property>
@@ -169,6 +176,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
+ <signal name="clicked" handler="panel_addto_dialog_button_close" swapped="yes"/>
</object>
<packing>
<property name="expand">True</property>
diff --git a/gnome-panel/panel-addto-dialog.c b/gnome-panel/panel-addto-dialog.c
index 6d73e61..6a832e4 100644
--- a/gnome-panel/panel-addto-dialog.c
+++ b/gnome-panel/panel-addto-dialog.c
@@ -23,7 +23,9 @@
#include <config.h>
#include <string.h>
+#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include <glib-object.h>
#include <gmenu-tree.h>
@@ -47,15 +49,19 @@
#include "panel-icon-names.h"
#include "panel-user-menu.h"
-typedef struct {
+struct _PanelAddtoDialog {
+ GtkWindow parent;
PanelWidget *panel_widget;
- GtkWidget *addto_dialog;
+ GtkWidget *dialog_vbox;
GtkWidget *label;
GtkWidget *search_entry;
- GtkWidget *back_button;
- GtkWidget *add_button;
+ GtkWidget *button_back;
+ GtkWidget *button_add;
+ GtkWidget *button_close;
GtkWidget *tree_view;
+ GtkWidget *tree_view_selection;
+
GtkTreeModel *applet_model;
GtkTreeModel *filter_applet_model;
GtkTreeModel *application_model;
@@ -70,10 +76,12 @@ typedef struct {
gchar *search_text;
gchar *applet_search_text;
- guint name_notify;
+ gulong name_notify;
PanelObjectPackType insert_pack_type;
-} PanelAddtoDialog;
+};
+
+G_DEFINE_TYPE (PanelAddtoDialog, panel_addto_dialog, GTK_TYPE_WINDOW)
static GQuark panel_addto_dialog_quark = 0;
@@ -805,59 +813,53 @@ panel_addto_add_item (PanelAddtoDialog *dialog,
}
static void
-panel_addto_dialog_response (GtkWidget *widget_dialog,
- guint response_id,
- PanelAddtoDialog *dialog)
+panel_addto_dialog_button_add (PanelAddtoDialog *dialog,
+ GtkWidget *widget)
{
GtkTreeSelection *selection;
- GtkTreeModel *filter_model;
- GtkTreeModel *child_model;
- GtkTreeIter iter;
- GtkTreeIter filter_iter;
-
- switch (response_id) {
- case PANEL_ADDTO_RESPONSE_ADD:
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree_view));
- if (gtk_tree_selection_get_selected (selection, &filter_model,
- &filter_iter)) {
- PanelAddtoItemInfo *data;
-
- gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER
(filter_model),
- &iter,
- &filter_iter);
- child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
- gtk_tree_model_get (child_model, &iter,
- COLUMN_DATA, &data, -1);
-
- if (data != NULL)
- panel_addto_add_item (dialog, data);
- }
- break;
-
- case PANEL_ADDTO_RESPONSE_BACK:
- /* This response only happens when we're showing the
- * application list and the user wants to go back to the
- * applet list. */
- panel_addto_present_applets (dialog);
- break;
+ GtkTreeModel *filter_model;
+ GtkTreeModel *child_model;
+ GtkTreeIter iter;
+ GtkTreeIter filter_iter;
- case GTK_RESPONSE_CLOSE:
- gtk_widget_destroy (widget_dialog);
- break;
- default:
- break;
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree_view));
+ if (gtk_tree_selection_get_selected (selection, &filter_model,
+ &filter_iter)) {
+ PanelAddtoItemInfo *data;
+
+ gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (filter_model),
+
&iter,
+
&filter_iter);
+ child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
+ gtk_tree_model_get (child_model, &iter,
+ COLUMN_DATA, &data, -1);
+
+ if (data != NULL)
+ panel_addto_add_item (dialog, data);
}
}
+/* This callback is only called when we're showing the
+ * application list and the user wants to go back to the
+ * applet list. */
static void
-panel_addto_dialog_destroy (GtkWidget *widget_dialog,
- PanelAddtoDialog *dialog)
+<<<<<<< HEAD
+panel_addto_dialog_button_back (GtkWidget *widget,
+ PanelAddtoDialog *dialog)
+=======
+panel_addto_dialog_button_back (PanelAddtoDialog *dialog,
+ GtkWidget *widget)
+>>>>>>> 14bd0f5... PanelAddtoDialog: Use template to connect callbacks
{
- panel_toplevel_pop_autohide_disabler (PANEL_TOPLEVEL (dialog->panel_widget->toplevel));
- g_object_set_qdata (G_OBJECT (dialog->panel_widget->toplevel),
- panel_addto_dialog_quark,
- NULL);
+ panel_addto_present_applets (dialog);
+}
+
+static void
+panel_addto_dialog_button_close (PanelAddtoDialog *dialog,
+ GtkWidget *widget)
+{
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
@@ -867,9 +869,9 @@ panel_addto_present_applications (PanelAddtoDialog *dialog)
panel_addto_make_application_model (dialog);
gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tree_view),
dialog->filter_application_model);
- gtk_window_set_focus (GTK_WINDOW (dialog->addto_dialog),
+ gtk_window_set_focus (GTK_WINDOW (dialog),
dialog->search_entry);
- gtk_widget_set_sensitive (dialog->back_button, TRUE);
+ gtk_widget_set_sensitive (dialog->button_back, TRUE);
if (dialog->applet_search_text)
g_free (dialog->applet_search_text);
@@ -886,9 +888,9 @@ panel_addto_present_applets (PanelAddtoDialog *dialog)
panel_addto_make_applet_model (dialog);
gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tree_view),
dialog->filter_applet_model);
- gtk_window_set_focus (GTK_WINDOW (dialog->addto_dialog),
+ gtk_window_set_focus (GTK_WINDOW (dialog),
dialog->search_entry);
- gtk_widget_set_sensitive (dialog->back_button, FALSE);
+ gtk_widget_set_sensitive (dialog->button_back, FALSE);
if (dialog->applet_search_text) {
gtk_entry_set_text (GTK_ENTRY (dialog->search_entry),
@@ -908,35 +910,27 @@ panel_addto_dialog_free_item_info (PanelAddtoItemInfo *item_info)
return;
/* the GIcon is never static */
- if (item_info->icon != NULL)
- g_object_unref (item_info->icon);
- item_info->icon = NULL;
+ g_clear_object (&item_info->icon);
if (item_info->static_strings)
return;
- if (item_info->name != NULL)
- g_free (item_info->name);
+ g_free (item_info->name);
item_info->name = NULL;
- if (item_info->description != NULL)
- g_free (item_info->description);
+ g_free (item_info->description);
item_info->description = NULL;
- if (item_info->iid != NULL)
- g_free (item_info->iid);
+ g_free (item_info->iid);
item_info->iid = NULL;
- if (item_info->launcher_path != NULL)
- g_free (item_info->launcher_path);
+ g_free (item_info->launcher_path);
item_info->launcher_path = NULL;
- if (item_info->menu_filename != NULL)
- g_free (item_info->menu_filename);
+ g_free (item_info->menu_filename);
item_info->menu_filename = NULL;
- if (item_info->menu_path != NULL)
- g_free (item_info->menu_path);
+ g_free (item_info->menu_path);
item_info->menu_path = NULL;
}
@@ -961,63 +955,6 @@ panel_addto_dialog_free_application_list (GSList *application_list)
}
static void
-panel_addto_dialog_free (PanelAddtoDialog *dialog)
-{
- GSList *item;
-
- if (dialog->name_notify)
- g_signal_handler_disconnect (dialog->panel_widget->toplevel,
- dialog->name_notify);
- dialog->name_notify = 0;
-
- if (dialog->search_text)
- g_free (dialog->search_text);
- dialog->search_text = NULL;
-
- if (dialog->applet_search_text)
- g_free (dialog->applet_search_text);
- dialog->applet_search_text = NULL;
-
- if (dialog->addto_dialog)
- gtk_widget_destroy (dialog->addto_dialog);
- dialog->addto_dialog = NULL;
-
- for (item = dialog->applet_list; item != NULL; item = item->next) {
- PanelAddtoItemInfo *applet;
-
- applet = (PanelAddtoItemInfo *) item->data;
- panel_addto_dialog_free_item_info (applet);
- g_free (applet);
- }
- g_slist_free (dialog->applet_list);
-
- panel_addto_dialog_free_application_list (dialog->application_list);
- panel_addto_dialog_free_application_list (dialog->settings_list);
-
- if (dialog->filter_applet_model)
- g_object_unref (dialog->filter_applet_model);
- dialog->filter_applet_model = NULL;
-
- if (dialog->applet_model)
- g_object_unref (dialog->applet_model);
- dialog->applet_model = NULL;
-
- if (dialog->filter_application_model)
- g_object_unref (dialog->filter_application_model);
- dialog->filter_application_model = NULL;
-
- if (dialog->application_model)
- g_object_unref (dialog->application_model);
- dialog->application_model = NULL;
-
- if (dialog->menu_tree)
- g_object_unref (dialog->menu_tree);
- dialog->menu_tree = NULL;
-
- g_free (dialog);
-}
-
-static void
panel_addto_name_change (PanelAddtoDialog *dialog)
{
const char *name;
@@ -1033,9 +970,6 @@ panel_addto_name_change (PanelAddtoDialog *dialog)
if (label == NULL)
label = g_strdup (_("Find an _item to add to the panel:"));
- gtk_window_set_title (GTK_WINDOW (dialog->addto_dialog),
- _("Add to Panel"));
-
gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->label), label);
g_free (label);
}
@@ -1079,8 +1013,8 @@ panel_addto_filter_func (GtkTreeModel *model,
}
static void
-panel_addto_search_entry_changed (GtkWidget *entry,
- PanelAddtoDialog *dialog)
+panel_addto_search_entry_changed (PanelAddtoDialog *dialog,
+ GtkWidget *entry)
{
GtkTreeModel *model;
char *new_text;
@@ -1116,16 +1050,19 @@ panel_addto_search_entry_changed (GtkWidget *entry,
}
static void
-panel_addto_search_entry_activated (GtkWidget *entry,
- PanelAddtoDialog *dialog)
+panel_addto_search_entry_activated (PanelAddtoDialog *dialog,
+ GtkWidget *entry)
{
- gtk_dialog_response (GTK_DIALOG (dialog->addto_dialog),
- PANEL_ADDTO_RESPONSE_ADD);
+<<<<<<< HEAD
+ panel_addto_dialog_button_add (entry, dialog);
+=======
+ panel_addto_dialog_button_add (dialog, entry);
+>>>>>>> 14bd0f5... PanelAddtoDialog: Use template to connect callbacks
}
static void
-panel_addto_selection_changed (GtkTreeSelection *selection,
- PanelAddtoDialog *dialog)
+panel_addto_selection_changed (PanelAddtoDialog *dialog,
+ GtkTreeSelection *selection)
{
GtkTreeModel *filter_model;
GtkTreeModel *child_model;
@@ -1137,7 +1074,7 @@ panel_addto_selection_changed (GtkTreeSelection *selection,
if (!gtk_tree_selection_get_selected (selection,
&filter_model,
&filter_iter)) {
- gtk_widget_set_sensitive (GTK_WIDGET (dialog->add_button),
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog->button_add),
FALSE);
return;
}
@@ -1148,18 +1085,18 @@ panel_addto_selection_changed (GtkTreeSelection *selection,
gtk_tree_model_get (child_model, &iter, COLUMN_DATA, &data, -1);
if (!data) {
- gtk_widget_set_sensitive (GTK_WIDGET (dialog->add_button),
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog->button_add),
FALSE);
return;
}
- gtk_widget_set_sensitive (GTK_WIDGET (dialog->add_button), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog->button_add), TRUE);
if (data->type == PANEL_ADDTO_LAUNCHER_MENU) {
- gtk_button_set_label (GTK_BUTTON (dialog->add_button),
+ gtk_button_set_label (GTK_BUTTON (dialog->button_add),
_("_Forward"));
} else {
- gtk_button_set_label (GTK_BUTTON (dialog->add_button),
+ gtk_button_set_label (GTK_BUTTON (dialog->button_add),
_("_Add"));
}
@@ -1199,13 +1136,12 @@ panel_addto_selection_changed (GtkTreeSelection *selection,
}
static void
-panel_addto_selection_activated (GtkTreeView *view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- PanelAddtoDialog *dialog)
+panel_addto_selection_activated (PanelAddtoDialog *dialog,
+ GtkTreeView *view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column)
{
- gtk_dialog_response (GTK_DIALOG (dialog->addto_dialog),
- PANEL_ADDTO_RESPONSE_ADD);
+ panel_addto_dialog_button_add (dialog, dialog->button_add);
}
static gboolean
@@ -1229,20 +1165,12 @@ static PanelAddtoDialog *
panel_addto_dialog_new (PanelWidget *panel_widget)
{
PanelAddtoDialog *dialog;
- GtkWidget *dialog_vbox;
- GtkWidget *inner_vbox;
- GtkWidget *find_hbox;
- GtkWidget *sw;
- GtkCellRenderer *renderer;
- GtkTreeSelection *selection;
- GtkTreeViewColumn *column;
- dialog = g_new0 (PanelAddtoDialog, 1);
+ dialog = g_object_new (PANEL_TYPE_ADDTO_DIALOG, NULL);
- g_object_set_qdata_full (G_OBJECT (panel_widget->toplevel),
+ g_object_set_qdata (G_OBJECT (panel_widget->toplevel),
panel_addto_dialog_quark,
- dialog,
- (GDestroyNotify) panel_addto_dialog_free);
+ dialog);
dialog->panel_widget = panel_widget;
dialog->name_notify =
@@ -1251,124 +1179,126 @@ panel_addto_dialog_new (PanelWidget *panel_widget)
G_CALLBACK (panel_addto_name_notify),
dialog);
- dialog->addto_dialog = gtk_dialog_new ();
- dialog->back_button = gtk_dialog_add_button (GTK_DIALOG (dialog->addto_dialog),
- _("_Back"),
- PANEL_ADDTO_RESPONSE_BACK);
- dialog->add_button = gtk_dialog_add_button (GTK_DIALOG (dialog->addto_dialog),
- _("_Add"),
- PANEL_ADDTO_RESPONSE_ADD);
- gtk_dialog_add_button (GTK_DIALOG (dialog->addto_dialog),
- _("_Close"),
- GTK_RESPONSE_CLOSE);
- gtk_widget_set_sensitive (GTK_WIDGET (dialog->add_button), FALSE);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog->addto_dialog),
- PANEL_ADDTO_RESPONSE_ADD);
-
- gtk_container_set_border_width (GTK_CONTAINER (dialog->addto_dialog), 5);
-
- dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog->addto_dialog));
- gtk_box_set_spacing (GTK_BOX (dialog_vbox), 12);
- gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
-
- g_signal_connect (G_OBJECT (dialog->addto_dialog), "response",
- G_CALLBACK (panel_addto_dialog_response), dialog);
- g_signal_connect (dialog->addto_dialog, "destroy",
- G_CALLBACK (panel_addto_dialog_destroy), dialog);
-
- inner_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (dialog_vbox), inner_vbox, TRUE, TRUE, 0);
-
- find_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (inner_vbox), find_hbox, FALSE, FALSE, 0);
-
- dialog->label = gtk_label_new_with_mnemonic ("");
- gtk_label_set_xalign (GTK_LABEL (dialog->label), 0.0);
- gtk_label_set_use_markup (GTK_LABEL (dialog->label), TRUE);
-
- gtk_box_pack_start (GTK_BOX (find_hbox), dialog->label,
- FALSE, FALSE, 0);
-
- dialog->search_entry = gtk_entry_new ();
- g_signal_connect (G_OBJECT (dialog->search_entry), "changed",
- G_CALLBACK (panel_addto_search_entry_changed), dialog);
- g_signal_connect (G_OBJECT (dialog->search_entry), "activate",
- G_CALLBACK (panel_addto_search_entry_activated), dialog);
-
- gtk_box_pack_end (GTK_BOX (find_hbox), dialog->search_entry,
- TRUE, TRUE, 0);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (dialog->label),
- dialog->search_entry);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
- GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (inner_vbox), sw, TRUE, TRUE, 0);
-
- dialog->tree_view = gtk_tree_view_new ();
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dialog->tree_view),
- FALSE);
+ gtk_widget_show_all (dialog->dialog_vbox);
+
+ panel_toplevel_push_autohide_disabler (dialog->panel_widget->toplevel);
+ panel_widget_register_open_dialog (panel_widget,
+ GTK_WIDGET (dialog));
+
+ panel_addto_name_change (dialog);
+
+ return dialog;
+}
+
+static void
+panel_addto_dialog_constructed (GObject *object)
+{
+ G_OBJECT_CLASS (panel_addto_dialog_parent_class)->constructed (object);
+ PanelAddtoDialog *dialog = PANEL_ADDTO_DIALOG (object);
+
+ /* Not sure if this can be removed or if there needs for some reason? */
gtk_tree_view_expand_all (GTK_TREE_VIEW (dialog->tree_view));
- renderer = g_object_new (GTK_TYPE_CELL_RENDERER_PIXBUF,
- "xpad", 4,
- "ypad", 4,
- "stock-size", GTK_ICON_SIZE_DND,
- NULL);
-
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (dialog->tree_view),
- -1, NULL,
- renderer,
- "gicon", COLUMN_ICON,
- NULL);
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (dialog->tree_view),
- -1, NULL,
- renderer,
- "markup", COLUMN_TEXT,
- NULL);
-
- //FIXME use the same search than the one for the search entry?
+ /*FIXME use the same search than the one for the search entry? */
gtk_tree_view_set_search_column (GTK_TREE_VIEW (dialog->tree_view),
- COLUMN_SEARCH);
+ COLUMN_SEARCH);
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (dialog->tree_view),
panel_addto_separator_func,
GINT_TO_POINTER (COLUMN_TEXT),
NULL);
-
+}
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree_view));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+static void
+panel_addto_dialog_dispose (GObject *object)
+{
+ PanelAddtoDialog *dialog;
- column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->tree_view),
- COLUMN_TEXT);
- gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
+ dialog = PANEL_ADDTO_DIALOG (object);
- g_signal_connect (selection, "changed",
- G_CALLBACK (panel_addto_selection_changed),
- dialog);
+ if (dialog->name_notify)
+ g_signal_handler_disconnect (dialog->panel_widget->toplevel,
+ dialog->name_notify);
- g_signal_connect (dialog->tree_view, "row-activated",
- G_CALLBACK (panel_addto_selection_activated),
- dialog);
+ dialog->name_notify = 0;
- gtk_container_add (GTK_CONTAINER (sw), dialog->tree_view);
+ g_clear_object (&dialog->filter_applet_model);
+ g_clear_object (&dialog->applet_model);
+ g_clear_object (&dialog->filter_application_model);
+ g_clear_object (&dialog->application_model);
+ g_clear_object (&dialog->menu_tree);
- gtk_widget_show_all (dialog_vbox);
+ G_OBJECT_CLASS (panel_addto_dialog_parent_class)->dispose (object);
+}
- panel_toplevel_push_autohide_disabler (dialog->panel_widget->toplevel);
- panel_widget_register_open_dialog (panel_widget,
- dialog->addto_dialog);
+static void
+panel_addto_dialog_finalize (GObject *object)
+{
+ PanelAddtoDialog *dialog;
+ GSList *item;
- panel_addto_name_change (dialog);
+ dialog = PANEL_ADDTO_DIALOG (object);
- return dialog;
+ panel_toplevel_pop_autohide_disabler (PANEL_TOPLEVEL (dialog->panel_widget->toplevel));
+ g_object_set_qdata (G_OBJECT (dialog->panel_widget->toplevel),
+ panel_addto_dialog_quark,
+ NULL);
+
+ g_free (dialog->search_text);
+ dialog->search_text = NULL;
+
+ g_free (dialog->applet_search_text);
+ dialog->applet_search_text = NULL;
+
+ for (item = dialog->applet_list; item != NULL; item = item->next) {
+ PanelAddtoItemInfo *applet;
+
+ applet = (PanelAddtoItemInfo *) item->data;
+ panel_addto_dialog_free_item_info (applet);
+ g_free (applet);
+ }
+ g_slist_free (dialog->applet_list);
+
+ panel_addto_dialog_free_application_list (dialog->application_list);
+ panel_addto_dialog_free_application_list (dialog->settings_list);
+
+ G_OBJECT_CLASS (panel_addto_dialog_parent_class)->finalize (object);
+}
+
+static void
+panel_addto_dialog_class_init (PanelAddtoDialogClass *dialog_class)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (dialog_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (dialog_class);
+
+ object_class->constructed = panel_addto_dialog_constructed;
+ object_class->dispose = panel_addto_dialog_dispose;
+ object_class->finalize = panel_addto_dialog_finalize;
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/panel/panel-add-to-dialog.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, dialog_vbox);
+ gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, label);
+ gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, search_entry);
+ gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, button_add);
+ gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, button_back);
+ gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, button_close);
+ gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, tree_view);
+ gtk_widget_class_bind_template_child (widget_class, PanelAddtoDialog, tree_view_selection);
+
+ gtk_widget_class_bind_template_callback (widget_class, panel_addto_dialog_button_add);
+ gtk_widget_class_bind_template_callback (widget_class, panel_addto_dialog_button_back);
+ gtk_widget_class_bind_template_callback (widget_class, panel_addto_dialog_button_close);
+ gtk_widget_class_bind_template_callback (widget_class, panel_addto_search_entry_changed);
+ gtk_widget_class_bind_template_callback (widget_class, panel_addto_search_entry_activated);
+ gtk_widget_class_bind_template_callback (widget_class, panel_addto_selection_changed);
+ gtk_widget_class_bind_template_callback (widget_class, panel_addto_selection_activated);
+}
+
+static void
+panel_addto_dialog_init (PanelAddtoDialog *dialog)
+{
+ gtk_widget_init_template (GTK_WIDGET (dialog));
}
#define MAX_ADDTOPANEL_HEIGHT 490
@@ -1404,8 +1334,8 @@ panel_addto_present (GtkMenuItem *item,
}
dialog->insert_pack_type = pd ? pd->insert_pack_type : PANEL_OBJECT_PACK_START;
- gtk_window_set_screen (GTK_WINDOW (dialog->addto_dialog), screen);
- gtk_window_set_default_size (GTK_WINDOW (dialog->addto_dialog),
+ gtk_window_set_screen (GTK_WINDOW (dialog), screen);
+ gtk_window_set_default_size (GTK_WINDOW (dialog),
height * 8 / 7, height);
- gtk_window_present (GTK_WINDOW (dialog->addto_dialog));
+ gtk_window_present (GTK_WINDOW (dialog));
}
diff --git a/gnome-panel/panel-addto-dialog.h b/gnome-panel/panel-addto-dialog.h
index 6a77a9a..5139a8e 100644
--- a/gnome-panel/panel-addto-dialog.h
+++ b/gnome-panel/panel-addto-dialog.h
@@ -23,10 +23,14 @@
#ifndef PANEL_ADDTO_DIALOG_H
#define PANEL_ADDTO_DIALOG_H
+#include <gtk/gtk.h>
+
G_BEGIN_DECLS
-void panel_addto_present (GtkMenuItem *item,
- PanelWidget *panel_widget);
+#define PANEL_TYPE_ADDTO_DIALOG panel_addto_dialog_get_type()
+G_DECLARE_FINAL_TYPE (PanelAddtoDialog, panel_addto_dialog, PANEL, ADDTO_DIALOG, GtkWindow)
+
+void panel_addto_present (GtkMenuItem *item, PanelWidget *panel_widget);
G_END_DECLS
diff --git a/gnome-panel/panel.gresource.xml b/gnome-panel/panel.gresource.xml
index 7124d59..77da2de 100644
--- a/gnome-panel/panel.gresource.xml
+++ b/gnome-panel/panel.gresource.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/panel">
+ <file compressed="true">panel-add-to-dialog.ui</file>
<file compressed="true">panel-properties-dialog.ui</file>
<file compressed="true">panel-run-dialog.ui</file>
<file>wanda_no_sea.png</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]