[Pommed-commits] [SCM] pommed - hotkeys handler for Apple laptops branch, master, updated. 1.32-8-gf51c990

Julien BLACHE jb at jblache.org
Wed Jun 23 19:45:56 UTC 2010


The following commit has been merged in the master branch:
commit f51c990b96529fbbc24f360c67f3b90d5bd6611a
Author: Julien BLACHE <jb at jblache.org>
Date:   Wed Jun 23 21:22:24 2010 +0200

    Switch from Glade to hardcoded GTK+ code
    
    Glade is being phased out, and the GUI is simple enough to be
    hardcoded.

diff --git a/INSTALL b/INSTALL
index 63d39c5..6e83073 100644
--- a/INSTALL
+++ b/INSTALL
@@ -23,7 +23,6 @@ gpomme requires:
  - libdbus
  - libdbus-glib
  - GTK+ 2.0
- - glade 2.0
 
 wmpomme requires:
  - X11 libs
@@ -64,7 +63,6 @@ To install gpomme:
  - install gpomme/themes as /usr/share/gpomme/themes
  - install gpomme/po/$lang.mo as /usr/share/locale/$lang/LC_MESSAGES/gpomme.mo
  - copy gpomme/gpomme*.desktop to /usr/share/applications
- - copy gpomme/gpomme.glade to /usr/share/gpomme
 
 Icons for gpomme are available in the icons/ directory. For the .desktop files
 provided with gpomme to work, the icons should be installed under
diff --git a/gpomme/Makefile b/gpomme/Makefile
index 438d152..42c51dd 100644
--- a/gpomme/Makefile
+++ b/gpomme/Makefile
@@ -3,9 +3,6 @@ CC = gcc
 GTK_CFLAGS = $(shell pkg-config --cflags gtk+-2.0)
 GTK_LIBS = $(shell pkg-config --libs gtk+-2.0)
 
-GLADE_CFLAGS = $(shell pkg-config --cflags libglade-2.0)
-GLADE_LIBS = $(shell pkg-config --libs libglade-2.0)
-
 DBUS_CFLAGS = $(shell pkg-config dbus-1 --cflags) -DDBUS_API_SUBJECT_TO_CHANGE
 DBUS_LIBS = $(shell pkg-config dbus-1 --libs)
 
@@ -17,8 +14,8 @@ CONFUSE_LIBS = $(shell pkg-config libconfuse --libs)
 
 INOTIFY_CFLAGS = $(shell test -e /usr/include/sys/inotify.h || echo -DNO_SYS_INOTIFY_H)
 
-CFLAGS = -g -O2 -Wall $(DBUS_CFLAGS) $(DBUSGLIB_CFLAGS) $(GTK_CFLAGS) $(CONFUSE_CFLAGS) $(GLADE_CFLAGS) $(INOTIFY_CFLAGS)
-LDFLAGS = -lpthread -lX11 $(DBUS_LIBS) $(DBUSGLIB_LIBS) $(GTK_LIBS) $(CONFUSE_LIBS) $(GLADE_LIBS)
+CFLAGS = -g -O2 -Wall $(DBUS_CFLAGS) $(DBUSGLIB_CFLAGS) $(GTK_CFLAGS) $(CONFUSE_CFLAGS) $(INOTIFY_CFLAGS)
+LDFLAGS = -lpthread -lX11 $(DBUS_LIBS) $(DBUSGLIB_LIBS) $(GTK_LIBS) $(CONFUSE_LIBS)
 
 SOURCES = gpomme.c theme.c conffile.c \
 		../client-common/dbus-client.c \
diff --git a/gpomme/conffile.c b/gpomme/conffile.c
index 052caeb..aca25e9 100644
--- a/gpomme/conffile.c
+++ b/gpomme/conffile.c
@@ -45,12 +45,10 @@
 #include "theme.h"
 
 #include <gtk/gtk.h>
-#include <glade/glade.h>
 
 
 #define _(str) gettext(str)
 
-#define GLADE_FILE  "/usr/share/gpomme/gpomme.glade" // FIXME: check for path
 #define CONFFILE    "/.gpommerc"
 
 
@@ -61,14 +59,18 @@ static cfg_opt_t cfg_opts[] =
     CFG_END()
   };
 
-GladeXML *gxml;     
 GtkWidget *app_window; 
+GtkWidget *cb_theme;
+GtkWidget *hs_timeout;
 
 void
-on_gpomme_window_close_cb (GtkWidget *widget, gpointer user_data);
+on_gpomme_response_cb(GtkWidget *widget, gint response_id, gpointer user_data);
 
 void
-update_gui_config (void);
+on_gpomme_window_close_cb(GtkWidget *widget, gpointer user_data);
+
+void
+update_gui_config(GtkWidget *widget, gpointer user_data);
 
 
 cfg_t *cfg = NULL;
@@ -269,40 +271,72 @@ config_monitor(void)
 void 
 config_gui(void)
 {
-  GtkWidget *cb_theme;
-  GtkWidget *hs_timeout;
-  struct dirent **namelist; 
+  GtkWidget *content;
+  GtkWidget *vbox;
+  GtkWidget *hbox;
+  GtkWidget *label;
+  GtkWidget *img;
+
+  struct dirent **namelist;
+  const char *cur_theme;
   int n; 
 
-  glade_init();
+  app_window = gtk_dialog_new_with_buttons(_("gpomme preferences"), NULL, 0,
+					   GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT,
+					   NULL);
+
+  gtk_window_set_default_size(GTK_WINDOW(app_window), 400, 240);
+  gtk_window_set_resizable(GTK_WINDOW(app_window), TRUE);
+
+  content = gtk_dialog_get_content_area(GTK_DIALOG(app_window));
+  gtk_box_set_spacing(GTK_BOX(content), 10);
+
+  /* Theme */
+  vbox = gtk_vbox_new(FALSE, 10);
+
+  label = gtk_label_new(_("Theme:"));
+  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 1.0);
+  gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
 
-  /* initialize glade and the window */
-  gxml = glade_xml_new(GLADE_FILE, NULL, NULL);
-  app_window = glade_xml_get_widget(gxml, "gpomme_window");
+  hbox = gtk_hbox_new(FALSE, 10);
 
-  /* setting the strings (for translation) */
-  gtk_window_set_title(GTK_WINDOW(app_window), _("gpomme preferences"));
+  img = gtk_image_new_from_icon_name("gnome-settings-theme", GTK_ICON_SIZE_DIALOG);
+  gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, TRUE, 0);
 
-  GtkWidget *s;
-  s = glade_xml_get_widget(gxml, "lb_theme");
-  gtk_label_set_text(GTK_LABEL(s), _("Theme:"));
+  cb_theme = gtk_combo_box_new_text();
+  gtk_box_pack_start(GTK_BOX(hbox), cb_theme, TRUE, TRUE, 10);
 
-  s = glade_xml_get_widget(gxml, "lb_timeout");
-  gtk_label_set_text(GTK_LABEL(s), _("Timeout (seconds):"));
+  gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
 
-  /* set the default settings */
-  hs_timeout = glade_xml_get_widget(gxml, "hs_timeout");
+  gtk_box_pack_start(GTK_BOX(content), vbox, FALSE, TRUE, 10);
+
+  /* Timeout */
+  vbox = gtk_vbox_new(FALSE, 10);
+
+  label = gtk_label_new(_("Timeout (seconds):"));
+  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 1.0);
+  gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
+
+  hbox = gtk_hbox_new(FALSE, 10);
+
+  img = gtk_image_new_from_icon_name("appointment", GTK_ICON_SIZE_DIALOG);
+  gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, TRUE, 0);
+
+  hs_timeout = gtk_hscale_new_with_range(0.0, 5.0, 0.1);
   gtk_range_set_value(GTK_RANGE(hs_timeout), (gdouble)cfg_getint(cfg, "timeout") / 1000.0);
+  gtk_box_pack_start(GTK_BOX(hbox), hs_timeout, TRUE, TRUE, 10);
+
+  gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
 
-  /* TODO: check for theme-previews */
-  cb_theme = glade_xml_get_widget(gxml, "cb_theme");
-  gtk_combo_box_remove_text(GTK_COMBO_BOX(cb_theme), 0); /* remove dummy-text */
+  gtk_box_pack_start(GTK_BOX(content), vbox, FALSE, TRUE, 10);
 
-  gtk_combo_box_append_text(GTK_COMBO_BOX(cb_theme), cfg_getstr(cfg, "theme"));
+  /* Populate combo box */
+  cur_theme = cfg_getstr(cfg, "theme");
+
+  gtk_combo_box_append_text(GTK_COMBO_BOX(cb_theme), cur_theme);
   gtk_combo_box_set_active(GTK_COMBO_BOX(cb_theme), 0);
 
   n = scandir(THEME_BASE, &namelist, 0, alphasort); 
-
   if (n < 0)
     {
       fprintf(stderr, "Could not open theme directory: %s\n", strerror(errno));
@@ -310,10 +344,10 @@ config_gui(void)
       exit(1);
     }
 
-  while(n--)
+  while (n--)
     {
-      if (strcmp(namelist[n]->d_name, cfg_getstr(cfg, "theme"))
-	  && (namelist[n]->d_name[0] != '.'))
+      if ((namelist[n]->d_name[0] != '.')
+	  && (strcmp(namelist[n]->d_name, cur_theme) != 0))
 	{
 	  /* printf("%s\n", namelist[n]->d_name); */
 	  gtk_combo_box_append_text(GTK_COMBO_BOX(cb_theme), namelist[n]->d_name); 
@@ -321,52 +355,42 @@ config_gui(void)
     }
 
   /* signals... */
-  glade_xml_signal_connect(gxml, "on_bt_close_clicked",         
-			   G_CALLBACK(on_gpomme_window_close_cb));
-
-  glade_xml_signal_connect(gxml, "on_gpomme_window_close",         
-			   G_CALLBACK(on_gpomme_window_close_cb));
+  g_signal_connect(app_window, "response", G_CALLBACK(on_gpomme_response_cb), NULL);
+  g_signal_connect(app_window, "close", G_CALLBACK(on_gpomme_window_close_cb), NULL);
 
-  glade_xml_signal_connect(gxml, "on_gpomme_window_destroy",         
-			   G_CALLBACK(on_gpomme_window_close_cb));
+  g_signal_connect(hs_timeout, "value-changed", G_CALLBACK(update_gui_config), NULL);
+  g_signal_connect(cb_theme, "changed", G_CALLBACK(update_gui_config), NULL);
 
-  glade_xml_signal_connect(gxml, "on_hs_timeout_value_changed",         
-			   G_CALLBACK(update_gui_config));
-
-  glade_xml_signal_connect(gxml, "on_cb_theme_changed",         
-			   G_CALLBACK(update_gui_config));
-
-  gtk_widget_show(app_window);
+  gtk_widget_show_all(app_window);
 
   gtk_main();
 }
 
+void
+on_gpomme_response_cb(GtkWidget *widget, gint response_id, gpointer user_data)
+{
+  on_gpomme_window_close_cb(widget, user_data);
+}
+
 /* window is closed, so write the settings to the config-file */
 void
 on_gpomme_window_close_cb (GtkWidget *widget, gpointer user_data)
 {
-  update_gui_config();
+  update_gui_config(widget, user_data);
   
   gtk_widget_hide(app_window);
   gtk_main_quit();
 }
 
 void
-update_gui_config(void)
+update_gui_config(GtkWidget *widget, gpointer user_data)
 {
-  GtkWidget *cb_themes;
-  GtkWidget *hs_timeout;
-
-  /* get the actual settings */
-  hs_timeout = glade_xml_get_widget(gxml, "hs_timeout");
-  cb_themes = glade_xml_get_widget(gxml, "cb_theme");
-
   gdouble timeout = gtk_range_get_value(GTK_RANGE(hs_timeout)) * 1000.0;
   //g_print("setting timeout to %gs\n", timeout);
   cfg_setint(cfg, "timeout", timeout);
 
-  //g_print("setting theme to %s\n", gtk_combo_box_get_active_text(GTK_COMBO_BOX(cb_themes)));
-  cfg_setstr(cfg, "theme", gtk_combo_box_get_active_text(GTK_COMBO_BOX(cb_themes)));
+  //g_print("setting theme to %s\n", gtk_combo_box_get_active_text(GTK_COMBO_BOX(cb_theme)));
+  cfg_setstr(cfg, "theme", gtk_combo_box_get_active_text(GTK_COMBO_BOX(cb_theme)));
 
   /* actually write them */
   config_write();
diff --git a/gpomme/gpomme.glade b/gpomme/gpomme.glade
deleted file mode 100644
index 5d4918a..0000000
--- a/gpomme/gpomme.glade
+++ /dev/null
@@ -1,160 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.1.5 on Wed Mar  7 18:24:41 2007 by dgsiegel at gmail.com-->
-<glade-interface>
-  <widget class="GtkDialog" id="gpomme_window">
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">gpomme Configuration</property>
-    <property name="resizable">False</property>
-    <property name="window_position">GTK_WIN_POS_MOUSE</property>
-    <property name="destroy_with_parent">True</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_UTILITY</property>
-    <property name="urgency_hint">True</property>
-    <property name="has_separator">False</property>
-    <signal name="close" handler="on_gpomme_window_close"/>
-    <signal name="destroy" handler="on_gpomme_window_destroy"/>
-    <child internal-child="vbox">
-      <widget class="GtkVBox" id="dialog-vbox2">
-        <property name="width_request">390</property>
-        <property name="visible">True</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <child>
-          <widget class="GtkVBox" id="vbox1">
-            <property name="visible">True</property>
-            <property name="spacing">13</property>
-            <child>
-              <widget class="GtkVBox" id="vbox2">
-                <property name="visible">True</property>
-                <child>
-                  <widget class="GtkLabel" id="lb_theme">
-                    <property name="visible">True</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">&lt;b&gt;Theme:&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
-                  </widget>
-                </child>
-                <child>
-                  <widget class="GtkHBox" id="hbox1">
-                    <property name="visible">True</property>
-                    <property name="spacing">10</property>
-                    <child>
-                      <widget class="GtkImage" id="image1">
-                        <property name="visible">True</property>
-                        <property name="icon_size">6</property>
-                        <property name="icon_name">gnome-settings-theme</property>
-                      </widget>
-                      <packing>
-                        <property name="expand">False</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <widget class="GtkAlignment" id="alignment1">
-                        <property name="visible">True</property>
-                        <property name="yscale">0</property>
-                        <child>
-                          <widget class="GtkComboBox" id="cb_theme">
-                            <property name="visible">True</property>
-                            <property name="tooltip" translatable="yes">Set the theme of gpomme</property>
-                            <property name="items" translatable="yes">&lt;item1&gt;</property>
-                            <signal name="changed" handler="on_cb_theme_changed"/>
-                          </widget>
-                        </child>
-                      </widget>
-                      <packing>
-                        <property name="padding">10</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                  </widget>
-                  <packing>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </widget>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="padding">1</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkVBox" id="vbox3">
-                <property name="visible">True</property>
-                <child>
-                  <widget class="GtkLabel" id="lb_timeout">
-                    <property name="visible">True</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes">&lt;b&gt;Timeout (in seconds):&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
-                  </widget>
-                </child>
-                <child>
-                  <widget class="GtkHBox" id="hbox2">
-                    <property name="visible">True</property>
-                    <property name="spacing">10</property>
-                    <child>
-                      <widget class="GtkImage" id="image2">
-                        <property name="visible">True</property>
-                        <property name="icon_size">6</property>
-                        <property name="icon_name">appointment</property>
-                      </widget>
-                      <packing>
-                        <property name="expand">False</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <widget class="GtkHScale" id="hs_timeout">
-                        <property name="visible">True</property>
-                        <property name="adjustment">0 0 5 0.10000000000000001 0.10000000000000001 0</property>
-                        <property name="value_pos">GTK_POS_LEFT</property>
-                        <signal name="value_changed" handler="on_hs_timeout_value_changed"/>
-                      </widget>
-                      <packing>
-                        <property name="padding">10</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                  </widget>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="padding">1</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </widget>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="expand">False</property>
-            <property name="padding">10</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <widget class="GtkHButtonBox" id="dialog-action_area2">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
-            <child>
-              <widget class="GtkButton" id="bt_close">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">gtk-close</property>
-                <property name="use_stock">True</property>
-                <signal name="clicked" handler="on_bt_close_clicked"/>
-              </widget>
-            </child>
-          </widget>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
-          </packing>
-        </child>
-      </widget>
-    </child>
-  </widget>
-</glade-interface>

-- 
pommed - hotkeys handler for Apple laptops



More information about the Pommed-commits mailing list