[gnome-pilot] Convert applet from libglade to GtkBuilder.
- From: Matthew Charles Davey <mcdavey src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-pilot] Convert applet from libglade to GtkBuilder.
- Date: Sat, 5 Sep 2009 13:24:47 +0000 (UTC)
commit ce7c75c3f231cc9c9fcfd491536c6f7b76511555
Author: Robert Ancell <robert ancell gmail com>
Date: Sat Sep 5 14:23:33 2009 +0100
Convert applet from libglade to GtkBuilder.
2009-09-05 Robert Ancell <robert ancell gmail com>
* applet/Makefile.am: #589501, with thanks to
Robert Ancell. Convert applet to GtkBuilder.
* applet/pilot-applet.glade: ditto.
* applet/pilot-applet.ui: ditto.
* applet/pilot.c: ditto.
* po/POTFILES.in: ditto.
ChangeLog | 8 +
applet/Makefile.am | 8 +-
applet/pilot-applet.glade | 638 ---------------------------------------------
applet/pilot-applet.ui | 468 +++++++++++++++++++++++++++++++++
applet/pilot.c | 161 +++++++-----
po/POTFILES.in | 2 +-
6 files changed, 579 insertions(+), 706 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index aa2b906..bd36a65 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-09-05 Robert Ancell <robert ancell gmail com>
+ * applet/Makefile.am: Partial fix for bug #589501.
+ Convert applet to GtkBuilder.
+ * applet/pilot-applet.glade: ditto.
+ * applet/pilot-applet.ui: ditto.
+ * applet/pilot.c: ditto.
+ * po/POTFILES.in: ditto.
+
2009-09-03 Matt Davey <mcdavey mrao cam ac uk>
* applet/pilot.c: minor cleanup of migration to
GtkAboutDialog
diff --git a/applet/Makefile.am b/applet/Makefile.am
index dac564d..b4e3d7d 100644
--- a/applet/Makefile.am
+++ b/applet/Makefile.am
@@ -34,7 +34,7 @@ INCLUDES = \
-I$(top_srcdir) \
$(GNOME_PILOT_CFLAGS) \
$(PILOT_APPLET_CFLAGS) \
- -DGLADEDATADIR=\""$(gladedir)"\" \
+ -DUIDATADIR=\""$(uidir)"\" \
-DPREFIX=\""$(prefix)\"" \
-DSYSCONFDIR=\""$(sysconfdir)\"" \
-DDATADIR=\""$(datadir)\"" \
@@ -42,8 +42,8 @@ INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"
-gladedir = $(datadir)/gnome-pilot/glade
-glade_DATA = pilot-applet.glade
+uidir = $(datadir)/gnome-pilot/ui
+ui_DATA = pilot-applet.ui
pixmapdir = $(datadir)/pixmaps
pixmap_DATA = sync_paused.png sync_broken.png sync_icon.png syncing_icon.png
@@ -69,7 +69,7 @@ install-data-local:
EXTRA_DIST = \
$(pixmap_DATA) \
- $(glade_DATA) \
+ $(ui_DATA) \
$(gobfiles) \
$(server_in_files) \
$(schemas_in_files) \
diff --git a/applet/pilot-applet.ui b/applet/pilot-applet.ui
new file mode 100644
index 0000000..a0f8343
--- /dev/null
+++ b/applet/pilot-applet.ui
@@ -0,0 +1,468 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="ChoosePilot">
+ <property name="title" translatable="yes">Choose PDA</property>
+ <property name="type_hint">normal</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="vbox12">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">8</property>
+ <child>
+ <object class="GtkFrame" id="frame9">
+ <property name="visible">True</property>
+ <property name="label_xalign">0.5</property>
+ <child>
+ <object class="GtkComboBox" id="pilot_combo">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Choose PDA</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="hbuttonbox4">
+ <property name="visible">True</property>
+ <property name="layout_style">edge</property>
+ <child>
+ <object class="GtkButton" id="button5">
+ <property name="label">gtk-ok</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">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button6">
+ <property name="label">gtk-cancel</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">1</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="0">button5</action-widget>
+ <action-widget response="0">button6</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkDialog" id="ProgressDialog">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">gnome-pilot progress</property>
+ <property name="default_width">500</property>
+ <property name="type_hint">normal</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="main_vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">8</property>
+ <child>
+ <object class="GtkVBox" id="inner_vbox">
+ <property name="visible">True</property>
+ <property name="border_width">4</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="sync_label">
+ <property name="visible">True</property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkProgressBar" id="overall_progress_bar">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkProgressBar" id="conduit_progress_bar">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolled_window">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTextView" id="message_area">
+ <property name="height_request">153</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="wrap_mode">word</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="action_area">
+ <property name="visible">True</property>
+ <property name="layout_style">edge</property>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="label">gtk-cancel</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">0</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="0">cancel_button</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkDialog" id="RestoreDialog">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Restore PDA</property>
+ <property name="type_hint">normal</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox5">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">8</property>
+ <child>
+ <object class="GtkFrame" id="main_frame">
+ <property name="visible">True</property>
+ <property name="label_xalign">0.5</property>
+ <child>
+ <object class="GtkTable" id="table2">
+ <property name="visible">True</property>
+ <property name="border_width">4</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Directory</property>
+ <property name="use_underline">True</property>
+ <property name="justify">center</property>
+ <property name="mnemonic_widget">dir_entry</property>
+ </object>
+ <packing>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="label" translatable="yes">_PDA ID</property>
+ <property name="use_underline">True</property>
+ <property name="justify">center</property>
+ <property name="mnemonic_widget">pilotid_entry</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="sync_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Sync cradle</property>
+ <property name="use_underline">True</property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="dir_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="pilotid_entry">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ </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>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="device_combo">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area5">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button8">
+ <property name="label">gtk-ok</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">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button10">
+ <property name="label">gtk-cancel</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">1</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="-5">button8</action-widget>
+ <action-widget response="-6">button10</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkDialog" id="PropertiesDialog">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">GNOME PilotSync Properties</property>
+ <property name="type_hint">normal</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox6">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="border_width">4</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Execute when clicked</property>
+ <property name="use_underline">True</property>
+ <property name="justify">center</property>
+ <property name="mnemonic_widget">exec_entry</property>
+ </object>
+ <packing>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Display notices</property>
+ <property name="use_underline">True</property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="exec_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="notices_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <child>
+ <placeholder/>
+ </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>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area6">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="helpbutton">
+ <property name="label">gtk-help</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">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="closebutton1">
+ <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">1</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">helpbutton</action-widget>
+ <action-widget response="-7">closebutton1</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/applet/pilot.c b/applet/pilot.c
index b6774cf..05e8f18 100644
--- a/applet/pilot.c
+++ b/applet/pilot.c
@@ -27,7 +27,6 @@
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
-#include <glade/glade.h>
#include <gtk/gtk.h>
#include <panel-applet-gconf.h>
@@ -94,7 +93,7 @@ typedef struct {
GtkWidget *chooseDialog;
GtkWidget *restoreDialog;
GdkColor errorColor;
- gchar* glade_file;
+ gchar *ui_file;
GnomePilotClient *gpc;
} PilotApplet;
@@ -121,6 +120,25 @@ static gboolean timeout (PilotApplet *self);
/******************************************************************/
+static GtkBuilder *
+load_ui (const gchar *filename, const gchar *widget)
+{
+ GtkBuilder *ui;
+ gchar *objects[2] = {NULL, NULL};
+
+ ui = gtk_builder_new ();
+ objects[0] = (gchar *)widget;
+ gtk_builder_add_objects_from_file (ui, filename, objects, NULL);
+
+ return ui;
+}
+
+static GtkWidget *
+get_widget (GtkBuilder *ui, const gchar *name)
+{
+ return GTK_WIDGET (gtk_builder_get_object (ui, name));
+}
+
static void
gpilotd_connect_cb (GnomePilotClient *client,
const gchar *id,
@@ -147,13 +165,13 @@ gpilotd_connect_cb (GnomePilotClient *client,
if (applet->progressDialog == NULL) {
gtk_window_set_default_icon_from_file (
GNOME_ICONDIR "/sync_icon.png", &error);
- GladeXML *xml = glade_xml_new (applet->glade_file,"ProgressDialog",NULL);
- applet->progressDialog = glade_xml_get_widget (xml,"ProgressDialog");
- applet->sync_label = glade_xml_get_widget (xml,"sync_label");
- applet->message_area = glade_xml_get_widget (xml,"message_area");
- applet->overall_progress_bar = glade_xml_get_widget (xml,"overall_progress_bar");
- applet->conduit_progress_bar = glade_xml_get_widget (xml,"conduit_progress_bar");
- applet->cancel_button = glade_xml_get_widget (xml,"cancel_button");
+ GtkBuilder *ui = load_ui (applet->ui_file,"ProgressDialog");
+ applet->progressDialog = get_widget (ui,"ProgressDialog");
+ applet->sync_label = get_widget (ui,"sync_label");
+ applet->message_area = get_widget (ui,"message_area");
+ applet->overall_progress_bar = get_widget (ui,"overall_progress_bar");
+ applet->conduit_progress_bar = get_widget (ui,"conduit_progress_bar");
+ applet->cancel_button = get_widget (ui,"cancel_button");
applet->message_buffer = gtk_text_view_get_buffer(
GTK_TEXT_VIEW(applet->message_area));
@@ -504,14 +522,14 @@ properties_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname
{
PilotApplet *self = user_data;
GtkWidget *button, *entry, *dialog;
- GladeXML *xml;
+ GtkBuilder *ui;
GError *error;
gtk_window_set_default_icon_from_file (GNOME_ICONDIR "/sync_icon.png", &error);
- xml =glade_xml_new (self->glade_file,"PropertiesDialog", NULL);
- dialog=glade_xml_get_widget (xml,"PropertiesDialog");
+ ui = load_ui (self->ui_file,"PropertiesDialog");
+ dialog = get_widget (ui,"PropertiesDialog");
- entry = glade_xml_get_widget (xml,"exec_entry");
+ entry = get_widget (ui,"exec_entry");
if (self->properties.exec_when_clicked)
gtk_entry_set_text (GTK_ENTRY (entry), self->properties.exec_when_clicked);
gtk_signal_connect (GTK_OBJECT (entry), "focus-out-event",
@@ -519,7 +537,7 @@ properties_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname
self);
- button = glade_xml_get_widget (xml,"notices_button");
+ button = get_widget (ui,"notices_button");
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), self->properties.popups);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
GTK_SIGNAL_FUNC (toggle_notices_cb),
@@ -622,9 +640,11 @@ restore_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname)
int handle,i;
gchar *pilot_name;
guint pilot_id;
- GladeXML *xml;
+ GtkBuilder *ui;
GtkWidget *dir_entry, *id_entry,*frame;
- GtkWidget *device_menu, *menu_item,*menu;
+ GtkWidget *device_combo;
+ GtkListStore *list_store;
+ GtkCellRenderer *renderer;
GList *list;
gchar *buf = NULL;
restore_properties restore_props;
@@ -652,23 +672,23 @@ restore_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname)
return;
}
- xml = glade_xml_new (applet->glade_file,"RestoreDialog",NULL);
- applet->restoreDialog = glade_xml_get_widget (xml,"RestoreDialog");
+ ui = load_ui (applet->ui_file, "RestoreDialog");
+ applet->restoreDialog = get_widget (ui, "RestoreDialog");
- dir_entry = glade_xml_get_widget (xml,"dir_entry");
+ dir_entry = get_widget (ui, "dir_entry");
gtk_entry_set_text (GTK_ENTRY (dir_entry),restore_props.backupdir);
g_free (restore_props.backupdir);
restore_props.backupdir=NULL;
/* FIXME: do we need to preserve the backupdir somewhere? */
- frame = glade_xml_get_widget (xml,"main_frame");
+ frame = get_widget (ui,"main_frame");
buf = g_strdup_printf (_("Restoring %s"), pilot_name);
gtk_frame_set_label (GTK_FRAME (frame), buf);
g_free (buf);
- id_entry = glade_xml_get_widget (xml,"pilotid_entry");
+ id_entry = get_widget (ui, "pilotid_entry");
buf = g_strdup_printf ("%d",pilot_id);
gtk_entry_set_text (GTK_ENTRY (id_entry),buf);
@@ -678,25 +698,25 @@ restore_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname)
gnome_pilot_client_get_cradles (applet->gpc,&(applet->properties.cradles));
list = applet->properties.cradles;
- device_menu = glade_xml_get_widget (xml,"device_menu");
- menu =gtk_menu_new ();
-
+ device_combo = get_widget (ui, "device_combo");
+ list_store = gtk_list_store_new (1, G_TYPE_STRING);
+ gtk_combo_box_set_model (GTK_COMBO_BOX (device_combo), GTK_TREE_MODEL (list_store));
+ renderer = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (device_combo), renderer, TRUE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (device_combo), renderer, "text", 0);
+
i=0;
while (list){
- menu_item = gtk_menu_item_new_with_label ((gchar*)list->data);
- gtk_widget_show (menu_item);
-/*
- gtk_signal_connect (GTK_OBJECT (menu_item),"activate",
- GTK_SIGNAL_FUNC (activate_device),
- (gchar*)list->data);
-*/
- gtk_menu_append (GTK_MENU (menu),menu_item);
+ GtkTreeIter iter;
+
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, (gchar*)list->data, -1);
list=list->next;
i++;
}
- gtk_option_menu_set_menu (GTK_OPTION_MENU (device_menu),menu);
- if (i<=1) gtk_widget_set_sensitive (GTK_WIDGET (device_menu),FALSE);
- else gtk_widget_set_sensitive (GTK_WIDGET (device_menu),TRUE);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (device_combo), 0);
+ if (i<=1) gtk_widget_set_sensitive (GTK_WIDGET (device_combo),FALSE);
+ else gtk_widget_set_sensitive (GTK_WIDGET (device_combo),TRUE);
if (gtk_dialog_run (GTK_DIALOG (applet->restoreDialog)) == GTK_RESPONSE_OK) {
int id;
@@ -1108,11 +1128,15 @@ save_properties (PilotApplet *self)
}
static void
-activate_pilot_menu (GtkMenuItem *widget, gpointer data)
+activate_pilot_menu (GtkComboBox *widget, gpointer data)
{
PilotApplet *applet = PILOT_APPLET (data);
- gtk_object_set_data (GTK_OBJECT (applet->chooseDialog),"pilot",
- (gpointer)gtk_menu_item_get_label(widget));
+ gchar *label;
+ GtkTreeIter iter;
+
+ gtk_combo_box_get_active_iter(widget, &iter);
+ gtk_tree_model_get (gtk_combo_box_get_model (widget), &iter, 0, &label, -1);
+ gtk_object_set_data (GTK_OBJECT (applet->chooseDialog), "pilot", (gpointer)label);
}
static gchar*
@@ -1125,31 +1149,44 @@ pick_pilot (PilotApplet *self)
pilot = (gchar*)self->properties.pilot_ids->data;
} else {
GList *tmp;
- GtkWidget *optionMenu,*menuItem,*menu;
+ GtkWidget *combo;
+ GtkListStore *list_store;
+ GtkCellRenderer *renderer;
+
if (self->chooseDialog == NULL) {
- GladeXML * xml;
+ GtkBuilder * ui;
+
+ ui = load_ui (self->ui_file,"ChoosePilot");
+ self->chooseDialog = get_widget (ui,"ChoosePilot");
+ combo = get_widget (ui, "pilot_combo");
+ gtk_object_set_data (GTK_OBJECT (self->chooseDialog),"pilot_combo", combo);
+
- xml = glade_xml_new (self->glade_file,"ChoosePilot",NULL);
- self->chooseDialog = glade_xml_get_widget (xml,"ChoosePilot");
- optionMenu=glade_xml_get_widget (xml,"pilot_menu");
- gtk_object_set_data (GTK_OBJECT (self->chooseDialog),"pilot_menu",optionMenu);
} else {
- optionMenu=gtk_object_get_data (GTK_OBJECT (self->chooseDialog),"pilot_menu");
+ combo = gtk_object_get_data (GTK_OBJECT (self->chooseDialog), "pilot_combo");
}
- menu = gtk_menu_new ();
-
+
+ list_store = gtk_list_store_new (1, G_TYPE_STRING);
+ gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (list_store));
+ gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo));
+ renderer = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", 0);
tmp=self->properties.pilot_ids;
while (tmp!=NULL){
- menuItem = gtk_menu_item_new_with_label ((gchar*)tmp->data);
- gtk_widget_show (menuItem);
- gtk_signal_connect (GTK_OBJECT (menuItem),"activate",
- GTK_SIGNAL_FUNC (activate_pilot_menu),
- self);
- gtk_menu_append (GTK_MENU (menu),menuItem);
+ GtkTreeIter iter;
+
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, (gchar*)tmp->data, -1);
tmp=tmp->next;
}
- gtk_option_menu_set_menu (GTK_OPTION_MENU (optionMenu),menu);
- gtk_option_menu_set_history (GTK_OPTION_MENU (optionMenu),0);
+
+
+ g_signal_connect (G_OBJECT (combo), "changed",
+ G_CALLBACK (activate_pilot_menu),
+ self);
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
gtk_object_set_data (GTK_OBJECT (self->chooseDialog),"pilot",self->properties.pilot_ids->data);
if (gtk_dialog_run(GTK_DIALOG (self->chooseDialog))== 0) {
pilot=(gchar *)gtk_object_get_data (GTK_OBJECT (self->chooseDialog),"pilot");
@@ -1391,17 +1428,15 @@ pilot_applet_fill (PanelApplet *applet)
self->applet = applet;
- /* initialize glade */
- glade_gnome_init ();
- self->glade_file="./pilot-applet.glade";
- if (!g_file_test (self->glade_file, G_FILE_TEST_EXISTS)) {
- self->glade_file = g_build_filename (GLADEDATADIR,
- "pilot-applet.glade",
+ self->ui_file="./pilot-applet.ui";
+ if (!g_file_test (self->ui_file, G_FILE_TEST_EXISTS)) {
+ self->ui_file = g_build_filename (UIDATADIR,
+ "pilot-applet.ui",
NULL);
}
- if (!g_file_test (self->glade_file, G_FILE_TEST_EXISTS)) {
+ if (!g_file_test (self->ui_file, G_FILE_TEST_EXISTS)) {
show_dialog (self, GTK_MESSAGE_ERROR,
- _("Cannot find pilot-applet.glade"));
+ "Cannot find %s", self->ui_file); /* FIXME: Make translatable after string freeze */
return -1;
}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ebadd54..060b8bf 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,7 +1,7 @@
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
applet/GNOME_PilotApplet.server.in.in
-applet/pilot-applet.glade
+[type: gettext/glade]applet/pilot-applet.ui
applet/pilot.c
applet/pilot.schemas.in
capplet/gnome-pilot-capplet.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]