[notification-daemon] Convert from glade to gtk-builder
- From: William Jon McCann <mccann src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [notification-daemon] Convert from glade to gtk-builder
- Date: Sun, 31 Jan 2010 21:55:09 +0000 (UTC)
commit d27a714d613edd56bf3412231db1462776678cc4
Author: William Jon McCann <jmccann redhat com>
Date: Sun Jan 31 13:37:46 2010 -0500
Convert from glade to gtk-builder
configure.ac | 2 +-
po/POTFILES.in | 2 +-
src/capplet/Makefile.am | 8 +-
src/capplet/notification-properties.c | 101 +++------
src/capplet/notification-properties.glade | 325 -----------------------------
src/capplet/notification-properties.ui | 261 +++++++++++++++++++++++
6 files changed, 299 insertions(+), 400 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4f4a52c..dc24927 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,7 +110,7 @@ dnl ---------------------------------------------------------------------------
dnl Requirements for the setup tool
dnl ---------------------------------------------------------------------------
-PKG_CHECK_MODULES(NOTIFICATION_CAPPLET, glib-2.0 >= $REQ_GLIB_VERSION gtk+-2.0 >= $REQ_GTK_VERSION libglade-2.0 gconf-2.0 libnotify dbus-1 dbus-glib-1)
+PKG_CHECK_MODULES(NOTIFICATION_CAPPLET, glib-2.0 >= $REQ_GLIB_VERSION gtk+-2.0 >= $REQ_GTK_VERSION gconf-2.0 libnotify dbus-1 dbus-glib-1)
AC_SUBST(NOTIFICATION_CAPPLET_CFLAGS)
AC_SUBST(NOTIFICATION_CAPPLET_LIBS)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fd8eae4..876ac8e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,6 @@
data/notification-daemon.schemas.in
src/capplet/notification-properties.c
src/capplet/notification-properties.desktop.in
-src/capplet/notification-properties.glade
+src/capplet/notification-properties.ui
src/daemon/daemon.c
src/daemon/sound.c
diff --git a/src/capplet/Makefile.am b/src/capplet/Makefile.am
index 6306027..bb2e400 100644
--- a/src/capplet/Makefile.am
+++ b/src/capplet/Makefile.am
@@ -5,8 +5,8 @@ bin_PROGRAMS = notification-properties
notification_properties_LDADD = $(NOTIFICATION_CAPPLET_LIBS)
notification_properties_SOURCES = notification-properties.c
-gladedir = $(datadir)/notification-daemon
-glade_DATA = notification-properties.glade
+uidir = $(datadir)/notification-daemon
+ui_DATA = notification-properties.ui
desktopdir = $(datadir)/applications
desktop_in_files = notification-properties.desktop.in
@@ -18,9 +18,9 @@ INCLUDES = \
$(NOTIFICATION_CAPPLET_CFLAGS) \
-DENGINES_DIR=\"$(libdir)/notification-daemon-1.0/engines\" \
-DNOTIFICATION_LOCALEDIR=\"$(datadir)/locale\" \
- -DNOTIFICATION_GLADEDIR=\"$(datadir)/notification-daemon\"
+ -DNOTIFICATION_UIDIR=\"$(datadir)/notification-daemon\"
CLEANFILES = $(desktop_DATA)
-EXTRA_DIST = $(glade_DATA) $(pixmap_DATA) $(desktop_in_files)
+EXTRA_DIST = $(ui_DATA) $(pixmap_DATA) $(desktop_in_files)
-include $(top_srcdir)/git.mk
diff --git a/src/capplet/notification-properties.c b/src/capplet/notification-properties.c
index 1b67c18..5a4a170 100644
--- a/src/capplet/notification-properties.c
+++ b/src/capplet/notification-properties.c
@@ -23,7 +23,6 @@
#include <glib/gi18n.h>
#include <glib.h>
#include <gtk/gtk.h>
-#include <glade/glade.h>
#include <gconf/gconf-client.h>
#include <string.h>
#include <libnotify/notify.h>
@@ -36,9 +35,11 @@
#define N_LISTENERS 2
+#define NOTIFICATION_UI_FILE "notification-properties.ui"
+#define WID(s) GTK_WIDGET (gtk_builder_get_object (builder, s))
+
typedef struct
{
- GladeXML *xml;
GConfClient *client;
GtkWidget *dialog;
@@ -68,17 +69,6 @@ enum
N_COLUMNS_THEME
};
-const struct
-{
- const gchar *identifier;
- const gchar *label;
-} popup_stack_locations[] = {
- {"top_left", N_("Top Left")},
- {"top_right", N_("Top Right")},
- {"bottom_left", N_("Bottom Left")},
- {"bottom_right", N_("Bottom Right")}
-};
-
static void
notification_properties_location_notify (GConfClient *client,
guint cnx_id,
@@ -148,33 +138,12 @@ notification_properties_location_changed (GtkComboBox *widget,
static void
notification_properties_dialog_setup_positions (NotificationAppletDialog *dialog)
{
- NotifyStackLocation i;
char *location;
gboolean valid;
- GtkListStore *store;
+ GtkTreeModel *model;
GtkTreeIter iter;
- dialog->position_combo = glade_xml_get_widget (dialog->xml,
- "position_combo");
- g_return_if_fail (dialog->position_combo != NULL);
-
- store = gtk_list_store_new (N_COLUMNS_POSITION,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- for (i = NOTIFY_STACK_LOCATION_TOP_LEFT;
- i <= NOTIFY_STACK_LOCATION_BOTTOM_RIGHT;
- i++) {
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store,
- &iter,
- NOTIFY_POSITION_LABEL, _(popup_stack_locations[i].label),
- NOTIFY_POSITION_NAME, popup_stack_locations[i].identifier,
- -1);
- }
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->position_combo),
- GTK_TREE_MODEL (store));
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->position_combo));
g_signal_connect (dialog->position_combo,
"changed",
G_CALLBACK (notification_properties_location_changed),
@@ -184,12 +153,12 @@ notification_properties_dialog_setup_positions (NotificationAppletDialog *dialog
GCONF_KEY_POPUP_LOCATION,
NULL);
- for (valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
+ for (valid = gtk_tree_model_get_iter_first (model, &iter);
valid;
- valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter)) {
+ valid = gtk_tree_model_iter_next (model, &iter)) {
gchar *key;
- gtk_tree_model_get (GTK_TREE_MODEL (store),
+ gtk_tree_model_get (model,
&iter,
NOTIFY_POSITION_NAME, &key,
-1);
@@ -299,10 +268,6 @@ notification_properties_dialog_setup_themes (NotificationAppletDialog *dialog)
gboolean valid;
GtkListStore *store;
GtkTreeIter iter;
- GtkCellRenderer *cell ;
-
- dialog->theme_combo = glade_xml_get_widget (dialog->xml, "theme_combo");
- g_assert (dialog->theme_combo != NULL);
store = gtk_list_store_new (N_COLUMNS_THEME,
G_TYPE_STRING,
@@ -316,15 +281,6 @@ notification_properties_dialog_setup_themes (NotificationAppletDialog *dialog)
G_CALLBACK (notification_properties_theme_changed),
dialog);
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (GTK_COMBO_BOX (dialog->theme_combo)),
- cell,
- TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (GTK_COMBO_BOX (dialog->theme_combo)),
- cell,
- "text", 0,
- NULL);
-
if ((dir = g_dir_open (ENGINES_DIR, 0, NULL))) {
while ((filename = g_dir_read_name (dir))) {
if (g_str_has_prefix (filename, "lib")
@@ -498,24 +454,38 @@ notification_properties_dialog_destroyed (GtkWidget *widget,
static gboolean
notification_properties_dialog_init (NotificationAppletDialog *dialog)
{
-#define NOTIFICATION_GLADE_FILE "notification-properties.glade"
- const char *glade_file;
+ GtkBuilder *builder;
+ GError *error;
+ const char *ui_file;
- if (g_file_test (NOTIFICATION_GLADE_FILE, G_FILE_TEST_EXISTS))
- glade_file = NOTIFICATION_GLADE_FILE;
- else
- glade_file = NOTIFICATION_GLADEDIR "/" NOTIFICATION_GLADE_FILE;
+ if (g_file_test (NOTIFICATION_UI_FILE, G_FILE_TEST_EXISTS)) {
+ ui_file = NOTIFICATION_UI_FILE;
+ } else {
+ ui_file = NOTIFICATION_UIDIR "/" NOTIFICATION_UI_FILE;
+ }
- dialog->xml = glade_xml_new (glade_file, "dialog", NULL);
+ builder = gtk_builder_new ();
- if (!dialog->xml) {
- g_warning (_("Unable to locate glade file '%s'"), glade_file);
+ error = NULL;
+ gtk_builder_add_from_file (builder, ui_file, &error);
+ if (error != NULL) {
+ g_warning (_("Could not load user interface file: %s"),
+ error->message);
+ g_error_free (error);
return FALSE;
}
- dialog->dialog = glade_xml_get_widget (dialog->xml, "dialog");
+ dialog->dialog = WID ("dialog");
g_assert (dialog->dialog != NULL);
+ dialog->position_combo = WID ("position_combo");
+ g_assert (dialog->position_combo != NULL);
+
+ dialog->theme_combo = WID ("theme_combo");
+ g_assert (dialog->theme_combo != NULL);
+
+ g_object_unref (builder);
+
g_signal_connect (dialog->dialog,
"response",
G_CALLBACK
@@ -545,8 +515,6 @@ notification_properties_dialog_init (NotificationAppletDialog *dialog)
dialog->preview = NULL;
return TRUE;
-
-#undef NOTIFICATION_GLADE_FILE
}
static void
@@ -576,11 +544,6 @@ notification_properties_dialog_finalize (NotificationAppletDialog *dialog)
dialog->client = NULL;
}
- if (dialog->xml != NULL) {
- g_object_unref (dialog->xml);
- dialog->xml = NULL;
- }
-
if (dialog->preview) {
notify_notification_close (dialog->preview, NULL);
dialog->preview = NULL;
diff --git a/src/capplet/notification-properties.ui b/src/capplet/notification-properties.ui
new file mode 100644
index 0000000..0268b13
--- /dev/null
+++ b/src/capplet/notification-properties.ui
@@ -0,0 +1,261 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="dialog">
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Notification Settings</property>
+ <property name="resizable">False</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="icon_name">notification-properties</property>
+ <property name="type_hint">dialog</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkVBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>General Options</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"> </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTable" id="table3">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">12</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkComboBox" id="theme_combo">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkCellRendererText" id="theme_cellrenderertext"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="position_combo">
+ <property name="visible">True</property>
+ <property name="model">position_liststore</property>
+ <child>
+ <object class="GtkCellRendererText" id="position_cellrenderertext"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">P_osition:</property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">position_combo</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Theme:</property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">theme_combo</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button3">
+ <property name="label">gtk-help</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ <property name="focus_on_click">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button4">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <object class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="icon_name">notification-properties</property>
+ <property name="icon-size">3</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Preview</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button5">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-11">button3</action-widget>
+ <action-widget response="-3">button4</action-widget>
+ <action-widget response="-7">button5</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkListStore" id="position_liststore">
+ <columns>
+ <!-- column-name label -->
+ <column type="gchararray"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">Top Left</col>
+ <col id="1" translatable="yes">top_left</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Top Right</col>
+ <col id="1" translatable="yes">top_right</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Bottom Left</col>
+ <col id="1" translatable="yes">bottom_left</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Bottom Right</col>
+ <col id="1" translatable="yes">bottom_right</col>
+ </row>
+ </data>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]