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



Author: epiotr
Date: Mon Jan 12 18:48:27 2009
New Revision: 2415
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2415&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-list.cc
   branches/gcmd-1-3/src/gnome-cmd-file-props-dialog.cc
   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-xfer-progress-win.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	Mon Jan 12 18:48:27 2009
@@ -51,8 +51,6 @@
 {
     GnomeCmdConList      *con_list;
     GList                *fav_apps;
-    GnomeCmdSizeDispMode size_disp_mode;
-    GnomeCmdPermDispMode perm_disp_mode;
     GnomeCmdDateFormat   date_format;           // NOTE: internally stored as locale (which not always defaults to UTF8), needs converting from/to UTF8 for editing and cfg load/save
     GnomeCmdLayout       layout;
     GnomeCmdColorTheme   color_themes[GNOME_CMD_NUM_COLOR_MODES];
@@ -62,7 +60,6 @@
     gchar                *document_icon_dir;
     guint                bookmark_dialog_col_width[BOOKMARK_DIALOG_NUM_COLUMNS];
     gint                 dir_cache_size;
-    gboolean             use_ls_colors;
     gboolean             honor_expect_uris;
     gboolean             use_internal_viewer;
     gboolean             skip_mounting;
@@ -1097,6 +1094,8 @@
     confirm_move_overwrite = GNOME_CMD_CONFIRM_OVERWRITE_QUERY;
     right_mouse_button_mode = RIGHT_BUTTON_POPUPS_MENU;
     color_mode = GNOME_CMD_COLOR_DEEP_BLUE;
+    size_disp_mode = GNOME_CMD_SIZE_DISP_MODE_POWERED;
+    perm_disp_mode = GNOME_CMD_PERM_DISP_MODE_TEXT;
     alt_quick_search = FALSE;
 
     filter_type = Filter::TYPE_FNMATCH;
@@ -1114,6 +1113,8 @@
     cmdline_visibility = TRUE;
     buttonbar_visibility = TRUE;
 
+    use_ls_colors = FALSE;
+
     icon_size = 16;
     dev_icon_size = 16;
     device_only_icon = FALSE;
@@ -1250,8 +1251,8 @@
     priv->color_themes[GNOME_CMD_COLOR_NONE].curs_fg = NULL;
     priv->color_themes[GNOME_CMD_COLOR_NONE].curs_bg = NULL;
 
-    priv->size_disp_mode = (GnomeCmdSizeDispMode) gnome_cmd_data_get_int ("/options/size_disp_mode", GNOME_CMD_SIZE_DISP_MODE_POWERED);
-    priv->perm_disp_mode = (GnomeCmdPermDispMode) gnome_cmd_data_get_int ("/options/perm_disp_mode", GNOME_CMD_PERM_DISP_MODE_TEXT);
+    size_disp_mode = (GnomeCmdSizeDispMode) gnome_cmd_data_get_int ("/options/size_disp_mode", GNOME_CMD_SIZE_DISP_MODE_POWERED);
+    perm_disp_mode = (GnomeCmdPermDispMode) gnome_cmd_data_get_int ("/options/perm_disp_mode", GNOME_CMD_PERM_DISP_MODE_TEXT);
 
 #ifdef HAVE_LOCALE_H
     gchar *utf8_date_format = gnome_cmd_data_get_string ("/options/date_disp_mode", "%x %R");
@@ -1367,7 +1368,7 @@
 
     device_only_icon = gnome_cmd_data_get_bool ("/devices/only_icon", FALSE);
     priv->dir_cache_size = gnome_cmd_data_get_int ("/options/dir_cache_size", 10);
-    priv->use_ls_colors = gnome_cmd_data_get_bool ("/colors/use_ls_colors", FALSE);
+    use_ls_colors = gnome_cmd_data_get_bool ("/colors/use_ls_colors", FALSE);
 
     priv->start_dirs[LEFT] = gnome_cmd_data_get_string ("/options/start_dir_left", g_get_home_dir ());
     priv->start_dirs[RIGHT] = gnome_cmd_data_get_string ("/options/start_dir_right", g_get_home_dir ());
@@ -1659,8 +1660,8 @@
         g_free (tmp);
     }
 
-    gnome_cmd_data_set_int    ("/options/size_disp_mode", priv->size_disp_mode);
-    gnome_cmd_data_set_int    ("/options/perm_disp_mode", priv->perm_disp_mode);
+    gnome_cmd_data_set_int    ("/options/size_disp_mode", size_disp_mode);
+    gnome_cmd_data_set_int    ("/options/perm_disp_mode", perm_disp_mode);
     gnome_cmd_data_set_int    ("/options/layout", priv->layout);
     gnome_cmd_data_set_int    ("/options/list_row_height", list_row_height);
 
@@ -1746,7 +1747,7 @@
 
     gnome_cmd_data_set_bool   ("/devices/only_icon", device_only_icon);
     gnome_cmd_data_set_int    ("/options/dir_cache_size", priv->dir_cache_size);
-    gnome_cmd_data_set_bool   ("/colors/use_ls_colors", priv->use_ls_colors);
+    gnome_cmd_data_set_bool   ("/colors/use_ls_colors", use_ls_colors);
 
     const gchar *quick_connect_uri = gnome_cmd_con_get_uri (GNOME_CMD_CON (quick_connect));
 
@@ -1846,30 +1847,6 @@
 }
 
 
-GnomeCmdSizeDispMode gnome_cmd_data_get_size_disp_mode ()
-{
-    return gnome_cmd_data.priv->size_disp_mode;
-}
-
-
-void
-gnome_cmd_data_set_size_disp_mode (GnomeCmdSizeDispMode mode)
-{
-    gnome_cmd_data.priv->size_disp_mode = mode;
-}
-
-
-GnomeCmdPermDispMode gnome_cmd_data_get_perm_disp_mode ()
-{
-    return gnome_cmd_data.priv->perm_disp_mode;
-}
-
-void gnome_cmd_data_set_perm_disp_mode (GnomeCmdPermDispMode mode)
-{
-    gnome_cmd_data.priv->perm_disp_mode = mode;
-}
-
-
 GnomeCmdDateFormat gnome_cmd_data_get_date_format ()
 {
     return gnome_cmd_data.priv->date_format;
@@ -2051,18 +2028,6 @@
 }
 
 
-gboolean gnome_cmd_data_get_use_ls_colors ()
-{
-    return gnome_cmd_data.priv->use_ls_colors;
-}
-
-
-void gnome_cmd_data_set_use_ls_colors (gboolean value)
-{
-    gnome_cmd_data.priv->use_ls_colors = value;
-}
-
-
 GnomeCmdBookmarkGroup *gnome_cmd_data_get_local_bookmarks ()
 {
     return gnome_cmd_con_get_bookmarks (gnome_cmd_con_list_get_home (gnome_cmd_data.priv->con_list));

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	Mon Jan 12 18:48:27 2009
@@ -147,6 +147,8 @@
     GnomeCmdConfirmOverwriteMode confirm_move_overwrite;
     RightMouseButtonMode         right_mouse_button_mode;
     GnomeCmdColorMode            color_mode;
+    GnomeCmdSizeDispMode         size_disp_mode;
+    GnomeCmdPermDispMode         perm_disp_mode;
     gboolean                     alt_quick_search;
 
     Filter::Type                 filter_type;
@@ -166,6 +168,8 @@
     gboolean                     cmdline_visibility;
     gboolean                     buttonbar_visibility;
 
+    gboolean                     use_ls_colors;
+
     guint                        icon_size;
     guint                        dev_icon_size;
     gboolean                     device_only_icon;
@@ -207,12 +211,6 @@
 const gchar *gnome_cmd_data_get_ftp_anonymous_password ();
 void gnome_cmd_data_set_ftp_anonymous_password (const gchar *pw);
 
-GnomeCmdSizeDispMode gnome_cmd_data_get_size_disp_mode ();
-void gnome_cmd_data_set_size_disp_mode (GnomeCmdSizeDispMode mode);
-
-GnomeCmdPermDispMode gnome_cmd_data_get_perm_disp_mode ();
-void gnome_cmd_data_set_perm_disp_mode (GnomeCmdPermDispMode mode);
-
 GnomeCmdDateFormat gnome_cmd_data_get_date_format ();
 void gnome_cmd_data_set_date_format (GnomeCmdDateFormat format);
 
@@ -257,9 +255,6 @@
 gint gnome_cmd_data_get_dir_cache_size ();
 void gnome_cmd_data_set_dir_cache_size (gint size);
 
-gboolean gnome_cmd_data_get_use_ls_colors ();
-void gnome_cmd_data_set_use_ls_colors (gboolean value);
-
 GnomeCmdBookmarkGroup *gnome_cmd_data_get_local_bookmarks ();
 GList *gnome_cmd_data_get_bookmark_groups ();
 

Modified: branches/gcmd-1-3/src/gnome-cmd-file-list.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file-list.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file-list.cc	Mon Jan 12 18:48:27 2009
@@ -336,7 +336,7 @@
         return;
 
 
-    if (!gnome_cmd_data_get_use_ls_colors ())
+    if (!gnome_cmd_data.use_ls_colors)
         gtk_clist_set_row_style (*fl, row, row%2 ? alt_sel_list_style : sel_list_style);
     else
     {
@@ -373,7 +373,7 @@
     gnome_cmd_file_unref (finfo);
     fl->priv->selected_files = g_list_remove (fl->priv->selected_files, finfo);
 
-    if (!gnome_cmd_data_get_use_ls_colors ())
+    if (!gnome_cmd_data.use_ls_colors)
         gtk_clist_set_row_style (*fl, row, row%2 ? alt_list_style : list_style);
     else
         if (LsColor *col = ls_colors_get (finfo))
@@ -1374,7 +1374,7 @@
     gint row = in_row == -1 ? gtk_clist_append (clist, data.text) : gtk_clist_insert (clist, in_row, data.text);
 
     // Setup row data and color
-    if (!gnome_cmd_data_get_use_ls_colors ())
+    if (!gnome_cmd_data.use_ls_colors)
         gtk_clist_set_row_style (clist, row, row%2 ? alt_list_style : list_style);
     else
     {

Modified: branches/gcmd-1-3/src/gnome-cmd-file-props-dialog.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file-props-dialog.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file-props-dialog.cc	Mon Jan 12 18:48:27 2009
@@ -66,12 +66,11 @@
 inline const gchar *get_size_disp_string (GnomeVFSFileSize size)
 {
     static gchar s[64];
-    GnomeCmdSizeDispMode mode = gnome_cmd_data_get_size_disp_mode ();
 
-    if (mode == GNOME_CMD_SIZE_DISP_MODE_POWERED)
+    if (gnome_cmd_data.size_disp_mode == GNOME_CMD_SIZE_DISP_MODE_POWERED)
         return create_nice_size_str (size);
 
-    snprintf (s, sizeof (s), ngettext("%s byte","%s bytes",size), size2string (size, mode));
+    snprintf (s, sizeof (s), ngettext("%s byte","%s bytes",size), size2string (size, gnome_cmd_data.size_disp_mode));
     return s;
 }
 

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	Mon Jan 12 18:48:27 2009
@@ -155,7 +155,7 @@
     gint num_sel_files = 0;
     gint num_sel_dirs = 0;
 
-    GnomeCmdSizeDispMode size_mode = gnome_cmd_data_get_size_disp_mode ();
+    GnomeCmdSizeDispMode size_mode = gnome_cmd_data.size_disp_mode;
     if (size_mode==GNOME_CMD_SIZE_DISP_MODE_POWERED)
         size_mode = GNOME_CMD_SIZE_DISP_MODE_GROUPED;
 

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	Mon Jan 12 18:48:27 2009
@@ -548,7 +548,7 @@
     if (file->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
         return dir_indicator;
 
-    return size2string (file->info->size, gnome_cmd_data_get_size_disp_mode ());
+    return size2string (file->info->size, gnome_cmd_data.size_disp_mode);
 }
 
 
@@ -584,7 +584,7 @@
     if (strcmp (file->info->name, "..") == 0)
         return gnome_cmd_file_get_size (file);
 
-    return size2string (gnome_cmd_file_get_tree_size (file), gnome_cmd_data_get_size_disp_mode());
+    return size2string (gnome_cmd_file_get_tree_size (file), gnome_cmd_data.size_disp_mode);
 }
 
 

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	Mon Jan 12 18:48:27 2009
@@ -206,23 +206,23 @@
     // Translators: 'Powered' refers to the mode of file size display (here - display using units of data: kB, MB, GB, ...)
     radio = create_radio (parent, NULL, _("Powered"), "size_powered_radio");
     gtk_container_add (GTK_CONTAINER (cat_box), radio);
-    if (gnome_cmd_data_get_size_disp_mode () == GNOME_CMD_SIZE_DISP_MODE_POWERED)
+    if (gnome_cmd_data.size_disp_mode == GNOME_CMD_SIZE_DISP_MODE_POWERED)
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
 
     // Translators: '<locale>' refers to the mode of file size display (here - use current locale settings)
     radio = create_radio (parent, get_radio_group (radio), _("<locale>"), "size_locale_radio");
     gtk_container_add (GTK_CONTAINER (cat_box), radio);
-    if (gnome_cmd_data_get_size_disp_mode () == GNOME_CMD_SIZE_DISP_MODE_LOCALE)
+    if (gnome_cmd_data.size_disp_mode == GNOME_CMD_SIZE_DISP_MODE_LOCALE)
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
 
     radio = create_radio (parent, get_radio_group (radio), _("Grouped"), "size_grouped_radio");
     gtk_container_add (GTK_CONTAINER (cat_box), radio);
-    if (gnome_cmd_data_get_size_disp_mode () == GNOME_CMD_SIZE_DISP_MODE_GROUPED)
+    if (gnome_cmd_data.size_disp_mode == GNOME_CMD_SIZE_DISP_MODE_GROUPED)
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
 
     radio = create_radio (parent, get_radio_group (radio), _("Plain"), "size_plain_radio");
     gtk_container_add (GTK_CONTAINER (cat_box), radio);
-    if (gnome_cmd_data_get_size_disp_mode () == GNOME_CMD_SIZE_DISP_MODE_PLAIN)
+    if (gnome_cmd_data.size_disp_mode == GNOME_CMD_SIZE_DISP_MODE_PLAIN)
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
 
 
@@ -233,12 +233,12 @@
 
     radio = create_radio (parent, NULL, _("Text (rw-r--r--)"), "perm_text_radio");
     gtk_container_add (GTK_CONTAINER (cat_box), radio);
-    if (gnome_cmd_data_get_perm_disp_mode () == GNOME_CMD_PERM_DISP_MODE_TEXT)
+    if (gnome_cmd_data.perm_disp_mode == GNOME_CMD_PERM_DISP_MODE_TEXT)
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
 
     radio = create_radio (parent, get_radio_group (radio), _("Number (644)"), "perm_num_radio");
     gtk_container_add (GTK_CONTAINER (cat_box), radio);
-    if (gnome_cmd_data_get_perm_disp_mode () == GNOME_CMD_PERM_DISP_MODE_NUMBER)
+    if (gnome_cmd_data.perm_disp_mode == GNOME_CMD_PERM_DISP_MODE_NUMBER)
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
 
 
@@ -286,18 +286,18 @@
     const gchar *format = gtk_entry_get_text (GTK_ENTRY (entry));
 
     if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (size_powered_radio)))
-        gnome_cmd_data_set_size_disp_mode (GNOME_CMD_SIZE_DISP_MODE_POWERED);
+        gnome_cmd_data.size_disp_mode = GNOME_CMD_SIZE_DISP_MODE_POWERED;
     else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (size_locale_radio)))
-        gnome_cmd_data_set_size_disp_mode (GNOME_CMD_SIZE_DISP_MODE_LOCALE);
+        gnome_cmd_data.size_disp_mode = GNOME_CMD_SIZE_DISP_MODE_LOCALE;
     else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (size_grouped_radio)))
-        gnome_cmd_data_set_size_disp_mode (GNOME_CMD_SIZE_DISP_MODE_GROUPED);
+        gnome_cmd_data.size_disp_mode = GNOME_CMD_SIZE_DISP_MODE_GROUPED;
     else
-        gnome_cmd_data_set_size_disp_mode (GNOME_CMD_SIZE_DISP_MODE_PLAIN);
+        gnome_cmd_data.size_disp_mode = GNOME_CMD_SIZE_DISP_MODE_PLAIN;
 
     if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (perm_text_radio)))
-        gnome_cmd_data_set_perm_disp_mode (GNOME_CMD_PERM_DISP_MODE_TEXT);
+        gnome_cmd_data.perm_disp_mode = GNOME_CMD_PERM_DISP_MODE_TEXT;
     else
-        gnome_cmd_data_set_perm_disp_mode (GNOME_CMD_PERM_DISP_MODE_NUMBER);
+        gnome_cmd_data.perm_disp_mode = GNOME_CMD_PERM_DISP_MODE_NUMBER;
 
     gnome_cmd_data_set_date_format (g_locale_from_utf8 (format, -1, NULL, NULL, NULL));
 }
@@ -545,7 +545,7 @@
 
     // LS_COLORS
     check = create_check (parent, _("Colorize files according to the LS_COLORS environment variable"), "use_ls_colors");
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), gnome_cmd_data_get_use_ls_colors());
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), gnome_cmd_data.use_ls_colors);
     gtk_table_attach (GTK_TABLE (table), check, 0, 2, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
 
 
@@ -602,7 +602,7 @@
         (GnomeCmdLayout) gtk_option_menu_get_history (GTK_OPTION_MENU (lm_optmenu)));
     gnome_cmd_data.color_mode = (GnomeCmdColorMode) gtk_option_menu_get_history (GTK_OPTION_MENU (cm_optmenu));
 
-    gnome_cmd_data_set_use_ls_colors (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (use_ls)));
+    gnome_cmd_data.use_ls_colors = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (use_ls));
 
     const gchar *list_font = gtk_font_button_get_font_name (GTK_FONT_BUTTON (list_font_picker));
     gnome_cmd_data_set_list_font (list_font);

Modified: branches/gcmd-1-3/src/gnome-cmd-xfer-progress-win.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-xfer-progress-win.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-xfer-progress-win.cc	Mon Jan 12 18:48:27 2009
@@ -169,8 +169,8 @@
         gtk_progress_set_percentage (GTK_PROGRESS (win->fileprog), file_prog);
     }
 
-    gchar *bytes_total_str = g_strdup (size2string (bytes_total, gnome_cmd_data_get_size_disp_mode()));
-    const gchar *bytes_copied_str = size2string (bytes_copied, gnome_cmd_data_get_size_disp_mode());
+    gchar *bytes_total_str = g_strdup (size2string (bytes_total, gnome_cmd_data.size_disp_mode));
+    const gchar *bytes_copied_str = size2string (bytes_copied, gnome_cmd_data.size_disp_mode);
 
     gchar text[128];
 

Modified: branches/gcmd-1-3/src/utils.cc
==============================================================================
--- branches/gcmd-1-3/src/utils.cc	(original)
+++ branches/gcmd-1-3/src/utils.cc	Mon Jan 12 18:48:27 2009
@@ -307,7 +307,7 @@
 
 const gchar *perm2string (GnomeVFSFilePermissions p, gchar *buf, guint max)
 {
-    switch (gnome_cmd_data_get_perm_disp_mode ())
+    switch (gnome_cmd_data.perm_disp_mode)
     {
         case GNOME_CMD_PERM_DISP_MODE_TEXT:
             return perm2textstring (p, buf, max);



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