[gimp/tito: 20/50] beautiful now - renamed functions with prefix tito, ordered, aligned, removed trailing spaces



commit aa481e353b33ccf3b6114d4309239fdf63604221
Author: srihari sriraman <techie visishta net>
Date:   Tue May 22 10:37:50 2012 +0530

    beautiful now - renamed functions with prefix tito, ordered, aligned, removed trailing spaces

 app/dialogs/tito-dialog.c |  579 +++++++++++++++++++++++----------------------
 1 files changed, 294 insertions(+), 285 deletions(-)
---
diff --git a/app/dialogs/tito-dialog.c b/app/dialogs/tito-dialog.c
index a874f9e..de94ab8 100644
--- a/app/dialogs/tito-dialog.c
+++ b/app/dialogs/tito-dialog.c
@@ -1,5 +1,5 @@
-/* GIMP - The GNU Image Manipulation Program
- * Copyright (C) 2012 Srihari Sriraman, Suhas Bharadwaj, Vidyashree K, Zeeshan Ali Ansari
+  /* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 2012 Srihari Sriraman, Suhas V, Vidyashree K, Zeeshan Ali Ansari
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,8 +15,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "config.h"           
-
+#include "config.h"
 #include <string.h>
 #include <time.h>
 #include <ctype.h>
@@ -24,96 +23,105 @@
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
 #include <gdk/gdkkeysyms.h>
-
 #include "libgimpbase/gimpbase.h"
-
 #include "dialogs-types.h"
-
 #include "widgets/gimpuimanager.h"
 #include "widgets/gimpaction.h"
-
 #include "tito-dialog.h"
-
 #include "gimp-intl.h"
 
 #define MAX_HISTORY_ACTIONS 20
 
-static GtkWidget* setup_list(void);                  //creates results ui
-static gboolean search_dialog (void);                //builds the main ui
-static void key_released (GtkWidget *widget, 
-                      GdkEventKey *event,
-                      gpointer func_data);           //callback for key release event in entry
-gboolean on_focus_out (GtkWidget *widget,
-                       GdkEventFocus *event,
-                       gpointer data);
-static gboolean search( GtkAction *action, 
-                        const gchar* keyword);       //searches through labels
-void search_display_results (const gchar *keyword);
-static void add_to_list( const gchar *label,  
-                          const gchar *tooltip,
-                          GtkAction* action);      //adds a new list items with given name
-gboolean result_selected (GtkWidget * widget,
-                      GdkEventKey* pKey,
-                      gpointer func_data);           //callback for return key pressed on result
-gboolean run_result_action(void);                        //resposible for carrying out action selected
-void row_activated ( GtkTreeView        *treeview,
-                     GtkTreePath        *path,
-                     GtkTreeViewColumn  *col,
-                     gpointer            userdata); //double click on result
-static gchar* find_accel_label( GtkAction *action);              //finds the shortcut (if any)
-static gboolean tito_action_view_accel_find_func ( GtkAccelKey *key,
-                                                   GClosure    *closure,
-                                                   gpointer     data);                     
-static void update_history(GtkAction *action);
-static void read_history(void);
-static void fill_history(void);
-int compare ( const void * a,
-              const void * b);
-gboolean initializer(void);
-void finalizer(void);
-static gboolean context_menu_invoked ( GtkWidget *widget,
-                                             GdkEvent  *event,
-                                             gpointer   user_data);
-static void preferences_dialog(void);            //builds the preferences dialog
-static void modify_position_spins(void);
-static void clear_history_button_clicked ( GtkButton *button,
-                                           gpointer   user_data);
-static void restore_defaults_button_clicked ( GtkButton *button,
-                                              gpointer   user_data);
-static void set_default_preferences(void);
-static void update_preferences(void);
-static void write_preferences(void);
-static void read_preferences(void);
-static void clear_history(void);
-static void set_prefereces_ui_values(void);
-static void context_menu(void);
-static void context_menu_handler( GtkMenuItem* menuitem,
-                                  gpointer *data);
-GimpUIManager     *manager;
-static GtkWidget  *dialog;
-static GtkWidget  *list;
-static GtkWidget  *list_view;
-static GtkWidget  *keyword_entry;
-static GtkWidget  *specify_radio;
-static GtkWidget  *pos_x_hbox;
-static GtkWidget  *pos_y_hbox;
-static GtkWidget  *right_top_radio;
-static GtkWidget  *middle_radio;
-static GtkWidget  *pos_x_spin_button;
-static GtkWidget  *pos_y_spin_button;
-static GtkWidget  *no_of_results_spin_button;
-static GtkWidget  *width_spin_button;
-static GtkWidget  *opacity_spin_button;
-static GtkWidget  *autohide_check_button;
-static GtkWidget  *show_insensitive_check_button;
-static GtkWidget  *preferences_button;
-static gint       def_height=1;
-static gint       tmp_x, tmp_y;
-static gchar      *history_file_path;
-static gchar      *preference_file_path;
-static gint       cur_no_of_his_actions;
-static gboolean   first_time=TRUE;
-static GtkCellRenderer *cell2;
+//search core
+gboolean            tito_run_result_action             (void);
+static GtkWidget*   tito_setup_results_list            (void);
+static gboolean     tito_search_dialog                 (void);
+static gboolean     tito_is_action_match               (GtkAction         *action,
+                                                        const gchar*       keyword);
+static void         tito_add_to_results_list           (const gchar       *label,
+                                                        const gchar       *tooltip,
+                                                        GtkAction*         action);
+static void         tito_search_history_and_actions    (const gchar       *keyword);
+
+//history
+static void         tito_update_history                (GtkAction         *action);
+static void         tito_read_history                  (void);
+static void         tito_fill_history                  (void);
+static void         tito_clear_history                 (void);
+
+//preferences
+static void         tito_preferences_dialog            (void);
+static void         tito_set_default_preferences       (void);
+static void         tito_update_preferences            (void);
+static void         tito_write_preferences             (void);
+static void         tito_read_preferences              (void);
+static void         tito_set_prefereces_ui_values      (void);
+
+//utilities
+gboolean            initializer                        (void);
+void                finalizer                          (void);
+int                 compare                            (const void         *a,
+                                                        const void         *b);
+static gchar*       find_accel_label                   (GtkAction          *action);
+static gboolean     tito_action_view_accel_find_func   (GtkAccelKey        *key,
+                                                        GClosure           *closure,
+                                                        gpointer            data);
+
+//events
+gboolean            result_selected                    (GtkWidget          *widget,
+                                                        GdkEventKey        *pKey,
+                                                        gpointer            func_data);
+static void         tito_clear_history_button_clicked  (GtkButton          *button,
+                                                        gpointer            user_data);
+static void         restore_defaults_button_clicked    (GtkButton          *button,
+                                                        gpointer            user_data);
+static void         modify_position_spins              (void);
+static void         key_released                       (GtkWidget          *widget,
+                                                        GdkEventKey        *event,
+                                                        gpointer            func_data);
+gboolean            on_focus_out                       (GtkWidget          *widget,
+                                                        GdkEventFocus      *event,
+                                                        gpointer            data);
+void                row_activated                      (GtkTreeView        *treeview,
+                                                        GtkTreePath        *path,
+                                                        GtkTreeViewColumn  *col,
+                                                        gpointer            userdata);
+//context menu
+static void         context_menu                       (void);
+static void         context_menu_handler               (GtkMenuItem        *menuitem,
+                                                        gpointer           *data);
+static gboolean     context_menu_invoked               (GtkWidget          *widget,
+                                                        GdkEvent           *event,
+                                                        gpointer            user_data);
+
+
+
+static GtkWidget        *dialog;
+static GtkWidget        *list;
+static GtkWidget        *list_view;
+static GtkWidget        *keyword_entry;
+static GtkWidget        *specify_radio;
+static GtkWidget        *pos_x_hbox;
+static GtkWidget        *pos_y_hbox;
+static GtkWidget        *right_top_radio;
+static GtkWidget        *middle_radio;
+static GtkWidget        *pos_x_spin_button;
+static GtkWidget        *pos_y_spin_button;
+static GtkWidget        *no_of_results_spin_button;
+static GtkWidget        *width_spin_button;
+static GtkWidget        *opacity_spin_button;
+static GtkWidget        *autohide_check_button;
+static GtkWidget        *show_insensitive_check_button;
+static GtkWidget        *preferences_button;
+
+GimpUIManager           *manager;
+static gint             def_height=1;
+static gint             tmp_x, tmp_y;
+static gchar            *history_file_path;
+static gchar            *preference_file_path;
+static gint             cur_no_of_his_actions;
+static gboolean         first_time=TRUE;
+static GtkCellRenderer  *cell_renderer;
 
 
  enum RES_COL {
@@ -127,7 +135,7 @@ static GtkCellRenderer *cell2;
 static struct HISTORY {
   GtkAction* history_action;
   int count;
-}history[MAX_HISTORY_ACTIONS]; 
+}history[MAX_HISTORY_ACTIONS];
 
 static struct HISTORY_ACTION_NAME{
   char* action_name;
@@ -150,16 +158,16 @@ tito_dialog_create (void)
 {
   if(!initializer())
     g_message("Tito initializer failed");
-  search_dialog();
+  tito_search_dialog();
   return dialog;
 }
 
-static GtkWidget* 
-setup_list(void)
+static GtkWidget*
+tito_setup_results_list(void)
 {
   gint wid1=100;
   GtkWidget *sc_win;
-  GtkListStore *store; // holds all objects to be displayed in the list
+  GtkListStore *store;
   GtkCellRenderer *cell1;
   GtkTreeViewColumn *column1, *column2;
 
@@ -167,8 +175,7 @@ setup_list(void)
   store=gtk_list_store_new(N_COL, G_TYPE_STRING, G_TYPE_STRING, GTK_TYPE_ACTION,G_TYPE_BOOLEAN);
   list=gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
   gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(list),FALSE);
-  
-  //set up column 1
+
   cell1 = gtk_cell_renderer_pixbuf_new ();
   column1=gtk_tree_view_column_new_with_attributes(NULL,
                                                   cell1,
@@ -178,21 +185,20 @@ setup_list(void)
   gtk_tree_view_column_add_attribute(column1, cell1, "sensitive", IS_SENSITIVE);
   gtk_tree_view_column_set_min_width(column1,22);
 
-  //set up column 2
-  cell2 = gtk_cell_renderer_text_new();
+  cell_renderer = gtk_cell_renderer_text_new();
   column2=gtk_tree_view_column_new_with_attributes(NULL,
-                                                  cell2,
+                                                  cell_renderer,
                                                   "markup", RESULT_DATA,
                                                   NULL);
-  gtk_tree_view_column_add_attribute(column2, cell2, "sensitive", IS_SENSITIVE);
+  gtk_tree_view_column_add_attribute(column2, cell_renderer, "sensitive", IS_SENSITIVE);
   gtk_tree_view_append_column(GTK_TREE_VIEW(list),column2);
   gtk_tree_view_column_set_max_width(column2,wid1);
-  
+
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sc_win),
                                  GTK_POLICY_NEVER,
                                  GTK_POLICY_AUTOMATIC);
   g_signal_connect(list, "row-activated", (GCallback) row_activated, NULL);
-                                 
+
   gtk_container_add(GTK_CONTAINER(sc_win),list);
   g_object_unref(G_OBJECT(store));
   return sc_win;
@@ -200,7 +206,7 @@ setup_list(void)
 
 
 static gboolean
-search_dialog (void)
+tito_search_dialog (void)
 {
   GtkWidget *main_vbox, *main_hbox;
   GtkWidget *preferences_image;
@@ -219,9 +225,9 @@ search_dialog (void)
   gtk_widget_show (main_vbox);
 
   main_hbox = gtk_hbox_new (FALSE, 2);
-  gtk_box_pack_start(GTK_BOX(main_vbox),main_hbox,FALSE,TRUE,0);  
+  gtk_box_pack_start(GTK_BOX(main_vbox),main_hbox,FALSE,TRUE,0);
   gtk_widget_show (main_hbox);
-  
+
   keyword_entry = gtk_entry_new();
   gtk_entry_set_has_frame(GTK_ENTRY(keyword_entry),FALSE);
   gtk_entry_set_icon_from_stock(GTK_ENTRY(keyword_entry),GTK_ENTRY_ICON_PRIMARY,GTK_STOCK_FIND);
@@ -234,8 +240,8 @@ search_dialog (void)
   gtk_widget_show (preferences_image);
   gtk_widget_show (preferences_button);
   gtk_box_pack_end(GTK_BOX(main_hbox),preferences_button,FALSE,TRUE,0);
-  
-  list_view = setup_list();
+
+  list_view = tito_setup_results_list();
   gtk_box_pack_start(GTK_BOX(main_vbox),list_view,TRUE,TRUE,0);
 
 
@@ -243,7 +249,7 @@ search_dialog (void)
   gtk_widget_set_events(dialog, GDK_KEY_PRESS_MASK);
   gtk_widget_set_events(dialog, GDK_BUTTON_PRESS_MASK);
   gtk_widget_set_events(preferences_button, GDK_BUTTON_PRESS_MASK);
-  
+
   g_signal_connect (keyword_entry, "key-release-event", G_CALLBACK (key_released), NULL);
   g_signal_connect (list, "key_press_event", G_CALLBACK (result_selected), NULL);
   g_signal_connect (preferences_button, "clicked", G_CALLBACK(context_menu_invoked),NULL);
@@ -253,17 +259,8 @@ search_dialog (void)
   return TRUE;
 }
 
-static gboolean
-context_menu_invoked ( GtkWidget *widget,
-                             GdkEvent  *event,
-                             gpointer   user_data)
-{ 
-  context_menu();
-  return TRUE;
-}
-
 static void
-preferences_dialog(void)
+tito_preferences_dialog (void)
 {
   GtkWidget   *pref_dialog;
   GtkWidget   *top_hbox;
@@ -271,7 +268,7 @@ preferences_dialog(void)
   GtkWidget   *position_frame;
   GtkWidget   *position_vbox;
   GtkWidget   *pos_x_label;
-  GtkWidget   *pos_y_label;  
+  GtkWidget   *pos_y_label;
   GtkWidget   *specify_alignment_x;
   GtkWidget   *specify_alignment_y;
 
@@ -279,15 +276,15 @@ preferences_dialog(void)
   GtkWidget   *display_vbox;
   GtkWidget   *no_of_results_hbox;
   GtkWidget   *width_hbox;
-  GtkWidget   *opacity_hbox;    
+  GtkWidget   *opacity_hbox;
   GtkWidget   *no_of_results_label;
   GtkWidget   *width_label;
-  GtkWidget   *opacity_label;  
-  
+  GtkWidget   *opacity_label;
+
   GtkWidget   *bottom_hbox;
-  GtkWidget   *clear_history_button;
+  GtkWidget   *tito_clear_history_button;
   GtkWidget   *restore_defaults_button;
-  
+
   pref_dialog = gtk_dialog_new_with_buttons ( "Tito preferences",
                                               NULL,
                                               GTK_DIALOG_MODAL,
@@ -295,12 +292,12 @@ preferences_dialog(void)
                                               GTK_RESPONSE_ACCEPT,
                                               GTK_STOCK_CANCEL,
                                               GTK_RESPONSE_REJECT,
-                                              NULL); 
+                                              NULL);
 
   gtk_window_set_position (GTK_WINDOW(pref_dialog), GTK_WIN_POS_CENTER_ALWAYS);
   top_hbox = gtk_hbox_new (FALSE,10);
   gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(pref_dialog))), top_hbox, FALSE, FALSE, 
2);
-  
+
   //Position preferences
   position_frame = gtk_frame_new("Postion");
   position_vbox = gtk_vbox_new(TRUE,2);
@@ -315,7 +312,7 @@ preferences_dialog(void)
   specify_alignment_x = gtk_alignment_new (1,0,0,0);
   specify_alignment_y = gtk_alignment_new (1,0,0,0);
   pos_x_label = gtk_label_new("x:");
-  pos_y_label = gtk_label_new("y:");      
+  pos_y_label = gtk_label_new("y:");
   pos_x_spin_button = gtk_spin_button_new_with_range (0, 100-PREF.WIDTH, 1);
   pos_y_spin_button = gtk_spin_button_new_with_range (0, 50, 1);
 
@@ -328,31 +325,31 @@ preferences_dialog(void)
       gtk_box_pack_start (GTK_BOX (position_vbox), specify_alignment_x, TRUE, TRUE, 1);
           gtk_container_add (GTK_CONTAINER (specify_alignment_x), pos_x_hbox);
               gtk_box_pack_start (GTK_BOX (pos_x_hbox),pos_x_label, TRUE, TRUE, 1);
-              gtk_box_pack_start (GTK_BOX (pos_x_hbox),pos_x_spin_button, TRUE, TRUE, 1);              
+              gtk_box_pack_start (GTK_BOX (pos_x_hbox),pos_x_spin_button, TRUE, TRUE, 1);
 
       gtk_box_pack_start (GTK_BOX (position_vbox), specify_alignment_y, TRUE, TRUE, 1);
           gtk_container_add (GTK_CONTAINER (specify_alignment_y), pos_y_hbox);
               gtk_box_pack_start (GTK_BOX (pos_y_hbox),pos_y_label, TRUE, TRUE, 1);
-              gtk_box_pack_start (GTK_BOX (pos_y_hbox),pos_y_spin_button, TRUE, TRUE, 1);              
+              gtk_box_pack_start (GTK_BOX (pos_y_hbox),pos_y_spin_button, TRUE, TRUE, 1);
 
   //Display preferences
   display_frame = gtk_frame_new("Display");
   display_vbox = gtk_vbox_new(TRUE,2);
- 
+
   gtk_frame_set_shadow_type (GTK_FRAME(display_frame), GTK_SHADOW_ETCHED_IN);
-  
+
   no_of_results_hbox = gtk_hbox_new(FALSE,2);
   width_hbox = gtk_hbox_new(FALSE,2);
-  opacity_hbox = gtk_hbox_new(FALSE,2);  
+  opacity_hbox = gtk_hbox_new(FALSE,2);
   no_of_results_label = gtk_label_new("Results height:");
   no_of_results_spin_button = gtk_spin_button_new_with_range(2,10,1);
   width_label = gtk_label_new("Tito Width:");
   width_spin_button = gtk_spin_button_new_with_range(20,60,1);
   opacity_label = gtk_label_new("Tito Opacity:");
-  opacity_spin_button = gtk_spin_button_new_with_range(40,100,10);  
+  opacity_spin_button = gtk_spin_button_new_with_range(40,100,10);
   autohide_check_button = gtk_check_button_new_with_label("Autohide");
   show_insensitive_check_button = gtk_check_button_new_with_label("Show inert actions");
-  clear_history_button = gtk_button_new_with_label ("Clear history");
+  tito_clear_history_button = gtk_button_new_with_label ("Clear history");
   restore_defaults_button = gtk_button_new_with_label ("Restore defaults");
 
   gtk_box_pack_start (GTK_BOX(top_hbox), display_frame, FALSE, FALSE, 2);
@@ -360,20 +357,19 @@ preferences_dialog(void)
       gtk_box_pack_start (GTK_BOX (display_vbox), no_of_results_hbox, TRUE, TRUE, 2);
           gtk_box_pack_start (GTK_BOX (no_of_results_hbox), no_of_results_label, TRUE, TRUE, 2);
           gtk_box_pack_start (GTK_BOX (no_of_results_hbox), no_of_results_spin_button, TRUE, TRUE, 2);
-      gtk_box_pack_start (GTK_BOX (display_vbox), width_hbox, TRUE, TRUE, 2);          
-          gtk_box_pack_start (GTK_BOX (width_hbox), width_label, TRUE, TRUE, 2);          
+      gtk_box_pack_start (GTK_BOX (display_vbox), width_hbox, TRUE, TRUE, 2);
+          gtk_box_pack_start (GTK_BOX (width_hbox), width_label, TRUE, TRUE, 2);
           gtk_box_pack_start (GTK_BOX (width_hbox), width_spin_button, TRUE, TRUE, 2);
-      gtk_box_pack_start (GTK_BOX (display_vbox), opacity_hbox, TRUE, TRUE, 2);          
-          gtk_box_pack_start (GTK_BOX (opacity_hbox), opacity_label, TRUE, TRUE, 2);          
-          gtk_box_pack_start (GTK_BOX (opacity_hbox), opacity_spin_button, TRUE, TRUE, 2);    
+      gtk_box_pack_start (GTK_BOX (display_vbox), opacity_hbox, TRUE, TRUE, 2);
+          gtk_box_pack_start (GTK_BOX (opacity_hbox), opacity_label, TRUE, TRUE, 2);
+          gtk_box_pack_start (GTK_BOX (opacity_hbox), opacity_spin_button, TRUE, TRUE, 2);
       gtk_box_pack_start (GTK_BOX (display_vbox), autohide_check_button, TRUE, TRUE, 2);
       gtk_box_pack_start (GTK_BOX (display_vbox), show_insensitive_check_button, TRUE, TRUE, 2);
 
-  
   //Clear and restore
   bottom_hbox = gtk_hbox_new(TRUE,2);
   gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(pref_dialog))), bottom_hbox, FALSE, 
FALSE, 2);
-    gtk_box_pack_start (GTK_BOX (bottom_hbox), clear_history_button, TRUE, TRUE, 2);
+    gtk_box_pack_start (GTK_BOX (bottom_hbox), tito_clear_history_button, TRUE, TRUE, 2);
     gtk_box_pack_start (GTK_BOX (bottom_hbox), restore_defaults_button, TRUE, TRUE, 2);
 
   gtk_widget_show (top_hbox);
@@ -391,42 +387,41 @@ preferences_dialog(void)
   gtk_widget_show (pos_y_label);
   gtk_widget_show (pos_x_spin_button);
   gtk_widget_show (pos_y_spin_button);
-                                                                
   gtk_widget_show (display_frame);
   gtk_widget_show (display_vbox);
   gtk_widget_show (no_of_results_hbox);
   gtk_widget_show (width_hbox);
-  gtk_widget_show (opacity_hbox);  
+  gtk_widget_show (opacity_hbox);
   gtk_widget_show (no_of_results_label);
   gtk_widget_show (width_label);
   gtk_widget_show (opacity_label);
   gtk_widget_show (no_of_results_spin_button);
   gtk_widget_show (width_spin_button);
-  gtk_widget_show (opacity_spin_button);  
+  gtk_widget_show (opacity_spin_button);
   gtk_widget_show (autohide_check_button);
   gtk_widget_show (show_insensitive_check_button);
 
   gtk_widget_show (bottom_hbox);
-  gtk_widget_show (clear_history_button);
+  gtk_widget_show (tito_clear_history_button);
   gtk_widget_show (restore_defaults_button);
 
-  set_prefereces_ui_values();
+  tito_set_prefereces_ui_values();
   gtk_widget_show (pref_dialog);
 
   g_signal_connect (right_top_radio, "toggled", G_CALLBACK (modify_position_spins), NULL);
   g_signal_connect (middle_radio, "toggled", G_CALLBACK (modify_position_spins), NULL);
   g_signal_connect (specify_radio, "toggled", G_CALLBACK (modify_position_spins), NULL);
-  g_signal_connect (clear_history_button, "clicked", G_CALLBACK (clear_history_button_clicked), NULL);
+  g_signal_connect (tito_clear_history_button, "clicked", G_CALLBACK (tito_clear_history_button_clicked), 
NULL);
   g_signal_connect (restore_defaults_button, "clicked", G_CALLBACK (restore_defaults_button_clicked), NULL);
 
   if(gtk_dialog_run (GTK_DIALOG (pref_dialog)) == GTK_RESPONSE_ACCEPT)
-    update_preferences();
+    tito_update_preferences();
 
   gtk_widget_destroy (pref_dialog);
 }
 
 static void
-set_prefereces_ui_values(void)
+tito_set_prefereces_ui_values (void)
 {
   if( PREF.POSITION == 0)
     gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(right_top_radio), TRUE);
@@ -440,13 +435,13 @@ set_prefereces_ui_values(void)
   gtk_spin_button_set_value (GTK_SPIN_BUTTON(no_of_results_spin_button), (gdouble)PREF.NO_OF_RESULTS);
   gtk_spin_button_set_value (GTK_SPIN_BUTTON(width_spin_button), (gdouble)PREF.WIDTH);
   gtk_spin_button_set_value (GTK_SPIN_BUTTON(opacity_spin_button), (gdouble)PREF.OPACITY*100);
-  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autohide_check_button), PREF.AUTO_HIDE);    
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autohide_check_button), PREF.AUTO_HIDE);
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_insensitive_check_button), PREF.SHOW_INSENSITIVE);
-  
+
 }
 
 static void
-modify_position_spins(void)
+modify_position_spins (void)
 {
   if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(specify_radio)))
     {
@@ -462,23 +457,23 @@ modify_position_spins(void)
                             (gdouble)(PREF.POSITION_X/gdk_screen_get_width(gdk_screen_get_default())*100));
   gtk_spin_button_set_value (GTK_SPIN_BUTTON(pos_y_spin_button),
                             (gdouble)(PREF.POSITION_Y/gdk_screen_get_height(gdk_screen_get_default())*100));
-  gtk_spin_button_set_range (GTK_SPIN_BUTTON(pos_x_spin_button), 
+  gtk_spin_button_set_range (GTK_SPIN_BUTTON(pos_x_spin_button),
                             (gdouble)0, (gdouble)( 100-gtk_spin_button_get_value_as_int 
(GTK_SPIN_BUTTON(width_spin_button))));
-}                            
+}
 
 static void
-clear_history_button_clicked ( GtkButton *button,
-                               gpointer   user_data) 
+tito_clear_history_button_clicked ( GtkButton *button,
+                                    gpointer   user_data)
 {
-  clear_history();
+  tito_clear_history();
 }
 
 static void
 restore_defaults_button_clicked ( GtkButton *button,
-                               gpointer   user_data) 
+                                  gpointer   user_data)
 {
-  set_default_preferences();
-  set_prefereces_ui_values();
+  tito_set_default_preferences();
+  tito_set_prefereces_ui_values();
 }
 
 gboolean
@@ -502,25 +497,25 @@ key_released( GtkWidget *widget,
 
   switch (event->keyval)
   {
-    case GDK_Escape: 
+    case GDK_Escape:
     {
       finalizer();
       return;
     }
     case GDK_Return:
     {
-      run_result_action();
+      tito_run_result_action();
       return;
     }
   }
-  
+
   if(strcmp(entry_text,"")!=0)
     {
       gtk_window_resize(GTK_WINDOW(dialog),(PREF.WIDTH * gdk_screen_get_width(gdk_screen_get_default()))/100,
                        (PREF.NO_OF_RESULTS*40+100));
       gtk_list_store_clear (GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list))));
       gtk_widget_show_all(list_view);
-      search_display_results(entry_text);
+      tito_search_history_and_actions(entry_text);
       gtk_tree_selection_select_path ( gtk_tree_view_get_selection(GTK_TREE_VIEW(list)),
                                        gtk_tree_path_new_from_string("0"));
     }
@@ -530,12 +525,12 @@ key_released( GtkWidget *widget,
                        (PREF.NO_OF_RESULTS*40+100));
       gtk_list_store_clear (GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list))));
       gtk_widget_show_all(list_view);
-      search_display_results(" ");
+      tito_search_history_and_actions(" ");
       gtk_tree_selection_select_path ( gtk_tree_view_get_selection(GTK_TREE_VIEW(list)),
                                        gtk_tree_path_new_from_string("0"));
 
     }
-  else    
+  else
     {
       gtk_widget_hide(list_view);
       gtk_window_resize (GTK_WINDOW(dialog),(PREF.WIDTH * 
gdk_screen_get_width(gdk_screen_get_default()))/100,def_height);
@@ -543,7 +538,7 @@ key_released( GtkWidget *widget,
 }
 
 gboolean
-result_selected ( GtkWidget * widget, 
+result_selected ( GtkWidget * widget,
                   GdkEventKey* pKey,
                   gpointer func_data)
 {
@@ -553,10 +548,10 @@ result_selected ( GtkWidget * widget,
         {
           case GDK_Return:
             {
-                               run_result_action();
+                    tito_run_result_action();
               break;
-             }
-               case GDK_Escape: 
+              }
+            case GDK_Escape:
             {
               finalizer();
               return TRUE;
@@ -569,12 +564,12 @@ result_selected ( GtkWidget * widget,
               GtkTreePath       *path;
               selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
               gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
-              
+
               if (gtk_tree_selection_get_selected(selection, &model, &iter))
                 {
                   path = gtk_tree_model_get_path(model,&iter);
                   if(strcmp(gtk_tree_path_to_string(path),"0")==0)
-                    { 
+                    {
                       gtk_widget_grab_focus((GTK_WIDGET(keyword_entry)));
                       return TRUE;
                     }
@@ -592,14 +587,14 @@ row_activated ( GtkTreeView        *treeview,
                 GtkTreeViewColumn  *col,
                 gpointer            userdata)
 {
-       run_result_action();
+    tito_run_result_action();
 }
-  
+
 
 static void
-add_to_list( const gchar *label,
-             const gchar *tooltip,
-             GtkAction* action)
+tito_add_to_results_list( const gchar *label,
+                          const gchar *tooltip,
+                          GtkAction* action)
 {
   GtkListStore *store;
   GtkTreeIter iter;
@@ -608,12 +603,12 @@ add_to_list( const gchar *label,
   const gchar *stock_id = gtk_action_get_stock_id (action);
   char *data = g_new(char,1024);
   char shortcut[1024] = "";
-  
+
   if(data==NULL)
     return;
   if(strchr(label, '@')!=NULL||strchr(label, '&')!=NULL)
     return;
-    
+
   if(GTK_IS_TOGGLE_ACTION(action))
     {
       if(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))
@@ -621,11 +616,11 @@ add_to_list( const gchar *label,
       else
         stock_id = GTK_STOCK_NO;
     }
- 
+
   if(accel_string==NULL)
       strcpy(shortcut,"");
   else if(strchr(accel_string,'<')!=NULL)
-      strcpy(shortcut,"");  
+      strcpy(shortcut,"");
   else
     {
       strcpy(shortcut," | ");
@@ -635,13 +630,13 @@ add_to_list( const gchar *label,
   if(tooltip==NULL)
       strcpy(data,"");
   else if(strchr(tooltip, '<')!=NULL)
-       strcpy(data,""); 
+       strcpy(data,"");
   else
     {
       strcpy(data,"\n");
       strcat(data,tooltip);
     }
-      
+
   markuptxt = g_strdup_printf("%s<small>%s<span weight='light'>%s</span></small>",
                                label, shortcut, data);
   store= GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
@@ -656,12 +651,12 @@ add_to_list( const gchar *label,
 }
 
 gboolean
-run_result_action(void)
+tito_run_result_action(void)
 {
   GtkTreeSelection *selection;
   GtkTreeModel     *model;
   GtkTreeIter       iter;
-  
+
   selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
   gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
   if (gtk_tree_selection_get_selected(selection, &model, &iter))
@@ -670,37 +665,37 @@ run_result_action(void)
       gtk_tree_model_get (model, &iter, RESULT_ACTION, &action, -1);
       if(!gtk_action_get_sensitive(action))
         return FALSE;
-      
+
       if(PREF.AUTO_HIDE)
-           gtk_widget_hide(dialog);
+        gtk_widget_hide(dialog);
       gtk_action_activate(action);
       finalizer();
-      update_history(action);
+      tito_update_history(action);
     }
   return TRUE;
 }
 
 
 void
-search_display_results (const gchar *keyword)
+tito_search_history_and_actions (const gchar *keyword)
 {
   GList             *list;
-  int i = 0;  
+  int i = 0;
   manager= gimp_ui_managers_from_name ("<Image>")->data;
   if(strcmp(keyword,"")==0)
     return;
-       
-       //search in history
-       for(i=0;i<cur_no_of_his_actions;i++)
-       {
-         if(history[i].history_action!=NULL)
-           {
-             if(search(history[i].history_action,keyword))
-          add_to_list( gimp_strip_uline (gtk_action_get_label (history[i].history_action)),
+
+    //search in history
+    for(i=0;i<cur_no_of_his_actions;i++)
+    {
+      if(history[i].history_action!=NULL)
+        {
+          if(tito_is_action_match(history[i].history_action,keyword))
+          tito_add_to_results_list( gimp_strip_uline (gtk_action_get_label (history[i].history_action)),
                      gtk_action_get_tooltip (history[i].history_action),
-                     history[i].history_action );              
-           }
-         }
+                     history[i].history_action );
+        }
+      }
 
   //for every action group
   for (list = gtk_ui_manager_get_action_groups (GTK_UI_MANAGER (manager));
@@ -710,12 +705,12 @@ search_display_results (const gchar *keyword)
       GimpActionGroup *group = list->data;
       GList           *actions;
       GList           *list2;
-      
-      
+
+
       //get and sort actions
       actions = gtk_action_group_list_actions (GTK_ACTION_GROUP (group));
       actions = g_list_sort (actions, (GCompareFunc) gimp_action_name_compare);
-      
+
       //for every action
       for (list2 = actions; list2; list2 = g_list_next (list2))
         {
@@ -724,16 +719,17 @@ search_display_results (const gchar *keyword)
           gboolean        is_redundant = FALSE;
           name         = gtk_action_get_name (action);
 
-            
-          //exclude menus and popups
+
+          //exclude menus, popups, context and undo
           if (strstr (name, "-menu")  ||
               strstr (name, "-popup") ||
               strstr (name,"context") ||
+              strstr (name,"edit-undo") ||
               name[0] == '<')
             continue;
-              
-               if( !gtk_action_get_sensitive(action) && !(PREF.SHOW_INSENSITIVE) )
-                       continue;
+
+            if( !gtk_action_get_sensitive(action) && !(PREF.SHOW_INSENSITIVE) )
+                continue;
 
           for(i=0;i<cur_no_of_his_actions;i++)
             {
@@ -746,13 +742,13 @@ search_display_results (const gchar *keyword)
                     }
                 }
             }
-          
+
           if(is_redundant)
             continue;
-            
-          if(search(action,keyword))
-                   {
-              add_to_list( gimp_strip_uline (gtk_action_get_label (action)),
+
+          if(tito_is_action_match(action,keyword))
+            {
+              tito_add_to_results_list( gimp_strip_uline (gtk_action_get_label (action)),
                            gtk_action_get_tooltip (action),
                            action);
             }
@@ -761,12 +757,12 @@ search_display_results (const gchar *keyword)
    }
 }
 
-static void fill_history(void)
+static void tito_fill_history (void)
 {
   GList             *list;
-  int i = 0;  
+  int i = 0;
   manager= gimp_ui_managers_from_name ("<Image>")->data;
-  
+
   for (list = gtk_ui_manager_get_action_groups (GTK_UI_MANAGER (manager));
        list;
        list = g_list_next (list))
@@ -774,18 +770,18 @@ static void fill_history(void)
         GimpActionGroup *group = list->data;
         GList           *actions;
         GList           *list2;
-        
+
          //get and sort actions
          actions = gtk_action_group_list_actions (GTK_ACTION_GROUP (group));
          actions = g_list_sort (actions, (GCompareFunc) gimp_action_name_compare);
-          
+
          //for every action
          for (list2 = actions; list2; list2 = g_list_next (list2))
            {
              GtkAction       *action        = list2->data;
              const gchar     *action_name;
              action_name        = gtk_action_get_name (action);
-                
+
              //exclude menus and popups
              if ( strstr (action_name, "-menu")  ||
                   strstr (action_name, "-popup") ||
@@ -809,8 +805,8 @@ static void fill_history(void)
 }
 
 static gboolean
-search( GtkAction *action,
-        const gchar* keyword)
+tito_is_action_match ( GtkAction *action,
+                       const gchar* keyword)
 {
   gchar *label, *tooltip, *key;
   int i;
@@ -830,16 +826,16 @@ search( GtkAction *action,
     {
       space_pos=strchr(label,' ');
       if(space_pos!=NULL)
-        {  
+        {
           space_pos++;
           if(key[0]==label[0] && key[1]==*space_pos)
               return TRUE;
         }
     }
-    
+
   if(strstr(label,key))
-           return TRUE; 
-           
+        return TRUE;
+
   if(strlen(key)>2 || strcmp(key," ")==0)
     {
       if(gtk_action_get_tooltip(action)!=NULL)
@@ -849,10 +845,10 @@ search( GtkAction *action,
             tooltip[i]=tolower(tooltip[i]);
 
           if(strstr(tooltip,key))
-               return TRUE; 
+                return TRUE;
         }
     }
-    
+
   g_free(label);
   g_free(key);
   g_free(tooltip);
@@ -876,7 +872,7 @@ find_accel_label( GtkAction *action)
   GClosure        *accel_closure = NULL;
   gchar           *accel_string;
   GtkAccelGroup   *accel_group;
-  
+
   accel_group = gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (manager));
   accel_closure = gtk_action_get_accel_closure (action);
 
@@ -898,19 +894,19 @@ find_accel_label( GtkAction *action)
   if(strcmp(accel_string,""))
     return accel_string;
 
-  return NULL;    
+  return NULL;
 }
 
 static void
-read_history(void)
+tito_read_history (void)
 {
   int i;
   FILE *fp;
   cur_no_of_his_actions=0;
-  
+
   fp= fopen(history_file_path,"r");
   if(fp==NULL)
-           return;
+        return;
 
   for(i=0;i<MAX_HISTORY_ACTIONS;i++)
     {
@@ -919,23 +915,23 @@ read_history(void)
       cur_no_of_his_actions++;
     }
   fclose(fp);
-  fill_history();
+  tito_fill_history();
 }
 
 static void
-update_history(GtkAction *action)
+tito_update_history (GtkAction *action)
 {
   int i;
   FILE *fp;
   gboolean is_present=FALSE;
-  
+
   fp= fopen(history_file_path,"w");
   if(fp==NULL)
     {
       g_message("Unable to open history file to write");
      return;
     }
-    
+
   //check if already in history var
   for(i=0;i<cur_no_of_his_actions;i++)
     {
@@ -946,29 +942,33 @@ update_history(GtkAction *action)
           break;
         }
     }
-    
+
   //assign action to history var
   if(!is_present)
     {
-      if(cur_no_of_his_actions==MAX_HISTORY_ACTIONS-1)
-        history[cur_no_of_his_actions].count=1;
+      if(cur_no_of_his_actions==MAX_HISTORY_ACTIONS)
+        {
+          history[MAX_HISTORY_ACTIONS-1].history_action = action;
+          history[MAX_HISTORY_ACTIONS-1].count=1;
+        }
       else
-        history[cur_no_of_his_actions++].count=1;
-
-      history[cur_no_of_his_actions].history_action = action;
+        {
+          history[cur_no_of_his_actions].history_action = action;
+          history[cur_no_of_his_actions++].count=1;
+        }
     }
-        
+
   //sort history according to count
   qsort (history, cur_no_of_his_actions, sizeof(struct HISTORY), compare);
 
-  //write history vars to file  
+  //write history vars to file
   for(i=0;i<cur_no_of_his_actions;i++)
     {
       if(history[i].history_action != NULL)
           fprintf(fp,"%s  %d \n",gtk_action_get_name(history[i].history_action),
                                    history[i].count);
     }
- 
+
   fclose(fp);
 }
 
@@ -1002,10 +1002,10 @@ initializer(void)
   {
     history_file_path= g_new(gchar, 1024);
     strcpy(history_file_path,(gchar*)gimp_sysconf_directory());
-    
+
     preference_file_path= g_new(gchar,1024);
     strcpy(preference_file_path,(gchar*)gimp_sysconf_directory());
-    
+
     strcat(history_file_path,"/history_tito");
     strcat(preference_file_path,"/preferences_tito");
 
@@ -1017,27 +1017,27 @@ initializer(void)
       }
     first_time=FALSE;
   }
-  read_preferences();
-  read_history();
+  tito_read_preferences();
+  tito_read_history();
   gtk_accel_map_change_entry ("<Actions>/dialogs/dialogs-tito",'?',GDK_SHIFT_MASK,FALSE);
   return TRUE;
 }
 
-static void 
-clear_history(void)
+static void
+tito_clear_history (void)
 {
   FILE *fp;
-  fp = fopen(history_file_path,"w"); 
+  fp = fopen(history_file_path,"w");
   if(fp == NULL)
     {
-           g_message("file not created");
-           return;
+        g_message("file not created");
+        return;
     }
   fclose(fp);
 }
 
-static void 
-set_default_preferences(void)
+static void
+tito_set_default_preferences (void)
 {
  PREF.POSITION = 0;
  PREF.WIDTH = 40;
@@ -1045,14 +1045,14 @@ set_default_preferences(void)
  PREF.POSITION_Y = 0.04*gdk_screen_get_height(gdk_screen_get_default());
  PREF.NO_OF_RESULTS = 4;
  PREF.AUTO_HIDE = TRUE;
- PREF.SHOW_INSENSITIVE = TRUE; 
+ PREF.SHOW_INSENSITIVE = TRUE;
  PREF.OPACITY = 1;
- write_preferences();
+ tito_write_preferences();
 }
 
 
 static void
-update_preferences(void)
+tito_update_preferences (void)
 {
   if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(right_top_radio)))
     PREF.POSITION = 0;
@@ -1062,15 +1062,15 @@ update_preferences(void)
     {
       PREF.POSITION = 2;
       tmp_x = (gfloat) gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(pos_x_spin_button));
-      tmp_y = (gfloat) gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(pos_y_spin_button));      
+      tmp_y = (gfloat) gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(pos_y_spin_button));
     }
-  
+
   PREF.NO_OF_RESULTS    = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(no_of_results_spin_button));
   PREF.WIDTH            = (gfloat)gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(width_spin_button));
   PREF.OPACITY          = (gdouble)gtk_spin_button_get_value_as_int 
(GTK_SPIN_BUTTON(opacity_spin_button))/100;
   PREF.AUTO_HIDE        = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(autohide_check_button));
   PREF.SHOW_INSENSITIVE = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(show_insensitive_check_button));
-    
+
   if(PREF.POSITION == 0)
   {
     PREF.POSITION_X = (1-PREF.WIDTH/100)*gdk_screen_get_width(gdk_screen_get_default());
@@ -1086,68 +1086,77 @@ update_preferences(void)
     PREF.POSITION_X = tmp_x*gdk_screen_get_width(gdk_screen_get_default())/100;
     PREF.POSITION_Y = tmp_y*gdk_screen_get_height(gdk_screen_get_default())/100;
   }
-  write_preferences();
+  tito_write_preferences();
   finalizer();
 }
 
-static void 
-write_preferences(void)
+static void
+tito_write_preferences (void)
 {
  FILE *fp;
  fp=fopen(preference_file_path,"w");
  if(fp == NULL)
     return;
  fprintf(fp,"%d %f %f %d %f %d %d %lf", PREF.POSITION,PREF.POSITION_X, PREF.POSITION_Y,
-                                   PREF.NO_OF_RESULTS, PREF.WIDTH, 
PREF.AUTO_HIDE,PREF.SHOW_INSENSITIVE,PREF.OPACITY);
+                    PREF.NO_OF_RESULTS, PREF.WIDTH, PREF.AUTO_HIDE,PREF.SHOW_INSENSITIVE,PREF.OPACITY);
  fclose(fp);
 }
 
-static void 
-read_preferences(void)
+static void
+tito_read_preferences (void)
 {
  FILE *fp;
  fp=fopen(preference_file_path,"r");
  if(fp == NULL)
    {
-     set_default_preferences();
+     tito_set_default_preferences();
      return;
    }
  if(fscanf(fp,"%d %f %f %d %f %d %d %lf", &PREF.POSITION, &PREF.POSITION_X, &PREF.POSITION_Y,
-                                  &PREF.NO_OF_RESULTS, &PREF.WIDTH, &PREF.AUTO_HIDE, &PREF.SHOW_INSENSITIVE, 
&PREF.OPACITY) == 0)
-          set_default_preferences();
+                   &PREF.NO_OF_RESULTS, &PREF.WIDTH, &PREF.AUTO_HIDE, &PREF.SHOW_INSENSITIVE, &PREF.OPACITY) 
== 0)
+       tito_set_default_preferences();
  fclose(fp);
 }
 
+static gboolean
+context_menu_invoked  ( GtkWidget *widget,
+                        GdkEvent  *event,
+                        gpointer   user_data)
+{
+  context_menu();
+  return TRUE;
+}
+
+static void
+context_menu_handler( GtkMenuItem* menuitem,
+                      gpointer *data)
+{
+  if(strchr(gtk_menu_item_get_label(menuitem),'r')!=NULL)
+    tito_preferences_dialog();
+  else
+    gtk_widget_destroy(dialog);
+}
+
 static void
-context_menu(void)
+context_menu (void)
 {
   GtkWidget *preferences_menuitem;
-  GtkWidget *close_menuitem;  
+  GtkWidget *close_menuitem;
   GtkWidget *context_menu;
 
   context_menu = gtk_menu_new();
   preferences_menuitem =  gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES,NULL);
   close_menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE,NULL);
-  
+
   gtk_menu_shell_append (GTK_MENU_SHELL(context_menu), preferences_menuitem);
-  gtk_menu_shell_append (GTK_MENU_SHELL(context_menu), close_menuitem);  
-  
+  gtk_menu_shell_append (GTK_MENU_SHELL(context_menu), close_menuitem);
+
   gtk_widget_show(context_menu);
   gtk_widget_show(preferences_menuitem);
   gtk_widget_show(close_menuitem);
-      
+
   g_signal_connect (preferences_menuitem, "activate", G_CALLBACK (context_menu_handler), NULL);
-  g_signal_connect (close_menuitem, "activate", G_CALLBACK (context_menu_handler), NULL);  
+  g_signal_connect (close_menuitem, "activate", G_CALLBACK (context_menu_handler), NULL);
 
   gtk_menu_popup( GTK_MENU(context_menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
 }
-
-static void
-context_menu_handler( GtkMenuItem* menuitem,
-                      gpointer *data)
-{
-  if(strchr(gtk_menu_item_get_label(menuitem),'r')!=NULL)
-    preferences_dialog();
-  else
-    gtk_widget_destroy(dialog);
-}                      



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]