[Xfce4-commits] <xfce4-panel:devel> Merge branch 'devel' of ssh://git.xfce.org/git/xfce/xfce4-panel into devel

Nick Schermer noreply at xfce.org
Sun Feb 14 23:06:02 CET 2010


Updating branch refs/heads/devel
         to 6ba92f016a5a153eff77a64bf5ef40b6db7d39c8 (commit)
       from 0c85cba58320eecd4c326c0249792fc189b73743 (commit)

commit 6ba92f016a5a153eff77a64bf5ef40b6db7d39c8
Merge: 0c85cba58320eecd4c326c0249792fc189b73743 3ce58e96dc532e113a4803ff0c9b3ffe0fd83759
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Feb 2 22:58:58 2010 +0100

    Merge branch 'devel' of ssh://git.xfce.org/git/xfce/xfce4-panel into devel

commit 3ce58e96dc532e113a4803ff0c9b3ffe0fd83759
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Feb 2 21:10:55 2010 +0100

    Hidden prop for clock command on double-click (bug #6098).

commit 1f9e6920d225584e96364ec26430463c0dade862
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Feb 2 20:53:49 2010 +0100

    Add tooltip to the custom clock format (bug #5282).

commit 3ff9bdee67c63a335cb7c0067c47911cede6b421
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Feb 2 20:31:55 2010 +0100

    Also watch widget::destroy in xfce_panel_plugin_register_menu().
    
    This should prevent bugs where menus are destroyed and
    don't emit the deactivate signal, which prevents the panel
    from hiding again.

commit 0cdd86a4e1db680e766e7b6e1a387a4553e8b5c4
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Feb 2 20:13:13 2010 +0100

    Force a pager rebuild on screen changes (bug #3328).

commit fa6bf45b08be59f1d0acc97676aa9f86a5ced2e8
Author: Nick Schermer <nick at xfce.org>
Date:   Mon Feb 1 20:21:35 2010 +0100

    Gracefully handle invalid sizes.

 libxfce4panel/xfce-panel-image.c  |    6 +++-
 libxfce4panel/xfce-panel-plugin.c |   10 ++++---
 plugins/clock/clock-dialog.glade  |    2 +
 plugins/clock/clock.c             |   54 ++++++++++++++++++++++++++++++++++--
 plugins/pager/pager.c             |   53 ++++++++++++++++++++++++++----------
 5 files changed, 101 insertions(+), 24 deletions(-)

diff --git a/libxfce4panel/xfce-panel-image.c b/libxfce4panel/xfce-panel-image.c
index 2d5817c..44c8716 100644
--- a/libxfce4panel/xfce-panel-image.c
+++ b/libxfce4panel/xfce-panel-image.c
@@ -448,8 +448,10 @@ xfce_panel_image_scale_pixbuf (GdkPixbuf *source,
   gint    source_height;
 
   panel_return_val_if_fail (GDK_IS_PIXBUF (source), NULL);
-  panel_return_val_if_fail (dest_width > 0, NULL);
-  panel_return_val_if_fail (dest_height > 0, NULL);
+
+  /* we fail on invalid sizes */
+  if (G_UNLIKELY (dest_width <= 0 || dest_height <= 0))
+    return NULL;
 
   source_width = gdk_pixbuf_get_width (source);
   source_height = gdk_pixbuf_get_height (source);
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index a27da25..a9c509e 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -1086,12 +1086,12 @@ xfce_panel_plugin_unregister_menu (GtkMenu         *menu,
   panel_return_if_fail (plugin->priv->panel_lock > 0);
   panel_return_if_fail (GTK_IS_MENU (menu));
 
+  /* disconnect this signal */
+  g_signal_handlers_disconnect_by_func (G_OBJECT (menu),
+      G_CALLBACK (xfce_panel_plugin_unregister_menu), plugin);
+
   if (G_LIKELY (plugin->priv->panel_lock > 0))
     {
-      /* disconnect this signal */
-      g_signal_handlers_disconnect_by_func (G_OBJECT (menu),
-          G_CALLBACK (xfce_panel_plugin_unregister_menu), plugin);
-
       /* decrease the counter */
       plugin->priv->panel_lock--;
 
@@ -1833,6 +1833,8 @@ xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin,
   /* connect signal to menu to decrease counter */
   g_signal_connect (G_OBJECT (menu), "deactivate",
       G_CALLBACK (xfce_panel_plugin_unregister_menu), plugin);
+  g_signal_connect (G_OBJECT (menu), "destroy",
+      G_CALLBACK (xfce_panel_plugin_unregister_menu), plugin);
 
   /* tell panel it needs to lock */
   if (plugin->priv->panel_lock == 1)
diff --git a/plugins/clock/clock-dialog.glade b/plugins/clock/clock-dialog.glade
index a81b4d9..d292780 100644
--- a/plugins/clock/clock-dialog.glade
+++ b/plugins/clock/clock-dialog.glade
@@ -114,6 +114,7 @@
                           <object class="GtkEntry" id="tooltip-format">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
+                            <property name="tooltip_text" translatable="yes">The format describes the date and time parts to insert into the file name. For example, %Y will be substituted with the year, %m with the month and %d with the day. See the documentation of the date utility for additional information.</property>
                             <property name="invisible_char">&#x2022;</property>
                           </object>
                           <packing>
@@ -262,6 +263,7 @@
                               <object class="GtkEntry" id="digital-format">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
+                                <property name="tooltip_text" translatable="yes">The format describes the date and time parts to insert into the file name. For example, %Y will be substituted with the year, %m with the month and %d with the day. See the documentation of the date utility for additional information.</property>
                                 <property name="invisible_char">&#x2022;</property>
                               </object>
                               <packing>
diff --git a/plugins/clock/clock.c b/plugins/clock/clock.c
index 732333c..1afcbd4 100644
--- a/plugins/clock/clock.c
+++ b/plugins/clock/clock.c
@@ -56,6 +56,8 @@ static gboolean clock_plugin_leave_notify_event        (GtkWidget             *w
                                                         GdkEventCrossing      *event);
 static gboolean clock_plugin_enter_notify_event        (GtkWidget             *widget,
                                                         GdkEventCrossing      *event);
+static gboolean clock_plugin_button_press_event        (GtkWidget             *widget,
+                                                        GdkEventButton        *event);
 static void     clock_plugin_construct                 (XfcePanelPlugin       *panel_plugin);
 static void     clock_plugin_free_data                 (XfcePanelPlugin       *panel_plugin);
 static gboolean clock_plugin_size_changed              (XfcePanelPlugin       *panel_plugin,
@@ -63,7 +65,6 @@ static gboolean clock_plugin_size_changed              (XfcePanelPlugin       *p
 static void     clock_plugin_orientation_changed       (XfcePanelPlugin       *panel_plugin,
                                                         GtkOrientation         orientation);
 static void     clock_plugin_configure_plugin          (XfcePanelPlugin       *panel_plugin);
-
 static void     clock_plugin_set_mode                  (ClockPlugin           *plugin);
 static gboolean clock_plugin_tooltip                   (gpointer               user_data);
 static gboolean clock_plugin_timeout_running           (gpointer               user_data);
@@ -77,7 +78,8 @@ enum
   PROP_0,
   PROP_MODE,
   PROP_SHOW_FRAME,
-  PROP_TOOLTIP_FORMAT
+  PROP_TOOLTIP_FORMAT,
+  PROP_COMMAND
 };
 
 typedef enum
@@ -108,7 +110,7 @@ struct _ClockPlugin
   GtkWidget          *frame;
 
   guint               show_frame : 1;
-
+  gchar              *command;
   ClockPluginMode     mode;
 
   gchar              *tooltip_format;
@@ -182,6 +184,7 @@ clock_plugin_class_init (ClockPluginClass *klass)
   widget_class = GTK_WIDGET_CLASS (klass);
   widget_class->leave_notify_event = clock_plugin_leave_notify_event;
   widget_class->enter_notify_event = clock_plugin_enter_notify_event;
+  widget_class->button_press_event = clock_plugin_button_press_event;
 
   plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
   plugin_class->construct = clock_plugin_construct;
@@ -212,6 +215,12 @@ clock_plugin_class_init (ClockPluginClass *klass)
                                                         NULL, NULL,
                                                         DEFAULT_TOOLTIP_FORMAT,
                                                         EXO_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_COMMAND,
+                                   g_param_spec_string ("command",
+                                                        NULL, NULL, NULL,
+                                                        EXO_PARAM_READWRITE));
 }
 
 
@@ -224,6 +233,7 @@ clock_plugin_init (ClockPlugin *plugin)
   plugin->show_frame = TRUE;
   plugin->tooltip_format = g_strdup (DEFAULT_TOOLTIP_FORMAT);
   plugin->tooltip_timeout = NULL;
+  plugin->command = NULL;
 
   plugin->frame = gtk_frame_new (NULL);
   gtk_container_add (GTK_CONTAINER (plugin), plugin->frame);
@@ -255,6 +265,10 @@ clock_plugin_get_property (GObject    *object,
       g_value_set_string (value, plugin->tooltip_format);
       break;
 
+    case PROP_COMMAND:
+      g_value_set_string (value, plugin->command);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -297,6 +311,11 @@ clock_plugin_set_property (GObject      *object,
       plugin->tooltip_format = g_value_dup_string (value);
       break;
 
+    case PROP_COMMAND:
+      g_free (plugin->command);
+      plugin->command = g_value_dup_string (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -342,6 +361,33 @@ clock_plugin_enter_notify_event (GtkWidget        *widget,
 
 
 
+static gboolean
+clock_plugin_button_press_event (GtkWidget      *widget,
+                                 GdkEventButton *event)
+{
+  ClockPlugin *plugin = XFCE_CLOCK_PLUGIN (widget);
+  GError      *error = NULL;
+
+  if (event->button == 1
+      && event->type == GDK_2BUTTON_PRESS
+      && !exo_str_is_empty (plugin->command))
+    {
+      /* launch command */
+      if (!gdk_spawn_command_line_on_screen (gtk_widget_get_screen (widget),
+                                             plugin->command, &error))
+        {
+          xfce_dialog_show_error (NULL, error, _("Failed to execute clock command"));
+          g_error_free (error);
+        }
+
+      return TRUE;
+    }
+
+  return (*GTK_WIDGET_CLASS (clock_plugin_parent_class)->button_press_event) (widget, event);
+}
+
+
+
 static void
 clock_plugin_construct (XfcePanelPlugin *panel_plugin)
 {
@@ -351,6 +397,7 @@ clock_plugin_construct (XfcePanelPlugin *panel_plugin)
     { "mode", G_TYPE_UINT },
     { "show-frame", G_TYPE_BOOLEAN },
     { "tooltip-format", G_TYPE_STRING },
+    { "command", G_TYPE_STRING },
     { NULL }
   };
 
@@ -378,6 +425,7 @@ clock_plugin_free_data (XfcePanelPlugin *panel_plugin)
     clock_plugin_timeout_free (plugin->tooltip_timeout);
 
   g_free (plugin->tooltip_format);
+  g_free (plugin->command);
 }
 
 
diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c
index c3c6f59..d3d7af4 100644
--- a/plugins/pager/pager.c
+++ b/plugins/pager/pager.c
@@ -266,6 +266,36 @@ pager_plugin_scroll_event (GtkWidget      *widget,
 
 
 static void
+pager_plugin_screen_layout_changed (PagerPlugin *plugin)
+{
+  panel_return_if_fail (XFCE_IS_PAGER_PLUGIN (plugin));
+  panel_return_if_fail (WNCK_IS_SCREEN (plugin->wnck_screen));
+
+  if (G_UNLIKELY (plugin->wnck_pager != NULL))
+    {
+      /* destroy the existing pager */
+      gtk_widget_destroy (GTK_WIDGET (plugin->wnck_pager));
+
+      /* force a screen update */
+      wnck_screen_force_update (plugin->wnck_screen);
+    }
+
+  /* create the wnck pager */
+  plugin->wnck_pager = wnck_pager_new (plugin->wnck_screen);
+  gtk_container_add (GTK_CONTAINER (plugin), plugin->wnck_pager);
+  gtk_widget_show (plugin->wnck_pager);
+
+  /* set the pager properties */
+  wnck_pager_set_display_mode (WNCK_PAGER (plugin->wnck_pager),
+                               plugin->show_names ?
+                                   WNCK_PAGER_DISPLAY_NAME :
+                                   WNCK_PAGER_DISPLAY_CONTENT);
+  wnck_pager_set_n_rows (WNCK_PAGER (plugin->wnck_pager), plugin->rows);
+}
+
+
+
+static void
 pager_plugin_screen_changed (GtkWidget *widget,
                              GdkScreen *previous_screen)
 {
@@ -280,24 +310,17 @@ pager_plugin_screen_changed (GtkWidget *widget,
   /* only update if the screen changed */
   if (plugin->wnck_screen != wnck_screen)
     {
-      /* destroy the existing pager */
-      if (G_UNLIKELY (plugin->wnck_pager != NULL))
-        gtk_widget_destroy (GTK_WIDGET (plugin->wnck_pager));
-
       /* set the new screen */
       plugin->wnck_screen = wnck_screen;
 
-      /* create the wnck pager */
-      plugin->wnck_pager = wnck_pager_new (wnck_screen);
-      gtk_container_add (GTK_CONTAINER (widget), plugin->wnck_pager);
-      gtk_widget_show (plugin->wnck_pager);
-
-      /* set the pager properties */
-      wnck_pager_set_display_mode (WNCK_PAGER (plugin->wnck_pager),
-                                   plugin->show_names ?
-                                       WNCK_PAGER_DISPLAY_NAME :
-                                       WNCK_PAGER_DISPLAY_CONTENT);
-      wnck_pager_set_n_rows (WNCK_PAGER (plugin->wnck_pager), plugin->rows);
+      /* rebuild the pager */
+      pager_plugin_screen_layout_changed (plugin);
+
+      /* watch the screen for changes */
+      g_signal_connect_swapped (G_OBJECT (screen), "monitors-changed",
+         G_CALLBACK (pager_plugin_screen_layout_changed), plugin);
+      g_signal_connect_swapped (G_OBJECT (screen), "size-changed",
+         G_CALLBACK (pager_plugin_screen_layout_changed), plugin);
     }
 }
 



More information about the Xfce4-commits mailing list