gnome-commander r2458 - in trunk: . src



Author: epiotr
Date: Wed Feb 11 17:00:12 2009
New Revision: 2458
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2458&view=rev

Log:
GnomeCmdData: more C++ rework

Modified:
   trunk/ChangeLog
   trunk/src/gnome-cmd-data.cc
   trunk/src/gnome-cmd-data.h
   trunk/src/gnome-cmd-file-selector.cc
   trunk/src/gnome-cmd-file.cc
   trunk/src/gnome-cmd-options-dialog.cc
   trunk/src/gnome-cmd-user-actions.cc
   trunk/src/utils.cc

Modified: trunk/src/gnome-cmd-data.cc
==============================================================================
--- trunk/src/gnome-cmd-data.cc	(original)
+++ trunk/src/gnome-cmd-data.cc	Wed Feb 11 17:00:12 2009
@@ -68,11 +68,6 @@
     gchar                *symlink_prefix;
 
     gchar                *ftp_anonymous_password;
-
-    gchar *viewer;
-    gchar *editor;
-    gchar *differ;
-    gchar *term;
 };
 
 
@@ -1133,11 +1128,22 @@
     main_win_height = 400;
 
     main_win_state = GDK_WINDOW_STATE_MAXIMIZED;
+
+    viewer = NULL;
+    editor = NULL;
+    differ = NULL;
+    term = NULL;
 }
 
 
 void GnomeCmdData::free()
 {
+    // free the external programs strings
+    g_free (viewer);
+    g_free (editor);
+    g_free (differ);
+    g_free (term);
+
     if (priv)
     {
         // free the connections
@@ -1159,12 +1165,6 @@
         // free the font name strings
         g_free (priv->list_font);
 
-        // free the external programs strings
-        g_free (priv->viewer);
-        g_free (priv->editor);
-        g_free (priv->differ);
-        g_free (priv->term);
-
         g_free (priv);
     }
 }
@@ -1356,10 +1356,10 @@
     priv->sort_column[RIGHT] = gnome_cmd_data_get_int ("/options/sort_column_right", GnomeCmdFileList::COLUMN_NAME);
     priv->sort_direction[RIGHT] = gnome_cmd_data_get_bool ("/options/sort_direction_right", GTK_SORT_ASCENDING);
 
-    priv->viewer = gnome_cmd_data_get_string ("/programs/viewer", "gedit %s");
-    priv->editor = gnome_cmd_data_get_string ("/programs/editor", "gedit %s");
-    priv->differ = gnome_cmd_data_get_string ("/programs/differ", "meld %s");
-    priv->term   = gnome_cmd_data_get_string ("/programs/terminal", "xterm -hold -e %s");
+    viewer = gnome_cmd_data_get_string ("/programs/viewer", "gedit %s");
+    editor = gnome_cmd_data_get_string ("/programs/editor", "gedit %s");
+    differ = gnome_cmd_data_get_string ("/programs/differ", "meld %s");
+    term   = gnome_cmd_data_get_string ("/programs/terminal", "xterm -hold -e %s");
 
     use_gcmd_block = gnome_cmd_data_get_bool ("/programs/use_gcmd_block", FALSE);
 
@@ -1734,10 +1734,10 @@
     gnome_cmd_data_set_int    ("/options/sort_column_right", priv->sort_column[RIGHT]);
     gnome_cmd_data_set_bool   ("/options/sort_direction_right", priv->sort_direction[RIGHT]);
 
-    gnome_cmd_data_set_string ("/programs/viewer", priv->viewer);
-    gnome_cmd_data_set_string ("/programs/editor", priv->editor);
-    gnome_cmd_data_set_string ("/programs/differ", priv->differ);
-    gnome_cmd_data_set_string ("/programs/terminal", priv->term);
+    gnome_cmd_data_set_string ("/programs/viewer", viewer);
+    gnome_cmd_data_set_string ("/programs/editor", editor);
+    gnome_cmd_data_set_string ("/programs/differ", differ);
+    gnome_cmd_data_set_string ("/programs/terminal", term);
 
     gnome_cmd_data_set_bool   ("/programs/use_gcmd_block", use_gcmd_block);
 
@@ -1870,58 +1870,6 @@
 }
 
 
-void gnome_cmd_data_set_viewer (const gchar *command)
-{
-    g_free (gnome_cmd_data.priv->viewer);
-    gnome_cmd_data.priv->viewer = g_strdup (command);
-}
-
-
-void gnome_cmd_data_set_editor (const gchar *command)
-{
-    g_free (gnome_cmd_data.priv->editor);
-    gnome_cmd_data.priv->editor = g_strdup (command);
-}
-
-
-void gnome_cmd_data_set_differ (const gchar *command)
-{
-    g_free (gnome_cmd_data.priv->differ);
-    gnome_cmd_data.priv->differ = g_strdup (command);
-}
-
-
-void gnome_cmd_data_set_term (const gchar *term)
-{
-    g_free (gnome_cmd_data.priv->term);
-    gnome_cmd_data.priv->term = g_strdup (term);
-}
-
-
-const gchar *gnome_cmd_data_get_viewer ()
-{
-    return gnome_cmd_data.priv->viewer;
-}
-
-
-const gchar *gnome_cmd_data_get_editor ()
-{
-    return gnome_cmd_data.priv->editor;
-}
-
-
-const gchar *gnome_cmd_data_get_differ ()
-{
-    return gnome_cmd_data.priv->differ;
-}
-
-
-const gchar *gnome_cmd_data_get_term ()
-{
-    return gnome_cmd_data.priv->term;
-}
-
-
 const gchar *gnome_cmd_data_get_list_font ()
 {
     return gnome_cmd_data.priv->list_font;

Modified: trunk/src/gnome-cmd-data.h
==============================================================================
--- trunk/src/gnome-cmd-data.h	(original)
+++ trunk/src/gnome-cmd-data.h	Wed Feb 11 17:00:12 2009
@@ -126,6 +126,11 @@
 
     GnomeCmdConFtp              *quick_connect;
 
+    gchar *viewer;
+    gchar *editor;
+    gchar *differ;
+    gchar *term;
+
     void load_auto_load_plugins();
     void load_cmdline_history();
     void load_local_bookmarks();
@@ -205,6 +210,16 @@
 
     gboolean hide_type(GnomeVFSFileType type)     {  return filter_settings.file_types[type];  }
     GnomeCmdConFtp *get_quick_connect()           {  return quick_connect;                     }
+
+    const gchar *get_viewer()                     {  return viewer;                            }
+    const gchar *get_editor()                     {  return editor;                            }
+    const gchar *get_differ()                     {  return differ;                            }
+    const gchar *get_term()                       {  return term;                              }
+
+    void set_viewer(const gchar *command);
+    void set_editor(const gchar *command);
+    void set_differ(const gchar *command);
+    void set_term(const gchar *command);
 };
 
 gpointer gnome_cmd_data_get_con_list ();
@@ -226,20 +241,33 @@
 void gnome_cmd_data_get_sort_params (GnomeCmdFileList *fl, gint &col, gboolean &direction);
 void gnome_cmd_data_set_sort_params (GnomeCmdFileList *fl, gint col, gboolean direction);
 
-const gchar *gnome_cmd_data_get_viewer ();
-const gchar *gnome_cmd_data_get_editor ();
-const gchar *gnome_cmd_data_get_differ ();
-
-void gnome_cmd_data_set_viewer (const gchar *command);
-void gnome_cmd_data_set_editor (const gchar *command);
-void gnome_cmd_data_set_differ (const gchar *command);
+inline void GnomeCmdData::set_viewer(const gchar *command)
+{
+    g_free (viewer);
+    viewer = g_strdup (command);
+}
+
+inline void GnomeCmdData::set_editor(const gchar *command)
+{
+    g_free (editor);
+    editor = g_strdup (command);
+}
+
+inline void GnomeCmdData::set_differ(const gchar *command)
+{
+    g_free (differ);
+    differ = g_strdup (command);
+}
+
+inline void GnomeCmdData::set_term(const gchar *command)
+{
+    g_free (term);
+    term = g_strdup (command);
+}
 
 const gchar *gnome_cmd_data_get_list_font ();
 void gnome_cmd_data_set_list_font (const gchar *list_font);
 
-const gchar *gnome_cmd_data_get_term ();
-void gnome_cmd_data_set_term (const gchar *shell);
-
 const gchar *gnome_cmd_data_get_theme_icon_dir ();
 void gnome_cmd_data_set_theme_icon_dir (const gchar *dir);
 

Modified: trunk/src/gnome-cmd-file-selector.cc
==============================================================================
--- trunk/src/gnome-cmd-file-selector.cc	(original)
+++ trunk/src/gnome-cmd-file-selector.cc	Wed Feb 11 17:00:12 2009
@@ -1318,7 +1318,7 @@
         return;
 
     // create a command with an empty argument to the editor
-    gchar *cmd = g_strdup_printf (gnome_cmd_data_get_editor (), "");
+    gchar *cmd = g_strdup_printf (gnome_cmd_data.get_editor(), "");
     gchar *dpath = gnome_cmd_file_get_real_path (GNOME_CMD_FILE (fs->file_list()->cwd));
 
     run_command_indir (cmd, dpath, FALSE);
@@ -1685,7 +1685,7 @@
     g_return_val_if_fail (filepath, TRUE);
 
     escaped_filepath = g_strdup_printf ("\"%s\"", filepath);
-    cmd = g_strdup_printf (gnome_cmd_data_get_editor (), escaped_filepath);
+    cmd = g_strdup_printf (gnome_cmd_data.get_editor(), escaped_filepath);
     g_free (filepath);
     g_free (escaped_filepath);
 

Modified: trunk/src/gnome-cmd-file.cc
==============================================================================
--- trunk/src/gnome-cmd-file.cc	(original)
+++ trunk/src/gnome-cmd-file.cc	Wed Feb 11 17:00:12 2009
@@ -725,7 +725,7 @@
 
         case FALSE: {
                         gchar *filename = gnome_cmd_file_get_quoted_real_path (f);
-                        gchar *command = g_strdup_printf (gnome_cmd_data_get_viewer (), filename);
+                        gchar *command = g_strdup_printf (gnome_cmd_data.get_viewer(), filename);
                         run_command (command, FALSE);
                         g_free (filename);
                     }
@@ -790,7 +790,7 @@
 
     gchar *fpath = gnome_cmd_file_get_quoted_real_path (f);
     gchar *dpath = gnome_cmd_file_get_unescaped_dirname (f);
-    gchar *command = g_strdup_printf (gnome_cmd_data_get_editor (), fpath);
+    gchar *command = g_strdup_printf (gnome_cmd_data.get_editor(), fpath);
 
     run_command_indir (command, dpath, FALSE);
 

Modified: trunk/src/gnome-cmd-options-dialog.cc
==============================================================================
--- trunk/src/gnome-cmd-options-dialog.cc	(original)
+++ trunk/src/gnome-cmd-options-dialog.cc	Wed Feb 11 17:00:12 2009
@@ -1314,17 +1314,17 @@
     label = create_label (parent, _("Terminal:"));
     table_add (table, label, 0, 4, GTK_FILL);
 
-    entry = create_entry (parent, "viewer", gnome_cmd_data_get_viewer());
+    entry = create_entry (parent, "viewer", gnome_cmd_data.get_viewer());
     table_add (table, entry, 1, 0, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
 
     check = create_check (parent, _("Use Internal Viewer"), "use_internal_viewer");
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), gnome_cmd_data.use_internal_viewer);
     table_add (table, check, 1, 1, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
-    entry = create_entry (parent, "editor", gnome_cmd_data_get_editor());
+    entry = create_entry (parent, "editor", gnome_cmd_data.get_editor());
     table_add (table, entry, 1, 2, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
-    entry = create_entry (parent, "differ", gnome_cmd_data_get_differ());
+    entry = create_entry (parent, "differ", gnome_cmd_data.get_differ());
     table_add (table, entry, 1, 3, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
-    entry = create_entry (parent, "term", gnome_cmd_data_get_term());
+    entry = create_entry (parent, "term", gnome_cmd_data.get_term());
     table_add (table, entry, 1, 4, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
 
 
@@ -1386,10 +1386,10 @@
     GtkWidget *check_uris = lookup_widget (GTK_WIDGET (dialog), "honor_expect_uris");
     GtkWidget *check_iv = lookup_widget (GTK_WIDGET (dialog), "use_internal_viewer");
 
-    gnome_cmd_data_set_viewer (gtk_entry_get_text (GTK_ENTRY (entry1)));
-    gnome_cmd_data_set_editor (gtk_entry_get_text (GTK_ENTRY (entry2)));
-    gnome_cmd_data_set_differ (gtk_entry_get_text (GTK_ENTRY (entry3)));
-    gnome_cmd_data_set_term (gtk_entry_get_text (GTK_ENTRY (entry5)));
+    gnome_cmd_data.set_viewer(gtk_entry_get_text (GTK_ENTRY (entry1)));
+    gnome_cmd_data.set_editor(gtk_entry_get_text (GTK_ENTRY (entry2)));
+    gnome_cmd_data.set_differ(gtk_entry_get_text (GTK_ENTRY (entry3)));
+    gnome_cmd_data.set_term(gtk_entry_get_text (GTK_ENTRY (entry5)));
 
     gnome_cmd_data.honor_expect_uris = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_uris));
     gnome_cmd_data.use_internal_viewer = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_iv));

Modified: trunk/src/gnome-cmd-user-actions.cc
==============================================================================
--- trunk/src/gnome-cmd-user-actions.cc	(original)
+++ trunk/src/gnome-cmd-user-actions.cc	Wed Feb 11 17:00:12 2009
@@ -827,7 +827,7 @@
 
     if (!s.empty())
     {
-        gchar *cmd = g_strdup_printf (gnome_cmd_data_get_differ (), s.c_str(), "");
+        gchar *cmd = g_strdup_printf (gnome_cmd_data.get_differ(), s.c_str(), "");
 
         g_print (_("running `%s'\n"), cmd);
         run_command (cmd, FALSE);
@@ -864,7 +864,7 @@
     g_free (active_dir);
     g_free (inactive_dir);
 
-    gchar *cmd = g_strdup_printf (gnome_cmd_data_get_differ (), s.c_str(), "");
+    gchar *cmd = g_strdup_printf (gnome_cmd_data.get_differ(), s.c_str(), "");
 
     g_print (_("running `%s'\n"), cmd);
     run_command (cmd, FALSE);

Modified: trunk/src/utils.cc
==============================================================================
--- trunk/src/utils.cc	(original)
+++ trunk/src/utils.cc	Wed Feb 11 17:00:12 2009
@@ -131,7 +131,7 @@
         else
             arg = g_shell_quote (in_command);
 
-        command = g_strdup_printf (gnome_cmd_data_get_term (), arg);
+        command = g_strdup_printf (gnome_cmd_data.get_term(), arg);
 
         g_free (arg);
     }



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