[gnome-commander] GnomeCmdData: more C++ rework



commit fb289c70e4c0baef74d057c7283ef320a7f0037a
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Thu Nov 10 21:55:24 2011 +0100

    GnomeCmdData: more C++ rework

 src/gnome-cmd-data.cc           |    6 ---
 src/gnome-cmd-data.h            |    3 --
 src/gnome-cmd-options-dialog.cc |   70 +++++++++++++++++++-------------------
 src/ls_colors.cc                |   36 ++++++++++----------
 4 files changed, 53 insertions(+), 62 deletions(-)
---
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 6b6c532..6762680 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -1732,12 +1732,6 @@ GnomeCmdColorTheme *gnome_cmd_data_get_custom_color_theme ()
 }
 
 
-GnomeCmdLsColorsPalette *gnome_cmd_data_get_ls_colors_palette ()
-{
-    return &gnome_cmd_data.options.ls_colors_palette;
-}
-
-
 const gchar *gnome_cmd_data_get_document_icon_dir ()
 {
     return gnome_cmd_data.options.document_icon_dir;
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 98969fd..f4e2767 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -97,7 +97,6 @@ struct GnomeCmdData
         gchar                  *theme_icon_dir;
         gchar                  *document_icon_dir;
 
-
         Options(): left_mouse_button_mode(LEFT_BUTTON_OPENS_WITH_DOUBLE_CLICK),
                    left_mouse_button_unselects(TRUE),
                    middle_mouse_button_mode(MIDDLE_BUTTON_GOES_UP_DIR),
@@ -372,8 +371,6 @@ void gnome_cmd_data_set_ftp_anonymous_password (const gchar *pw);
 GnomeCmdColorTheme *gnome_cmd_data_get_custom_color_theme ();
 GnomeCmdColorTheme *gnome_cmd_data_get_current_color_theme ();
 
-GnomeCmdLsColorsPalette *gnome_cmd_data_get_ls_colors_palette ();
-
 inline void GnomeCmdData::set_viewer(const gchar *command)
 {
     g_free (viewer);
diff --git a/src/gnome-cmd-options-dialog.cc b/src/gnome-cmd-options-dialog.cc
index 05ddfd8..a24f565 100644
--- a/src/gnome-cmd-options-dialog.cc
+++ b/src/gnome-cmd-options-dialog.cc
@@ -483,24 +483,24 @@ static void on_edit_ls_colors_cancel (GtkButton *btn, GtkWidget *dlg)
 
 static void on_edit_ls_colors_ok (GtkButton *btn, GtkWidget *dlg)
 {
-    GnomeCmdLsColorsPalette *palette = gnome_cmd_data_get_ls_colors_palette ();
-
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "black_fg")), palette->black_fg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "black_bg")), palette->black_bg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "red_fg")), palette->red_fg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "red_bg")), palette->red_bg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "green_fg")), palette->green_fg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "green_bg")), palette->green_bg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "yellow_fg")), palette->yellow_fg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "yellow_bg")), palette->yellow_bg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "blue_fg")), palette->blue_fg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "blue_bg")), palette->blue_bg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "magenta_fg")), palette->magenta_fg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "magenta_bg")), palette->magenta_bg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "cyan_fg")), palette->cyan_fg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "cyan_bg")), palette->cyan_bg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "white_fg")), palette->white_fg);
-    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "white_bg")), palette->white_bg);
+    GnomeCmdLsColorsPalette &palette = gnome_cmd_data.options.ls_colors_palette;
+
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "black_fg")), palette.black_fg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "black_bg")), palette.black_bg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "red_fg")), palette.red_fg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "red_bg")), palette.red_bg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "green_fg")), palette.green_fg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "green_bg")), palette.green_bg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "yellow_fg")), palette.yellow_fg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "yellow_bg")), palette.yellow_bg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "blue_fg")), palette.blue_fg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "blue_bg")), palette.blue_bg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "magenta_fg")), palette.magenta_fg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "magenta_bg")), palette.magenta_bg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "cyan_fg")), palette.cyan_fg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "cyan_bg")), palette.cyan_bg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "white_fg")), palette.white_fg);
+    gtk_color_button_get_color (GTK_COLOR_BUTTON (lookup_widget (dlg, "white_bg")), palette.white_bg);
 
     gtk_widget_destroy (dlg);
 }
@@ -547,7 +547,7 @@ static void on_ls_colors_edit (GtkButton *btn, GtkWidget *parent)
     GtkWidget *cat, *cat_box;
     GtkWidget *table, *label;
     GtkWidget *cbutton;
-    GnomeCmdLsColorsPalette *palette = gnome_cmd_data_get_ls_colors_palette ();
+    GnomeCmdLsColorsPalette &palette = gnome_cmd_data.options.ls_colors_palette;
 
     cat_box = create_vbox (dlg, FALSE, 12);
     cat = create_category (dlg, cat_box, _("Palette"));
@@ -558,52 +558,52 @@ static void on_ls_colors_edit (GtkButton *btn, GtkWidget *parent)
 
     cbutton = create_color_button (dlg, "black_fg");
     table_add (table, cbutton, 1, 1, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->black_fg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.black_fg);
     cbutton = create_color_button (dlg, "black_bg");
     table_add (table, cbutton, 1, 2, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->black_bg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.black_bg);
     cbutton = create_color_button (dlg, "red_fg");
     table_add (table, cbutton, 2, 1, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->red_fg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.red_fg);
     cbutton = create_color_button (dlg, "red_bg");
     table_add (table, cbutton, 2, 2, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->red_bg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.red_bg);
     cbutton = create_color_button (dlg, "green_fg");
     table_add (table, cbutton, 3, 1, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->green_fg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.green_fg);
     cbutton = create_color_button (dlg, "green_bg");
     table_add (table, cbutton, 3, 2, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->green_bg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.green_bg);
     cbutton = create_color_button (dlg, "yellow_fg");
     table_add (table, cbutton, 4, 1, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->yellow_fg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.yellow_fg);
     cbutton = create_color_button (dlg, "yellow_bg");
     table_add (table, cbutton, 4, 2, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->yellow_bg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.yellow_bg);
     cbutton = create_color_button (dlg, "blue_fg");
     table_add (table, cbutton, 5, 1, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->blue_fg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.blue_fg);
     cbutton = create_color_button (dlg, "blue_bg");
     table_add (table, cbutton, 5, 2, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->blue_bg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.blue_bg);
     cbutton = create_color_button (dlg, "magenta_fg");
     table_add (table, cbutton, 6, 1, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->magenta_fg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.magenta_fg);
     cbutton = create_color_button (dlg, "magenta_bg");
     table_add (table, cbutton, 6, 2, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->magenta_bg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.magenta_bg);
     cbutton = create_color_button (dlg, "cyan_fg");
     table_add (table, cbutton, 7, 1, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->cyan_fg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.cyan_fg);
     cbutton = create_color_button (dlg, "cyan_bg");
     table_add (table, cbutton, 7, 2, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->cyan_bg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.cyan_bg);
     cbutton = create_color_button (dlg, "white_fg");
     table_add (table, cbutton, 8, 1, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->white_fg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.white_fg);
     cbutton = create_color_button (dlg, "white_bg");
     table_add (table, cbutton, 8, 2, (GtkAttachOptions) 0);
-    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette->white_bg);
+    gtk_color_button_set_color (GTK_COLOR_BUTTON (cbutton), palette.white_bg);
 
     label = create_label (dlg, _("Foreground:"));
     table_add (table, label, 0, 1, (GtkAttachOptions) GTK_FILL);
diff --git a/src/ls_colors.cc b/src/ls_colors.cc
index a91fe05..aedf6d6 100644
--- a/src/ls_colors.cc
+++ b/src/ls_colors.cc
@@ -46,27 +46,27 @@ static LsColor *type_colors[8];
 */
 inline GdkColor *code2color (gint code)
 {
-    GnomeCmdLsColorsPalette *palette = gnome_cmd_data_get_ls_colors_palette ();
+    GnomeCmdLsColorsPalette &palette = gnome_cmd_data.options.ls_colors_palette;
 
     switch (code)
     {
-        case 30: return palette->black_fg;
-        case 31: return palette->red_fg;
-        case 32: return palette->green_fg;
-        case 33: return palette->yellow_fg;
-        case 34: return palette->blue_fg;
-        case 35: return palette->magenta_fg;
-        case 36: return palette->cyan_fg;
-        case 37: return palette->white_fg;
-
-        case 40: return palette->black_bg;
-        case 41: return palette->red_bg;
-        case 42: return palette->green_bg;
-        case 43: return palette->yellow_bg;
-        case 44: return palette->blue_bg;
-        case 45: return palette->magenta_bg;
-        case 46: return palette->cyan_bg;
-        case 47: return palette->white_bg;
+        case 30: return palette.black_fg;
+        case 31: return palette.red_fg;
+        case 32: return palette.green_fg;
+        case 33: return palette.yellow_fg;
+        case 34: return palette.blue_fg;
+        case 35: return palette.magenta_fg;
+        case 36: return palette.cyan_fg;
+        case 37: return palette.white_fg;
+
+        case 40: return palette.black_bg;
+        case 41: return palette.red_bg;
+        case 42: return palette.green_bg;
+        case 43: return palette.yellow_bg;
+        case 44: return palette.blue_bg;
+        case 45: return palette.magenta_bg;
+        case 46: return palette.cyan_bg;
+        case 47: return palette.white_bg;
     }
 
     return NULL;



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