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

Jerome Guelfucci jeromeg at xfce.org
Tue Nov 4 12:01:17 CET 2008


Author: jeromeg
Date: 2008-11-04 11:01:17 +0000 (Tue, 04 Nov 2008)
New Revision: 5966

Modified:
   xfce4-screenshooter-plugin/trunk/ChangeLog
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h
   xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c
   xfce4-screenshooter-plugin/trunk/src/main.c
Log:
Add missing comments in the code and improve indentation in some places.

Modified: xfce4-screenshooter-plugin/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter-plugin/trunk/ChangeLog	2008-11-04 10:04:03 UTC (rev 5965)
+++ xfce4-screenshooter-plugin/trunk/ChangeLog	2008-11-04 11:01:17 UTC (rev 5966)
@@ -1,3 +1,7 @@
+2008-11-04 jeromeg
+
+  * Add missing comments in the code and improve indentation in some places.
+
 2008-11-03 jeromeg
 
   * configure.ac.in: Display build options.

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	2008-11-04 10:04:03 UTC (rev 5965)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	2008-11-04 11:01:17 UTC (rev 5966)
@@ -46,6 +46,9 @@
                                       
 /* Internals */
 
+
+
+/* Set the mode when the button is toggled */
 static void cb_fullscreen_screen_toggled (GtkToggleButton *tb,
                                           ScreenshotData   *sd)
 {
@@ -61,6 +64,7 @@
 
 
 
+/* Set the mode when the button is toggled */
 static void cb_active_window_toggled (GtkToggleButton *tb,
                                       ScreenshotData   *sd)
 {
@@ -76,6 +80,7 @@
 
 
 
+/* Set sd->show_save_dialog when the button is toggled */
 static void cb_show_save_dialog_toggled (GtkToggleButton *tb,
                                          ScreenshotData   *sd)
 {
@@ -84,6 +89,7 @@
 
 
 
+/* Set sd->screenshot_dir when the user changed the value in the file chooser */
 static void cb_default_folder (GtkWidget       *chooser, 
                                ScreenshotData  *sd)
 {
@@ -93,6 +99,7 @@
 
    
 
+/* Set the delay according to the spinner */
 static void cb_delay_spinner_changed (GtkWidget       *spinner, 
                                       ScreenshotData  *sd)
 {
@@ -106,6 +113,7 @@
 
 
 
+/* Set sd->app as per the active item in the combobox */
 static void cb_combo_active_item_changed (GtkWidget *box, ScreenshotData *sd)
 {
   GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (box));
@@ -121,6 +129,7 @@
 
 
 
+/* Extract the informations from app_info and add them to the liststore. */
 static void add_item (GAppInfo *app_info, GtkWidget *liststore)
 {
   GtkTreeIter iter;
@@ -129,6 +138,7 @@
   GIcon *icon = g_app_info_get_icon (app_info);
   GdkPixbuf *pixbuf = NULL;
   
+  /* Get the icon */
   if (G_IS_LOADABLE_ICON (icon))
     {
       GFile *file = g_file_icon_get_file (G_FILE_ICON (icon));
@@ -164,11 +174,13 @@
         }
     }
   
+  /* Add to the liststore */
   gtk_list_store_append (GTK_LIST_STORE (liststore), &iter);
           
   gtk_list_store_set (GTK_LIST_STORE (liststore), &iter, 0, pixbuf, 1, name,
                       2, command, -1);
-          
+  
+  /* Free the stuff */      
   g_free (command);
   g_free (name);
   if (pixbuf != NULL)
@@ -178,12 +190,14 @@
 
 
 
+/* Populate the liststore using the applications which can open image/png. */
 static void populate_liststore (GtkListStore *liststore)
 {
   const gchar *content_type;
   GList	*list_app;
   GtkTreeIter iter;
   
+  /* Add default "none" item. */
   gtk_list_store_append (GTK_LIST_STORE (liststore), &iter);
   
   gtk_list_store_set (GTK_LIST_STORE (liststore), 
@@ -194,9 +208,11 @@
                       -1);
      
   content_type = "image/png";
-    
+  
+  /* Get all applications for image/png.*/
   list_app = g_app_info_get_all_for_type (content_type);
   
+  /* Add them to the liststore */
   if (list_app != NULL)
     {
       g_list_foreach (list_app, (GFunc) add_item, liststore);
@@ -205,6 +221,9 @@
     }
 }
 
+
+
+/* Select the sd->app item in the combobox */
 static void set_default_item (GtkWidget     *combobox, 
                               gchar         *default_app)
 {
@@ -212,8 +231,10 @@
   GtkTreeIter iter; 
   gchar *command = NULL;
   
+  /* Get the first iter */
   gtk_tree_model_get_iter_first (model , &iter);    
-
+  
+  /* Loop until finding the appropirate item, if any */
   do
     {
       gtk_tree_model_get (model, &iter, 2, &command, -1);
@@ -230,11 +251,16 @@
 }                              
 #endif
 
+
                       
 /* Public */
 
 
 
+/* Build the preferences dialog.
+ at sd: a ScreenshotData to set the options.
+plugin: if in plugin mode, we show the save options in the dialog.
+*/
 GtkWidget *screenshooter_dialog_new (ScreenshotData  *sd, gboolean plugin)
 {
   GtkWidget *dlg;
@@ -434,6 +460,11 @@
 }
 
 
+
+/* Dialog to set the screenshot_dir when using the main executable
+ at rc_file: file where the option will be saved.
+ at current_default_dir: the current default dir to set the file chooser.
+*/
 void screenshooter_preferences_dialog (gchar *rc_file, 
                                        gchar *current_default_dir)
 {

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h	2008-11-04 10:04:03 UTC (rev 5965)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h	2008-11-04 11:01:17 UTC (rev 5966)
@@ -21,17 +21,25 @@
 #include <config.h>
 #endif
 
+
+
 #include "screenshooter-utils.h"
 #ifdef HAVE_GIO
 #include <gio/gio.h>
 #endif
 
+
+
 #include <gtk/gtk.h>
 #include <libxfce4util/libxfce4util.h>
 #include <libxfcegui4/libxfcegui4.h>
 
-GtkWidget   *screenshooter_dialog_new          (ScreenshotData  *sd,
-                                                gboolean         plugin);
-void         screenshooter_preferences_dialog  (gchar           *rc_file, 
-                                                gchar           *current_default_dir);
+
+
+GtkWidget   
+*screenshooter_dialog_new          (ScreenshotData      *sd,
+                                    gboolean             plugin);
+void
+screenshooter_preferences_dialog   (gchar               *rc_file, 
+                                    gchar               *current_default_dir);
                                       

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c	2008-11-04 10:04:03 UTC (rev 5965)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c	2008-11-04 11:01:17 UTC (rev 5966)
@@ -280,6 +280,11 @@
 
 
 
+/* Read the options from file and sets the sd values.
+ at file: the path to the rc file.
+ at sd: the ScreenshotData to be set.
+ at dir_only: if true, only read the screenshot_dir.
+*/
 void
 screenshooter_read_rc_file (gchar               *file, 
                             ScreenshotData      *sd, 
@@ -328,6 +333,10 @@
 
 
 
+/* Writes the options from sd to file.
+ at file: the path to the rc file.
+ at sd: a ScreenshotData.
+*/
 void
 screenshooter_write_rc_file (gchar               *file, 
                              ScreenshotData      *sd)
@@ -349,12 +358,17 @@
 
 
 
+/* Opens the screenshot using application.
+ at screenshot_path: the path to the saved screenshot.
+ at application: the command to run the application.
+*/
 void
 screenshooter_open_screenshot (gchar *screenshot_path,
                                gchar *application)
 {
   if (screenshot_path != NULL)
     {
+      /* If application == none, we don't do anything */      
       if (!g_str_equal (application, "none"))
         {
           gchar *command = 
@@ -362,6 +376,7 @@
     
           GError      *error = NULL;
           
+          /* 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))
             {
               xfce_err (error->message);

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h	2008-11-04 10:04:03 UTC (rev 5965)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h	2008-11-04 11:01:17 UTC (rev 5966)
@@ -33,15 +33,22 @@
 
 #include <unistd.h>
 
+
+
 #define DEFAULT_SAVE_DIRECTORY xfce_get_homedir ()
 #define DEFAULT_APPLICATION "none"
 
+
+
+/* Screenshot Modes */
 enum {
   MODE_0,
   FULLSCREEN,
   ACTIVE_WINDOW,
 };
 
+
+
 /* Struct to store the screenshot options */
 typedef struct
 {
@@ -55,6 +62,8 @@
 }
 ScreenshotData;
 
+
+
 GdkPixbuf 
 *screenshooter_take_screenshot   (gint                  mode, 
                                   gint                  delay);

Modified: xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c	2008-11-04 10:04:03 UTC (rev 5965)
+++ xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c	2008-11-04 11:01:17 UTC (rev 5966)
@@ -168,12 +168,14 @@
   
   g_object_unref (screenshot);                                   
   
+  /* Open the screenshot */
   if (screenshot_path != NULL)
     {
       screenshooter_open_screenshot (screenshot_path, pd->sd->app);
       g_free (screenshot_path);
     }                              
   
+  /* Make the panel button clickable */
 	gtk_widget_set_sensitive (GTK_WIDGET (pd->button), TRUE);
 }
 

Modified: xfce4-screenshooter-plugin/trunk/src/main.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/src/main.c	2008-11-04 10:04:03 UTC (rev 5965)
+++ xfce4-screenshooter-plugin/trunk/src/main.c	2008-11-04 11:01:17 UTC (rev 5966)
@@ -180,15 +180,20 @@
     {
       screenshooter_preferences_dialog (rc_file, sd->screenshot_dir);
     }
+  /* Else we just show up the main application */
   else
     {
       GtkWidget *dialog;
       gint response;
       
+      /* Read the preferences */
       screenshooter_read_rc_file (rc_file, sd, FALSE);
       
+      /* Set the dialog up */
       dialog = screenshooter_dialog_new (sd, FALSE);
-            
+      
+      /* Run the dialog and destroy it, so that it's not grabbed in active
+         window mode */
       response = gtk_dialog_run (GTK_DIALOG (dialog));
       
       gtk_widget_destroy (dialog);
@@ -197,18 +202,21 @@
         {
           gchar *screenshot_path = NULL;
           
+          /* Take the screenshot */
           screenshot = screenshooter_take_screenshot (sd->mode, sd->delay);
           screenshot_path =
             screenshooter_save_screenshot (screenshot, sd->show_save_dialog, 
                                            sd->screenshot_dir);
           g_object_unref (screenshot);
           
+          /* Open the screenshot */
           if (screenshot_path != NULL)
             {
               screenshooter_open_screenshot (screenshot_path, sd->app);
               g_free (screenshot_path);
             }
-                   
+          
+          /* Save preferences */     
           screenshooter_write_rc_file (rc_file, sd);
         }
     }




More information about the Goodies-commits mailing list