[pan2] * small fix for group colors (should hopefully work now) * use gtk_rc defaults for fg and bg colors



commit 09c1eba1a802d1adb05ea494851aa06cbe0c0e31
Author: Heinrich MÃller <heinrich mueller82 gmail com>
Date:   Sun May 20 14:26:02 2012 +0200

    * small fix for group colors (should hopefully work now)
    * use gtk_rc defaults for fg and bg colors as fallback (black/white otherwise)

 pan/gui/group-prefs-dialog.cc     |   23 ++++++++++++++---------
 pan/gui/group-prefs-dialog.h      |    2 ++
 pan/gui/gui.cc                    |    1 -
 pan/gui/prefs-ui.cc               |   22 ++++++++++++++++------
 pan/gui/prefs-ui.h                |    1 +
 pan/tasks/socket-impl-scripted.cc |    3 +--
 6 files changed, 34 insertions(+), 18 deletions(-)
---
diff --git a/pan/gui/group-prefs-dialog.cc b/pan/gui/group-prefs-dialog.cc
index 88c8052..9af45ca 100644
--- a/pan/gui/group-prefs-dialog.cc
+++ b/pan/gui/group-prefs-dialog.cc
@@ -131,7 +131,6 @@ GroupPrefsDialog :: save_from_gui ()
   }
 #endif
 
-  // group color
   foreach_const (quarks_v, _groups, it)
   {
     _group_prefs.set_group_color(*it, _color);
@@ -229,17 +228,23 @@ namespace
     return w;
   }
 
-  void color_set_cb (GtkColorButton* b, gpointer gp)
+  void color_set_cb (GtkColorButton* b, gpointer p)
   {
-    GdkColor* col = (GdkColor*)gp;
-	  gtk_color_button_get_color (b, col);
+    GroupPrefsDialog* dialog = static_cast<GroupPrefsDialog*>(p);
+	  GdkColor col;
+	  gtk_color_button_get_color (b, &(dialog->get_color()));
   }
 
-  GtkWidget* new_color_button (const Quark& group, GroupPrefs& prefs, GdkColor* color)
+  GtkWidget* new_color_button (const Quark& group, GroupPrefs& prefs, GroupPrefsDialog* dialog)
   {
-    const GdkColor& val (prefs.get_group_color (group, "black"));
+    GdkColor color;
+    GtkStyle *style = gtk_rc_get_style(dialog->root());
+    if(!gtk_style_lookup_color(style, "text_color", &color))
+      gdk_color_parse("black", &color);
+
+    const GdkColor& val (prefs.get_group_color (group, GroupPrefs::color_to_string(color)));
     GtkWidget * b = gtk_color_button_new_with_color (&val);
-    g_signal_connect (b, "color-set", G_CALLBACK(color_set_cb), color);
+    g_signal_connect (b, "color-set", G_CALLBACK(color_set_cb), dialog);
     return b;
   }
 
@@ -300,11 +305,11 @@ GroupPrefsDialog :: GroupPrefsDialog (Data            & data,
     w = _spellchecker_language = create_spellcheck_combo_box ( groups[0], group_prefs);
     HIG :: workarea_add_row (t, &row, _("Spellchecker _language:"), w);
 #endif
-    w = _group_color = new_color_button (groups[0], _group_prefs, &_color);
+    w = _group_color = new_color_button (groups[0], _group_prefs, this);
     HIG :: workarea_add_row(t, &row, _("Group color:"), w);
 
-  gtk_widget_show_all (t);
   gtk_box_pack_start ( GTK_BOX( gtk_dialog_get_content_area( GTK_DIALOG( dialog))), t, true, true, 0);
   _root = dialog;
+  gtk_widget_show_all (t);
 
 }
diff --git a/pan/gui/group-prefs-dialog.h b/pan/gui/group-prefs-dialog.h
index d755eda..89b9b34 100644
--- a/pan/gui/group-prefs-dialog.h
+++ b/pan/gui/group-prefs-dialog.h
@@ -59,6 +59,8 @@ namespace pan
     public:
       	 GdkColor& get_color() { return _color; }
       	 GtkWidget* get_color_button() { return _group_color; }
+      	 const quarks_v& get_groups() { return _groups; }
+      	 GroupPrefs& get_prefs() { return _group_prefs; }
   };
 }
 #endif
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 395b11c..c39c753 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -642,7 +642,6 @@ void GUI :: do_read_or_save_articles ()
     do_read_selected_article();
 }
 
-
 void GUI :: do_save_articles_to_nzb ()
 {
 
diff --git a/pan/gui/prefs-ui.cc b/pan/gui/prefs-ui.cc
index 5ef6326..a09ab1d 100644
--- a/pan/gui/prefs-ui.cc
+++ b/pan/gui/prefs-ui.cc
@@ -1117,25 +1117,35 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
   gtk_notebook_append_page (GTK_NOTEBOOK(notebook), t, new_label_with_icon(_("_Fonts"), _("Fonts"), icon_prefs_fonts, prefs));
 
   // Colors
+  GdkColor def_color, def_color_bg;
+  GtkStyle *style = gtk_rc_get_style(dialog);
+  if(!gtk_style_lookup_color(style, "text_color", &def_color))
+    gdk_color_parse("black", &def_color);
+  if(!gtk_style_lookup_color(style, "bg_color", &def_color_bg))
+    gdk_color_parse("white", &def_color_bg);
+
+  std::string def_color_str (GroupPrefs::color_to_string(def_color));
+  std::string def_color_bg_str (GroupPrefs::color_to_string(def_color_bg));
+
   row = 0;
   t = HIG :: workarea_create ();
   HIG :: workarea_add_section_title (t, &row, _("Header Pane"));
     HIG :: workarea_add_section_spacer(t, row, 6);
     h = gtk_hbox_new (false, PAD);
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Text:")));
-    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-watched-fg", "black", prefs));
+    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-watched-fg", def_color_str.c_str(), prefs));
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Background:")));
     pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-watched-bg", TANGO_CHAMELEON_LIGHT, prefs));
     HIG :: workarea_add_row (t, &row, _("Scores of 9999 or more:"), h);
     h = gtk_hbox_new (false, PAD);
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Text:")));
-    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-high-fg", "black", prefs));
+    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-high-fg", def_color_str.c_str(), prefs));
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Background:")));
     pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-high-bg", TANGO_BUTTER_LIGHT, prefs));
     HIG :: workarea_add_row (t, &row, _("Scores from 5000 to 9998:"), h);
     h = gtk_hbox_new (false, PAD);
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Text:")));
-    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-medium-fg", "black", prefs));
+    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-medium-fg", def_color_str.c_str(), prefs));
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Background:")));
     pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-medium-bg", TANGO_SKY_BLUE_LIGHT, prefs));
     HIG :: workarea_add_row (t, &row, _("Scores from 1 to 4999:"), h);
@@ -1143,19 +1153,19 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Text:")));
     pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-low-fg", TANGO_ALUMINUM_2, prefs));
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Background:")));
-    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-low-bg", "black", prefs));
+    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-low-bg", def_color_str.c_str(), prefs));
     HIG :: workarea_add_row (t, &row, _("Scores from -9998 to -1:"), h);
     h = gtk_hbox_new (false, PAD);
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Text:")));
     pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-ignored-fg", TANGO_ALUMINUM_4, prefs));
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Background:")));
-    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-ignored-bg", "black", prefs));
+    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("score-color-ignored-bg", def_color_str.c_str(), prefs));
     HIG :: workarea_add_row (t, &row, _("Scores of -9999 or less:"), h);
     h = gtk_hbox_new (false, PAD);
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Text:")));
     pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("color-read-fg", TANGO_ORANGE, prefs));
     pan_box_pack_start_defaults (GTK_BOX(h), gtk_label_new (_("Background:")));
-    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("color-read-bg", "white", prefs));
+    pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("color-read-bg", def_color_bg_str.c_str(), prefs));
     HIG :: workarea_add_row (t, &row, _("Read collapsed thread:"), h);
   HIG :: workarea_add_section_divider (t, &row);
   HIG :: workarea_add_section_title (t, &row, _("Body Pane"));
diff --git a/pan/gui/prefs-ui.h b/pan/gui/prefs-ui.h
index 6648a86..8eca180 100644
--- a/pan/gui/prefs-ui.h
+++ b/pan/gui/prefs-ui.h
@@ -22,6 +22,7 @@
 
 #include "gtk-compat.h"
 #include <pan/gui/prefs.h>
+#include <pan/gui/group-prefs.h>
 
 namespace pan
 {
diff --git a/pan/tasks/socket-impl-scripted.cc b/pan/tasks/socket-impl-scripted.cc
index 8aebfb1..fd472fb 100644
--- a/pan/tasks/socket-impl-scripted.cc
+++ b/pan/tasks/socket-impl-scripted.cc
@@ -45,8 +45,7 @@ ScriptedSocket :: open (const StringView& address UNUSED, int port UNUSED)
   return true;
 }
 
-void
-ScriptedSocket :: write_command (const StringView& chars, Listener * l)
+void ScriptedSocket :: write_command (const StringView& chars, Listener * l)
 {
    if (_script.empty()) {
       debug ("UNEXPECTED [" << chars << ']');



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