Index: configure.ac.in =================================================================== --- configure.ac.in (revision 23165) +++ configure.ac.in (working copy) @@ -83,6 +83,12 @@ [startup-notification], [startup notification library], [yes]) +XDT_CHECK_OPTIONAL_PACKAGE([LIBEXO], + [exo-0.3], [0.3.1.10], + [exo], + AC_HELP_STRING([--disable-exo], + [Disable the use of the libexo icon chooser (default=enabled)])) + dnl install dummy scripts? AC_ARG_ENABLE([dummy-scripts], AC_HELP_STRING([--enable-dummy-scripts], Index: plugins/launcher/launcher-dialog.c =================================================================== --- plugins/launcher/launcher-dialog.c (revision 23165) +++ plugins/launcher/launcher-dialog.c (working copy) @@ -31,6 +31,10 @@ #include #include +#ifdef HAVE_LIBEXO +#include +#endif + #include "launcher-dialog.h" @@ -59,12 +63,14 @@ GtkWidget *exec_comment; GtkWidget *icon_button; +#ifndef HAVE_LIBEXO GtkWidget *icon_img; GtkWidget *icon_category; GtkWidget *icon_file_align; GtkWidget *icon_file; GtkWidget *icon_browse; GtkWidget *icon_label; +#endif GtkWidget *exec; GtkWidget *exec_browse; @@ -96,6 +102,7 @@ } ZeroInstallProcess; +#ifndef HAVE_LIBEXO /* Keep in sync with XfceIconTheme */ static const char *category_icons [] = { N_("Default"), @@ -114,6 +121,7 @@ N_("Terminal"), N_("Development") }; +#endif #define NUM_CATEGORIES G_N_ELEMENTS(category_icons) @@ -135,7 +143,7 @@ guint info, guint time, LauncherDialog *ld); - +#ifndef HAVE_LIBEXO static void icon_entry_data_received (GtkWidget *w, GdkDragContext *context, gint x, @@ -144,6 +152,7 @@ guint info, guint time, LauncherDialog *ld); +#endif /* File dialog with preview */ static char *select_file_with_preview (const char *title, @@ -199,8 +208,61 @@ static void update_entry_icon (LauncherDialog *ld) { + GdkPixbuf *pb = NULL; + +#ifdef HAVE_LIBEXO + gchar *icon; + GtkWidget *image; + GtkIconTheme *icon_theme; + GdkPixbuf *icon_scaled; + + /* load current icon */ + icon = ld->entry->icon.icon.name; + + /* drop the previous button child */ + if (GTK_BIN (ld->icon_button)->child != NULL) + gtk_widget_destroy (GTK_BIN (ld->icon_button)->child); + + if (G_LIKELY (icon != NULL && g_path_is_absolute (icon))) + { + /* load the icon from the file */ + pb = exo_gdk_pixbuf_new_from_file_at_max_size (icon, 48, 48, TRUE, NULL); + } + else if (icon != NULL) + { + /* determine the appropriate icon theme */ + if (G_LIKELY (gtk_widget_has_screen (GTK_WIDGET (ld->icon_button)))) + icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (ld->icon_button))); + else + icon_theme = gtk_icon_theme_get_default (); + + /* try to load the named icon */ + pb = gtk_icon_theme_load_icon (icon_theme, icon, 48, 0, NULL); + } + + /* setup the icon button */ + if (G_LIKELY (pb != NULL)) + { + /* scale down the icon if required */ + icon_scaled = exo_gdk_pixbuf_scale_down (pb, TRUE, 48, 48); + g_object_unref (G_OBJECT (pb)); + pb = icon_scaled; + + /* setup an image for the icon */ + image = gtk_image_new_from_pixbuf (pb); + gtk_container_add (GTK_CONTAINER (ld->icon_button), image); + gtk_widget_show (image); + + g_object_unref (G_OBJECT (pb)); + } + else + { + image = gtk_label_new (_("No icon")); + gtk_container_add (GTK_CONTAINER (ld->icon_button), image); + gtk_widget_show (image); + } +#else const char *text; - GdkPixbuf *pb; text = gtk_entry_get_text (GTK_ENTRY (ld->icon_file)); @@ -233,6 +295,7 @@ gtk_image_set_from_pixbuf (GTK_IMAGE (ld->icon_img), pb); g_object_unref (G_OBJECT (pb)); } +#endif gtk_widget_queue_draw (ld->tree); } @@ -278,10 +341,12 @@ { update_entry_info (ld); } +#ifndef HAVE_LIBEXO else if (gentry == ld->icon_file) { update_entry_icon (ld); } +#endif else if (gentry == ld->exec) { update_entry_exec (ld); @@ -312,7 +377,147 @@ launcher_update_panel_entry(ld->launcher); } +/* exec callback */ static void +exec_browse (GtkWidget *b, LauncherDialog *ld) +{ + char *file; + + file = select_file_with_preview (_("Select command"), ld->entry->exec, + ld->dlg, FALSE); + + if (file) + { + gtk_entry_set_text (GTK_ENTRY (ld->exec), file); + gtk_editable_set_position (GTK_EDITABLE (ld->exec), -1); + update_entry_exec (ld); + } + + g_free (file); +} + +#ifdef HAVE_LIBEXO +static void +icon_button_clicked (LauncherDialog *ld); +#endif + +/* info widgets */ +static void +add_entry_info_options(LauncherDialog *ld, GtkBox *box, GtkSizeGroup *sg) +{ + GtkWidget *hbox, *label; + + hbox = gtk_hbox_new (FALSE, BORDER); + gtk_widget_show (hbox); + gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); + + label = gtk_label_new (_("Name")); + gtk_widget_show (label); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + + gtk_size_group_add_widget (sg, label); + + ld->exec_name = gtk_entry_new (); + gtk_widget_show (ld->exec_name); + gtk_box_pack_start (GTK_BOX (hbox), ld->exec_name, TRUE, TRUE, 0); + + g_signal_connect (ld->exec_name, "focus-out-event", + G_CALLBACK (entry_lost_focus), ld); + + hbox = gtk_hbox_new (FALSE, BORDER); + gtk_widget_show (hbox); + gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); + + label = gtk_label_new (_("Description")); + gtk_widget_show (label); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + + gtk_size_group_add_widget (sg, label); + + ld->exec_comment = gtk_entry_new (); + gtk_widget_show (ld->exec_comment); + gtk_box_pack_start (GTK_BOX (hbox), ld->exec_comment, TRUE, TRUE, 0); + gtk_widget_set_size_request (ld->exec_comment, 300, -1); + + g_signal_connect (ld->exec_comment, "focus-out-event", + G_CALLBACK (entry_lost_focus), ld); + +#ifdef HAVE_LIBEXO + /* add the icon chooser button */ + hbox = gtk_hbox_new (FALSE, BORDER); + gtk_widget_show (hbox); + gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); + + label = gtk_label_new (_("Icon")); + gtk_widget_show (label); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + + gtk_size_group_add_widget (sg, label); + + ld->icon_button = gtk_button_new_with_label (_("No icon")); + gtk_box_pack_start (GTK_BOX (hbox), ld->icon_button, FALSE, FALSE, 0); + gtk_widget_show (ld->icon_button); + + g_signal_connect_swapped (G_OBJECT (ld->icon_button), "clicked", + G_CALLBACK (icon_button_clicked), ld); +#endif +} + +/* icon widgets */ +#ifdef HAVE_LIBEXO +static void +icon_button_clicked (LauncherDialog *ld) +{ + const gchar *name; + GtkWidget *chooser; + gchar *title; + gchar *icon; + + /* determine the name of the launcher being edited */ + name = gtk_entry_get_text (GTK_ENTRY (ld->exec_name)); + if (G_UNLIKELY (name == NULL || *name == '\0')) + name = _("Unknown"); + + /* allocate the chooser dialog */ + title = g_strdup_printf (_("Select an Icon for \"%s\""), name); + chooser = exo_icon_chooser_dialog_new (title, NULL, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + gtk_dialog_set_alternative_button_order (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT, GTK_RESPONSE_CANCEL, -1); + gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT); + g_free (title); + + /* setup the currently selected icon */ + icon = ld->entry->icon.icon.name; + if (G_LIKELY (icon != NULL && *icon != '\0')) + exo_icon_chooser_dialog_set_icon (EXO_ICON_CHOOSER_DIALOG (chooser), icon); + + /* run the icon chooser dialog */ + if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT) + { + /* remember the selected icon from the chooser */ + if (G_LIKELY (icon)) + g_free (icon); + + icon = exo_icon_chooser_dialog_get_icon (EXO_ICON_CHOOSER_DIALOG (chooser)); + ld->entry->icon.icon.name = g_strdup (icon); + g_free (icon); + } + + /* destroy the chooser */ + gtk_widget_destroy (chooser); + + /* update button */ + update_entry_icon (ld); +} + + +#else +static void icon_menu_deactivated (GtkWidget *menu, LauncherDialog *ld) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ld->icon_button), FALSE); @@ -450,70 +655,6 @@ } } -/* exec callback */ -static void -exec_browse (GtkWidget *b, LauncherDialog *ld) -{ - char *file; - - file = select_file_with_preview (_("Select command"), ld->entry->exec, - ld->dlg, FALSE); - - if (file) - { - gtk_entry_set_text (GTK_ENTRY (ld->exec), file); - gtk_editable_set_position (GTK_EDITABLE (ld->exec), -1); - update_entry_exec (ld); - } - - g_free (file); -} - -/* info widgets */ -static void -add_entry_info_options(LauncherDialog *ld, GtkBox *box, GtkSizeGroup *sg) -{ - GtkWidget *hbox, *label; - - hbox = gtk_hbox_new (FALSE, BORDER); - gtk_widget_show (hbox); - gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); - - label = gtk_label_new (_("Name")); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - - gtk_size_group_add_widget (sg, label); - - ld->exec_name = gtk_entry_new (); - gtk_widget_show (ld->exec_name); - gtk_box_pack_start (GTK_BOX (hbox), ld->exec_name, TRUE, TRUE, 0); - - g_signal_connect (ld->exec_name, "focus-out-event", - G_CALLBACK (entry_lost_focus), ld); - - hbox = gtk_hbox_new (FALSE, BORDER); - gtk_widget_show (hbox); - gtk_box_pack_start (box, hbox, FALSE, FALSE, 0); - - label = gtk_label_new (_("Description")); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - - gtk_size_group_add_widget (sg, label); - - ld->exec_comment = gtk_entry_new (); - gtk_widget_show (ld->exec_comment); - gtk_box_pack_start (GTK_BOX (hbox), ld->exec_comment, TRUE, TRUE, 0); - gtk_widget_set_size_request (ld->exec_comment, 300, -1); - - g_signal_connect (ld->exec_comment, "focus-out-event", - G_CALLBACK (entry_lost_focus), ld); -} - -/* icon widgets */ static GtkWidget * create_icon_category_menu (LauncherDialog *ld) { @@ -639,6 +780,7 @@ g_signal_connect (ld->icon_browse, "drag-data-received", G_CALLBACK (icon_entry_data_received), ld); } +#endif /* exec widgets */ static void @@ -717,7 +859,9 @@ launcher_dialog_update_entry_properties (LauncherDialog *ld) { char *value; +#ifndef HAVE_LIBEXO GdkPixbuf *pb; +#endif ld->updating = TRUE; @@ -735,7 +879,9 @@ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ld->exec_startup), ld->entry->startup); - +#ifdef HAVE_LIBEXO + update_entry_icon (ld); +#else pb = launcher_icon_load_pixbuf (ld->icon_img, &ld->entry->icon, DLG_ICON_SIZE); gtk_image_set_from_pixbuf (GTK_IMAGE (ld->icon_img), pb); @@ -767,6 +913,7 @@ { gtk_widget_hide (ld->icon_label); } +#endif ld->updating = FALSE; } @@ -774,8 +921,11 @@ static void launcher_dialog_add_entry_properties (LauncherDialog *ld, GtkBox *box) { - GtkWidget *frame, *vbox, *align; + GtkWidget *frame, *vbox; GtkSizeGroup *sg; +#ifndef HAVE_LIBEXO + GtkWidget *align; +#endif frame = gtk_frame_new (NULL); gtk_widget_show (frame); @@ -790,6 +940,7 @@ add_entry_info_options (ld, GTK_BOX (vbox), sg); +#ifndef HAVE_LIBEXO align = gtk_alignment_new (0, 0, 0, 0); gtk_widget_show (align); gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0); @@ -801,6 +952,7 @@ gtk_widget_show (align); gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0); gtk_widget_set_size_request (align, BORDER, BORDER); +#endif add_entry_exec_options (ld, GTK_BOX (vbox), sg); @@ -1305,7 +1457,9 @@ launcher_update_panel_entry (ld->launcher); launcher_recreate_menu (ld->launcher); +#ifndef HAVE_LIBEXO gtk_widget_destroy (ld->icon_category); +#endif gtk_widget_destroy (dlg); xfce_panel_plugin_unblock_menu (ld->plugin); @@ -1713,10 +1867,13 @@ if (e) { +#ifndef HAVE_LIBEXO GdkPixbuf *pb; +#endif gtk_entry_set_text (GTK_ENTRY (ld->exec_name), e->name); gtk_entry_set_text (GTK_ENTRY (ld->exec_comment), e->comment); +#ifndef HAVE_LIBEXO if (e->icon.type == LAUNCHER_ICON_TYPE_NAME) gtk_entry_set_text (GTK_ENTRY (ld->icon_file), e->icon.icon.name); @@ -1730,6 +1887,7 @@ DLG_ICON_SIZE); gtk_image_set_from_pixbuf (GTK_IMAGE (ld->icon_img), pb); g_object_unref (G_OBJECT (pb)); +#endif } } @@ -1776,6 +1934,7 @@ g_ptr_array_free (files, TRUE); } +#ifndef HAVE_LIBEXO static void icon_entry_data_received (GtkWidget *w, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, @@ -1807,6 +1966,7 @@ gtk_entry_set_text (GTK_ENTRY (ld->icon_file), file); gtk_editable_set_position (GTK_EDITABLE (ld->icon_file), -1); + update_entry_icon (ld); pb = launcher_icon_load_pixbuf (ld->icon_img, &ld->entry->icon, @@ -1824,6 +1984,7 @@ g_ptr_array_free (files, TRUE); } +#endif /* File open dialog * ---------------- Index: plugins/launcher/launcher.c =================================================================== --- plugins/launcher/launcher.c (revision 23165) +++ plugins/launcher/launcher.c (working copy) @@ -1299,6 +1299,9 @@ entry->name = g_strdup (_("New Item")); entry->comment = g_strdup (_("This item has not yet been configured")); +#ifdef HAVE_LIBEXO + entry->icon.type = LAUNCHER_ICON_TYPE_NAME; +#endif g_ptr_array_add (launcher->entries, entry); Index: plugins/launcher/Makefile.am =================================================================== --- plugins/launcher/Makefile.am (revision 23165) +++ plugins/launcher/Makefile.am (working copy) @@ -15,10 +15,13 @@ liblauncher_la_CFLAGS = \ -I$(top_srcdir) \ @LIBXFCEGUI4_CFLAGS@ \ - -DLOCALEDIR=\"$(localedir)\" + -DLOCALEDIR=\"$(localedir)\" \ + -DEXO_API_SUBJECT_TO_CHANGE \ + @LIBEXO_CFLAGS@ liblauncher_la_LIBADD = \ ../../libxfce4panel/libxfce4panel.la \ + @LIBEXO_LIBS@ \ @LIBS@ liblauncher_la_DEPENDENCIES = \