[Xfce4-commits] <xfce4-mailwatch-plugin:master> Use exo icon chooser dialog for icon selection

Ján Sučan noreply at xfce.org
Thu Sep 12 12:18:01 CEST 2013


Updating branch refs/heads/master
         to 5908aa74ca09ae8923b1caa533f9997046d9c64e (commit)
       from f4e901eb256f99585fcfdc0bfbaa1452a4b3e37e (commit)

commit 5908aa74ca09ae8923b1caa533f9997046d9c64e
Author: Ján Sučan <sucan at runbox.com>
Date:   Thu Sep 12 12:14:53 2013 +0200

    Use exo icon chooser dialog for icon selection

 configure.ac.in                 |    1 +
 panel-plugin/Makefile.am        |    4 +++-
 panel-plugin/mailwatch-plugin.c |   28 +++++++++++++++++++++-------
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index d2ad9a6..97a7ecf 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -77,6 +77,7 @@ XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.18.0])
 XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.8.0])
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.8.0])
 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.8.0])
+XDT_CHECK_PACKAGE([EXO], [exo-1], [0.7.2])
 
 dnl Check for gnutls and libgcrypt support
 XDT_CHECK_OPTIONAL_PACKAGE([GNUTLS], [gnutls], [1.2.0], [ssl],
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index 251bdf9..b63c642 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -21,6 +21,7 @@ libmailwatch_plugin_la_CFLAGS = \
 	$(GTHREAD_CFLAGS) \
 	$(LIBXFCE4PANEL_CFLAGS) \
 	$(LIBXFCE4UI_CFLAGS) \
+	$(EXO_CFLAGS) \
 	$(PLATFORM_CFLAGS)
 
 libmailwatch_plugin_la_LDFLAGS = \
@@ -36,7 +37,8 @@ libmailwatch_plugin_la_LIBADD = \
 	$(LIBXFCE4PANEL_LIBS) \
 	$(LIBXFCE4UI_LIBS) \
 	$(GNUTLS_LIBS) \
-	$(LIBGCRYPT_LIBS)
+	$(LIBGCRYPT_LIBS) \
+	$(EXO_LIBS)
 
 #
 # Desktop file
diff --git a/panel-plugin/mailwatch-plugin.c b/panel-plugin/mailwatch-plugin.c
index 1d1c9e1..35beaa8 100644
--- a/panel-plugin/mailwatch-plugin.c
+++ b/panel-plugin/mailwatch-plugin.c
@@ -32,6 +32,7 @@
 #include <libxfce4util/libxfce4util.h>
 #include <libxfce4ui/libxfce4ui.h>
 #include <libxfce4panel/libxfce4panel.h>
+#include <exo/exo.h>
 
 #include "mailwatch.h"
 #include "mailwatch-mailbox.h"
@@ -741,15 +742,28 @@ mailwatch_iconbtn_clicked_cb(GtkWidget *w, XfceMailwatchPlugin *mwp)
     g_return_if_fail(icon_type == ICON_TYPE_NORMAL || icon_type == ICON_TYPE_NEW_MAIL);
     
     toplevel = gtk_widget_get_toplevel(w);
-    chooser = gtk_file_chooser_dialog_new(_("Select Icon"),
-                                          GTK_WINDOW(toplevel),
-                                          GTK_FILE_CHOOSER_ACTION_OPEN,
-                                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                          GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
-                                          NULL);
+    chooser = exo_icon_chooser_dialog_new (_("Select Icon"),
+					   GTK_WINDOW(gtk_widget_get_toplevel(toplevel)),
+					   GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+					   GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+					   NULL);
+    gtk_dialog_set_default_response(GTK_DIALOG(chooser), GTK_RESPONSE_ACCEPT);
+    /* Preselect actually used icon */
+    switch(icon_type) {
+    case ICON_TYPE_NORMAL:
+        exo_icon_chooser_dialog_set_icon (EXO_ICON_CHOOSER_DIALOG (chooser),
+					  exo_str_is_empty (mwp->normal_icon) ? 
+					  DEFAULT_NORMAL_ICON : mwp->normal_icon);
+        break;
+    case ICON_TYPE_NEW_MAIL:
+        exo_icon_chooser_dialog_set_icon (EXO_ICON_CHOOSER_DIALOG (chooser),
+					  exo_str_is_empty (mwp->new_mail_icon) ?
+					  DEFAULT_NEW_MAIL_ICON : mwp->new_mail_icon);
+        break;
+    }
     
     if(gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) {
-        gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
+        gchar *filename = exo_icon_chooser_dialog_get_icon(EXO_ICON_CHOOSER_DIALOG(chooser));
         if(filename) {
             GtkWidget *label, *image, *vbox;
             GdkPixbuf **icon_pix;


More information about the Xfce4-commits mailing list