[Goodies-commits] r7216 - in xfce4-screenshooter/trunk: . lib panel-plugin

Jerome Guelfucci jeromeg at xfce.org
Thu Apr 16 13:21:01 CEST 2009


Author: jeromeg
Date: 2009-04-16 11:21:00 +0000 (Thu, 16 Apr 2009)
New Revision: 7216

Modified:
   xfce4-screenshooter/trunk/ChangeLog
   xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c
   xfce4-screenshooter/trunk/lib/screenshooter-utils.c
   xfce4-screenshooter/trunk/panel-plugin/screenshooter-plugin.c
Log:
	* panel-plugin/screenshooter-plugin.c:
	  - remove the wrong XFCE_PANEL_PLUGIN_REGISTER_INTERNAL macro call,
	    the plugin is external.
	  - add (set_panel_button_tooltip) to simplify the code, this function
	    sets the tooltip according to the area to be captured.
	  - use g_spawn_command_line_async to laucnh the help window.
	  - improve the indentation in some places.
	* lib/screenshooter-utils.c:
	  - improve the indentation in some places.
	  - (screenshooter_open_screenshot):
	    + declare the variables at the beginning of the code block.
            + use g_spawn_command_line_async to launch the applications.
	* lib/screenshooter-dialogs.c: improve the indentation.


Modified: xfce4-screenshooter/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter/trunk/ChangeLog	2009-04-16 09:34:41 UTC (rev 7215)
+++ xfce4-screenshooter/trunk/ChangeLog	2009-04-16 11:21:00 UTC (rev 7216)
@@ -1,3 +1,19 @@
+2009-04-16 jeromeg
+
+	* panel-plugin/screenshooter-plugin.c:
+	  - remove the wrong XFCE_PANEL_PLUGIN_REGISTER_INTERNAL macro call,
+	    the plugin is external.
+	  - add (set_panel_button_tooltip) to simplify the code, this function
+	    sets the tooltip according to the area to be captured.
+	  - use g_spawn_command_line_async to laucnh the help window.
+	  - improve the indentation in some places.
+	* lib/screenshooter-utils.c:
+	  - improve the indentation in some places.
+	  - (screenshooter_open_screenshot):
+	    + declare the variables at the beginning of the code block.
+            + use g_spawn_command_line_async to launch the applications.
+	* lib/screenshooter-dialogs.c: improve the indentation.
+
 2009-04-12 jeromeg
 
 	* src/main.c:

Modified: xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c	2009-04-16 09:34:41 UTC (rev 7215)
+++ xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c	2009-04-16 11:21:00 UTC (rev 7216)
@@ -694,8 +694,7 @@
 /* Build the preferences dialog.
 @sd: a ScreenshotData to set the options.
 */
-GtkWidget *screenshooter_dialog_new (ScreenshotData  *sd, 
-                                     gboolean plugin)
+GtkWidget *screenshooter_dialog_new (ScreenshotData  *sd, gboolean plugin)
 {
   GtkWidget *dlg, *main_alignment;
   GtkWidget *vbox;

Modified: xfce4-screenshooter/trunk/lib/screenshooter-utils.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-utils.c	2009-04-16 09:34:41 UTC (rev 7215)
+++ xfce4-screenshooter/trunk/lib/screenshooter-utils.c	2009-04-16 11:21:00 UTC (rev 7216)
@@ -36,8 +36,9 @@
 
   TRACE ("Adding the image to the clipboard...");
 
-  clipboard = gtk_clipboard_get_for_display (gdk_display_get_default(), 
-                                             GDK_SELECTION_CLIPBOARD);
+  clipboard =
+    gtk_clipboard_get_for_display (gdk_display_get_default(), GDK_SELECTION_CLIPBOARD);
+
   gtk_clipboard_set_image (clipboard, screenshot);
 
   gtk_clipboard_store (clipboard);
@@ -60,7 +61,7 @@
   gint action = SAVE;
   gint show_save_dialog = 1;
   gint show_mouse = 1;
-  gint close = 1;
+  gint close_app = 1;
   gchar *screenshot_dir = screenshooter_get_home_uri ();
   gchar *app = g_strdup ("none");
 
@@ -88,7 +89,7 @@
           show_mouse =
             xfce_rc_read_int_entry (rc, "show_mouse", 1);
 
-          close =
+          close_app =
             xfce_rc_read_int_entry (rc, "close", 1);
               
           g_free (app);
@@ -117,7 +118,7 @@
   sd->action = action;
   sd->show_save_dialog = show_save_dialog;
   sd->show_mouse = show_mouse;
-  sd->close = close;
+  sd->close = close_app;
   sd->screenshot_dir = screenshot_dir;
   sd->app = app;
 }
@@ -167,9 +168,11 @@
 @application: the command to run the application.
 */
 void
-screenshooter_open_screenshot (gchar *screenshot_path,
-                               gchar *application)
+screenshooter_open_screenshot (gchar *screenshot_path, gchar *application)
 {
+  gchar *command;
+  GError *error = NULL;
+
   g_return_if_fail (screenshot_path != NULL);
   
   TRACE ("Path was != NULL");
@@ -178,17 +181,13 @@
 
   TRACE ("Application was not none");
 
-  gchar *command = 
-    g_strconcat (application, " ", screenshot_path, NULL);
+  command = g_strconcat (application, " ", screenshot_path, NULL);
 
-  GError *error = NULL;
-
   TRACE ("Launch the command");
   
   /* Execute the command and show an error dialog if there was 
   * an error. */
-  if (!xfce_exec_on_screen (gdk_screen_get_default (), command, 
-                            FALSE, TRUE, &error))
+  if (!g_spawn_command_line_async (command, &error))
     {
       TRACE ("An error occured");
 

Modified: xfce4-screenshooter/trunk/panel-plugin/screenshooter-plugin.c
===================================================================
--- xfce4-screenshooter/trunk/panel-plugin/screenshooter-plugin.c	2009-04-16 09:34:41 UTC (rev 7215)
+++ xfce4-screenshooter/trunk/panel-plugin/screenshooter-plugin.c	2009-04-16 11:21:00 UTC (rev 7216)
@@ -94,11 +94,9 @@
 cb_style_set                         (XfcePanelPlugin      *plugin, 
                                       gpointer              ignored,
                                       PluginData           *pd);
-                                       
-                                              
 
-/* Register the panel plugin */
-XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (screenshooter_plugin_construct);
+static void
+set_panel_button_tooltip             (PluginData           *pd);
 
 
 
@@ -221,12 +219,11 @@
 
 
 /* Callback for dialog response:
-   Update the tooltips if using gtk >= 2.12.
+   Update the tooltips.
    Unblock the plugin contextual menu.
    Save the options in the rc file.*/
 static void
-cb_dialog_response (GtkWidget *dlg, int response,
-                    PluginData *pd)
+cb_dialog_response (GtkWidget *dlg, int response, PluginData *pd)
 {
   if (response == GTK_RESPONSE_OK)
     {
@@ -235,23 +232,7 @@
       gtk_widget_destroy (dlg);
       
       /* Update tooltips according to the chosen option */
-      if (pd->sd->region == FULLSCREEN)
-      {
-        gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
-                        _("Take a screenshot of the entire screen"));
-      }
-      else if (pd->sd->region == ACTIVE_WINDOW)
-      {
-        gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
-                        _("Take a screenshot of the active window"));
-      }
-      else if (pd->sd->region == SELECT)
-      {
-        gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
-   _("Select a region to be captured by clicking a point of the screen "
-     "without releasing the mouse button, dragging your mouse to the "
-     "other corner of the region, and releasing the mouse button."));
-      }
+      set_panel_button_tooltip (pd);
       
       /* Unblock the menu and save options */
       xfce_panel_plugin_unblock_menu (pd->plugin);
@@ -264,9 +245,7 @@
               
       /* Execute the help and show an error dialog if there was 
        * an error. */
-      if (!xfce_exec_on_screen (gdk_screen_get_default (),
-                                "xfhelp4 xfce4-screenshooter.html", 
-                                FALSE, TRUE, &error_help))
+      if (!g_spawn_command_line_async ("xfhelp4 xfce4-screenshooter.html", &error_help))
         {
           xfce_err (error_help->message);
           g_error_free (error_help);
@@ -297,14 +276,38 @@
   
   g_object_set_data (G_OBJECT (plugin), "dialog", dlg);
   
-  g_signal_connect (dlg, "response", G_CALLBACK (cb_dialog_response),
-                    pd);
+  g_signal_connect (dlg, "response", G_CALLBACK (cb_dialog_response), pd);
 
   gtk_widget_show (dlg);
 }
 
 
 
+static void
+set_panel_button_tooltip (PluginData *pd)
+{
+  if (pd->sd->region == FULLSCREEN)
+    {
+      gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
+                                   _("Take a screenshot of the entire screen"));
+    }
+  else if (pd->sd->region == ACTIVE_WINDOW)
+    {
+      gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
+                                   _("Take a screenshot of the active window"));
+    }
+  else if (pd->sd->region == SELECT)
+    {
+      gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
+                                   _("Select a region to be captured by clicking a "
+                                     "point of the screen without releasing the mouse "
+                                     "button, dragging your mouse to the other corner "
+                                     "of the region, and releasing the mouse button."));
+    }
+}
+
+
+
 /* Create the plugin button */
 static void
 screenshooter_plugin_construct (XfcePanelPlugin *plugin)
@@ -340,23 +343,7 @@
   /* Set the tooltips if available */
   TRACE ("Set the default tooltip");
   
-  if (pd->sd->region == FULLSCREEN)
-   {
-     gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
-                      _("Take a screenshot of the entire screen"));
-   }
-  else if (pd->sd->region == ACTIVE_WINDOW)
-    {
-      gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
-                      _("Take a screenshot of the active window"));
-    }
-  else if (pd->sd->region == SELECT)
-    {
-      gtk_widget_set_tooltip_text (GTK_WIDGET (pd->button),
-   _("Select a region to be captured by clicking a point of the screen "
-     "without releasing the mouse button, dragging your mouse to the "
-     "other corner of the region, and releasing the mouse button."));
-    }
+  set_panel_button_tooltip (pd);
 
   TRACE ("Add the button to the panel");
   
@@ -370,30 +357,24 @@
 
   TRACE ("Set the clicked callback");
   
-  g_signal_connect (pd->button, "clicked",
-                    G_CALLBACK (cb_button_clicked), pd);
+  g_signal_connect (pd->button, "clicked", G_CALLBACK (cb_button_clicked), pd);
 
   TRACE ("Set the free data callback");
 
-  g_signal_connect (plugin, "free-data",
-                    G_CALLBACK (cb_free_data), pd);
+  g_signal_connect (plugin, "free-data", G_CALLBACK (cb_free_data), pd);
 
   TRACE ("Set the size changed callback");
 
-  g_signal_connect (plugin, "size-changed",
-                    G_CALLBACK (cb_set_size), pd);
+  g_signal_connect (plugin, "size-changed", G_CALLBACK (cb_set_size), pd);
 
   TRACE ("Set the style set callback");
 
-  pd->style_id =
-      g_signal_connect (plugin, "style-set",
-                        G_CALLBACK (cb_style_set), pd);
+  pd->style_id = g_signal_connect (plugin, "style-set", G_CALLBACK (cb_style_set), pd);
 
   TRACE ("Set the configuration menu");
 
   xfce_panel_plugin_menu_show_configure (plugin);
   
-  g_signal_connect (plugin, "configure-plugin",
-                    G_CALLBACK (cb_properties_dialog), pd);
+  g_signal_connect (plugin, "configure-plugin", G_CALLBACK (cb_properties_dialog), pd);
 }
 XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (screenshooter_plugin_construct);




More information about the Goodies-commits mailing list