gnome-commander r2459 - in branches/gcmd-1-3: . src



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

Log:
GnomeCmdData: more C++ rework

Modified:
   branches/gcmd-1-3/ChangeLog
   branches/gcmd-1-3/src/gnome-cmd-data.cc
   branches/gcmd-1-3/src/gnome-cmd-data.h
   branches/gcmd-1-3/src/gnome-cmd-file-selector.cc
   branches/gcmd-1-3/src/gnome-cmd-file.cc
   branches/gcmd-1-3/src/gnome-cmd-options-dialog.cc
   branches/gcmd-1-3/src/gnome-cmd-user-actions.cc
   branches/gcmd-1-3/src/utils.cc

Modified: branches/gcmd-1-3/src/gnome-cmd-data.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-data.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-data.cc	Wed Feb 11 17:21:34 2009
@@ -68,11 +68,6 @@
     gchar                *symlink_prefix;
 
     gchar                *ftp_anonymous_password;
-
-    gchar *viewer;
-    gchar *editor;
-    gchar *differ;
-    gchar *term;
     gchar *mime_editor;
 };
 
@@ -1134,11 +1129,23 @@
     main_win_height = 400;
 
     main_win_state = GDK_WINDOW_STATE_MAXIMIZED;
+
+    viewer = NULL;
+    editor = NULL;
+    differ = NULL;
+    term = NULL;
+    mime_editor = 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
@@ -1160,11 +1167,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->mime_editor);
 
         g_free (priv);
@@ -1358,11 +1360,11 @@
     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");
-    priv->mime_editor   = gnome_cmd_data_get_string ("/programs/mime_editor", "gnome-file-types-properties");
+    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");
+    mime_editor   = gnome_cmd_data_get_string ("/programs/mime_editor", "gnome-file-types-properties");
 
     use_gcmd_block = gnome_cmd_data_get_bool ("/programs/use_gcmd_block", FALSE);
 
@@ -1737,11 +1739,11 @@
     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/mime_editor", priv->mime_editor);
+    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_string ("/programs/mime_editor", mime_editor);
 
     gnome_cmd_data_set_bool   ("/programs/use_gcmd_block", use_gcmd_block);
 
@@ -1874,71 +1876,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);
-}
-
-
-void gnome_cmd_data_set_mime_editor (const gchar *mime_editor)
-{
-    g_free (gnome_cmd_data.priv->mime_editor);
-    gnome_cmd_data.priv->mime_editor = g_strdup (mime_editor);
-}
-
-
-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_mime_editor ()
-{
-    return gnome_cmd_data.priv->mime_editor;
-}
-
-
 const gchar *gnome_cmd_data_get_list_font ()
 {
     return gnome_cmd_data.priv->list_font;

Modified: branches/gcmd-1-3/src/gnome-cmd-data.h
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-data.h	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-data.h	Wed Feb 11 17:21:34 2009
@@ -126,6 +126,12 @@
 
     GnomeCmdConFtp              *quick_connect;
 
+    gchar *viewer;
+    gchar *editor;
+    gchar *differ;
+    gchar *term;
+    gchar *mime_editor;
+
     void load_auto_load_plugins();
     void load_cmdline_history();
     void load_local_bookmarks();
@@ -205,6 +211,18 @@
 
     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;                              }
+    const gchar *get_mime_editor()                {  return mime_editor;                       }
+
+    void set_viewer(const gchar *command);
+    void set_editor(const gchar *command);
+    void set_differ(const gchar *command);
+    void set_term(const gchar *command);
+    void set_mime_editor(const gchar *command);
 };
 
 gpointer gnome_cmd_data_get_con_list ();
@@ -226,20 +244,39 @@
 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);
+}
+
+inline void GnomeCmdData::set_mime_editor(const gchar *command)
+{
+    g_free (mime_editor);
+    mime_editor = 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_mime_editor ();
 void gnome_cmd_data_set_mime_editor (const gchar *shell);
 

Modified: branches/gcmd-1-3/src/gnome-cmd-file-selector.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file-selector.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file-selector.cc	Wed Feb 11 17:21:34 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: branches/gcmd-1-3/src/gnome-cmd-file.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file.cc	Wed Feb 11 17:21:34 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: branches/gcmd-1-3/src/gnome-cmd-options-dialog.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-options-dialog.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-options-dialog.cc	Wed Feb 11 17:21:34 2009
@@ -1316,19 +1316,19 @@
     label = create_label (parent, _("MIME editor:"));
     table_add (table, label, 0, 5, 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));
-    entry = create_entry (parent, "mime_editor", gnome_cmd_data_get_mime_editor());
+    entry = create_entry (parent, "mime_editor", gnome_cmd_data.get_mime_editor());
     table_add (table, entry, 1, 5, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
 
 
@@ -1391,11 +1391,11 @@
     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_mime_editor (gtk_entry_get_text (GTK_ENTRY (entry6)));
+    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_mime_editor(gtk_entry_get_text (GTK_ENTRY (entry6)));
 
     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: branches/gcmd-1-3/src/gnome-cmd-user-actions.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-user-actions.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-user-actions.cc	Wed Feb 11 17:21:34 2009
@@ -828,7 +828,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);
@@ -865,7 +865,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: branches/gcmd-1-3/src/utils.cc
==============================================================================
--- branches/gcmd-1-3/src/utils.cc	(original)
+++ branches/gcmd-1-3/src/utils.cc	Wed Feb 11 17:21:34 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);
     }
@@ -1266,7 +1266,7 @@
     if (!mime_type)
         mime_type = "";
 
-    string cmd = gnome_cmd_data_get_mime_editor ();
+    string cmd = gnome_cmd_data.get_mime_editor();
     cmd += " " + stringify(g_shell_quote (mime_type));
 
     if (blocking)



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