[pan2] - fixes https://bugzilla.gnome.org/show_bug.cgi?id=681037 - fixes https://bugzilla.gnome.org/show_bu
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2] - fixes https://bugzilla.gnome.org/show_bug.cgi?id=681037 - fixes https://bugzilla.gnome.org/show_bu
- Date: Sun, 23 Sep 2012 07:40:23 +0000 (UTC)
commit cf68577fea0ede2e1143de4a80a27023e1c48723
Author: Heinrich MÃller <henmull src gnome org>
Date: Sun Sep 23 09:33:59 2012 +0200
- fixes https://bugzilla.gnome.org/show_bug.cgi?id=681037
- fixes https://bugzilla.gnome.org/show_bug.cgi?id=673813
- some cleanups
pan/general/Makefile.am | 1 -
pan/general/typedefs.h | 30 -------------
pan/gui/body-pane.cc | 12 ++++-
pan/gui/group-pane.cc | 2 +-
pan/gui/gui.cc | 7 +++-
pan/gui/gui.h | 3 +
pan/gui/header-pane.cc | 105 +++++++++++++++++++++++++++++++++++++++++------
pan/gui/header-pane.h | 9 ++++-
pan/gui/prefs-ui.cc | 11 ++++-
pan/gui/render-bytes.cc | 19 ++++++++
10 files changed, 149 insertions(+), 50 deletions(-)
---
diff --git a/pan/general/Makefile.am b/pan/general/Makefile.am
index 8fe2db7..1bd5a1d 100644
--- a/pan/general/Makefile.am
+++ b/pan/general/Makefile.am
@@ -36,7 +36,6 @@ noinst_HEADERS = \
time-elapsed.h \
utf8-utils.h \
worker-pool.h \
- typedefs.h \
singleton-template.h
#noinst_PROGRAMS = \
diff --git a/pan/gui/body-pane.cc b/pan/gui/body-pane.cc
index 4eeeeb3..fd61e00 100644
--- a/pan/gui/body-pane.cc
+++ b/pan/gui/body-pane.cc
@@ -495,7 +495,8 @@ namespace
set_text_buffer_tags (GtkTextBuffer * buffer, const Prefs& p)
{
const PanColors& colors (PanColors::get());
- const std::string& bg (colors.def_bg);
+ const std::string fg (p.get_color_str ("text-color-fg", colors.def_fg));
+ const std::string bg (p.get_color_str ("text-color-bg", colors.def_bg));
GtkTextTagTable * table = gtk_text_buffer_get_tag_table (buffer);
@@ -532,6 +533,10 @@ namespace
"foreground", p.get_color_str ("body-pane-color-signature", TANGO_SKY_BLUE_LIGHT).c_str(),
"background", p.get_color_str ("body-pane-color-signature-bg", bg).c_str(),
NULL);
+ g_object_set (get_or_create_tag (table, "text"),
+ "foreground", p.get_color_str ("text-color-fg", fg).c_str(),
+ "background", p.get_color_str ("text-color-bg", bg).c_str(),
+ NULL);
}
}
@@ -768,6 +773,9 @@ namespace
StringView v(body), line;
GtkTextIter mark_start (start);
+ // colorize text
+ gtk_text_buffer_apply_tag_by_name (buffer, "text", &mark_start, &end);
+
// find where the signature begins...
const char * sig_point (0);
int offset (0);
@@ -2106,7 +2114,7 @@ BodyPane :: on_prefs_string_changed (const StringView& key, const StringView& va
void
BodyPane :: on_prefs_color_changed (const StringView& key, const GdkColor& color G_GNUC_UNUSED)
{
- if (key.strstr ("body-pane-color") != 0)
+ if (key == "body-pane-color" || key == "font-color-fg" || key == "font-color-bg")
refresh_colors ();
}
diff --git a/pan/gui/group-pane.cc b/pan/gui/group-pane.cc
index e6f8a6c..e074b67 100644
--- a/pan/gui/group-pane.cc
+++ b/pan/gui/group-pane.cc
@@ -1041,6 +1041,6 @@ void
GroupPane :: on_prefs_color_changed (const StringView& key, const GdkColor&)
{
if (key == "group-color")
- refresh_font ();
refresh_dirty_groups ();
+ refresh_font ();
}
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 137e8f0..528a73b 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -2237,9 +2237,14 @@ GUI :: set_queue_size_label (unsigned int running,
g_snprintf (str, sizeof(str), "%s: %u/%u", _("Tasks"), running, size);
// build the tooltip
- // todo : perhaps fix this for mac osx automatically....
+ // FIX : build fix for 64bit osx which doesn't seem to have guint64t nor gulong :(
+#ifdef G_OS_DARWIN
+ unsigned long queued, unused, stopped;
+ uint64_t KiB_remain;
+#else
gulong queued, unused, stopped;
guint64 KiB_remain;
+#endif
double KiBps;
int hr, min, sec;
_queue.get_stats (queued, unused, stopped,
diff --git a/pan/gui/gui.h b/pan/gui/gui.h
index 80b871b..ff3cfd2 100644
--- a/pan/gui/gui.h
+++ b/pan/gui/gui.h
@@ -280,6 +280,9 @@ namespace pan
static void root_realized_cb (GtkWidget*, gpointer self_gpointer);
+ public:
+ BodyPane* body_pane() { return _body_pane; }
+
private:
static void add_widget (GtkUIManager*, GtkWidget*, gpointer);
static void server_list_dialog_destroyed_cb (GtkWidget*, gpointer);
diff --git a/pan/gui/header-pane.cc b/pan/gui/header-pane.cc
index 6aba02c..3139a53 100644
--- a/pan/gui/header-pane.cc
+++ b/pan/gui/header-pane.cc
@@ -59,6 +59,14 @@ namespace
};
}
+namespace
+{
+ // default color theme's Colors
+ const PanColors& colors (PanColors::get());
+ const char* def_color_str (colors.def_bg.c_str());
+ const char* def_color_fg_str (colors.def_fg.c_str());
+}
+
const Article*
HeaderPane :: get_article (GtkTreeModel* model, GtkTreeIter* iter)
{
@@ -226,20 +234,25 @@ HeaderPane :: render_score (GtkTreeViewColumn * ,
const Prefs& prefs (self->_prefs);
std::string bg, fg;
if (score >= 9999) {
- fg = prefs.get_color_str ("score-color-watched-fg", "black");
+ fg = prefs.get_color_str ("score-color-watched-fg", def_color_fg_str);
bg = prefs.get_color_str ("score-color-watched-bg", TANGO_CHAMELEON_LIGHT);
} else if (score >= 5000) {
- fg = prefs.get_color_str ("score-color-high-fg", "black");
+ fg = prefs.get_color_str ("score-color-high-fg", def_color_fg_str);
bg = prefs.get_color_str ("score-color-high-bg", TANGO_BUTTER_LIGHT);
} else if (score >= 1) {
- fg = prefs.get_color_str ("score-color-medium-fg", "black");
+ fg = prefs.get_color_str ("score-color-medium-fg", def_color_fg_str);
bg = prefs.get_color_str ("score-color-medium-bg", TANGO_SKY_BLUE_LIGHT);
} else if (score <= -9999) {
fg = prefs.get_color_str ("score-color-ignored-fg", TANGO_ALUMINUM_4);
- bg = prefs.get_color_str ("score-color-ignored-bg", "black");
+ bg = prefs.get_color_str ("score-color-ignored-bg", def_color_str);
} else if (score <= -1) {
fg = prefs.get_color_str ("score-color-low-fg", TANGO_ALUMINUM_2);
- bg = prefs.get_color_str ("score-color-low-bg", "black");
+ bg = prefs.get_color_str ("score-color-low-bg", def_color_str);
+ }
+ else if (score == 0)
+ {
+ fg = self->_fg;
+ bg = self->_bg;
}
g_object_set (renderer, "text", buf,
@@ -262,22 +275,70 @@ HeaderPane :: render_author (GtkTreeViewColumn * ,
const Article * a (self->get_article (model, iter));
char* ret = __g_mime_iconv_strdup(conv, a->author.c_str());
- if (ret) g_object_set (renderer, "text", ret, NULL);
+ if (ret) g_object_set (renderer, "text", ret,
+ "background", self->_bg.c_str(),
+ "foreground", self->_fg.c_str(),
+ NULL);
g_free(ret);
}
void
+HeaderPane :: render_lines (GtkTreeViewColumn * ,
+ GtkCellRenderer * renderer,
+ GtkTreeModel * model,
+ GtkTreeIter * iter,
+ gpointer user_data)
+{
+
+ const HeaderPane * self (static_cast<HeaderPane*>(user_data));
+
+ unsigned long lines(0ul);
+ std::stringstream str;
+
+ gtk_tree_model_get (model, iter, COL_LINES, &lines, -1);
+ str << lines;
+
+ g_object_set (renderer, "text", str.str().c_str(),
+ "background", self->_bg.c_str(),
+ "foreground", self->_fg.c_str(),
+ NULL);
+}
+
+void
HeaderPane :: render_bytes (GtkTreeViewColumn * ,
GtkCellRenderer * renderer,
GtkTreeModel * model,
GtkTreeIter * iter,
- gpointer )
+ gpointer userdata)
{
+ const HeaderPane * self (static_cast<HeaderPane*>(userdata));
+
unsigned long bytes (0);
gtk_tree_model_get (model, iter, COL_BYTES, &bytes, -1);
- g_object_set (renderer, "text", pan::render_bytes(bytes), NULL);
+ g_object_set (renderer,
+ "text", pan::render_bytes(bytes),
+ "background", self->_bg.c_str(),
+ "foreground", self->_fg.c_str(),
+ NULL);
}
+void
+HeaderPane :: render_date (GtkTreeViewColumn * ,
+ GtkCellRenderer * renderer,
+ GtkTreeModel * model,
+ GtkTreeIter * iter,
+ gpointer userdata)
+{
+ const HeaderPane * self (static_cast<HeaderPane*>(userdata));
+
+ gchar* date (0);
+ gtk_tree_model_get (model, iter, COL_DATE_STR, &date, -1);
+ g_object_set (renderer,
+ "text", date,
+ "background", self->_bg.c_str(),
+ "foreground", self->_fg.c_str(),
+ NULL);
+}
struct HeaderPane::CountUnread: public PanTreeStore::WalkFunctor
{
@@ -346,8 +407,8 @@ HeaderPane :: render_subject (GtkTreeViewColumn * ,
g_object_set (renderer,
"text", res.c_str(),
"weight", (bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL),
- "foreground", unread ? (def_fg.empty() ? NULL : def_fg.c_str()) : NULL,
- "background", unread ? (def_bg.empty() ? NULL : def_bg.c_str()) : NULL, NULL);
+ "foreground", unread ? (def_fg.empty() ? self->_fg.c_str() : def_fg.c_str()) : self->_fg.c_str(),
+ "background", unread ? (def_bg.empty() ? self->_bg.c_str() : def_bg.c_str()) : self->_bg.c_str(), NULL);
}
@@ -1726,11 +1787,12 @@ HeaderPane :: build_tree_columns ()
"xalign", 1.0,
NULL));
ellipsize_if_supported (G_OBJECT(r));
- col = gtk_tree_view_column_new_with_attributes (_("Lines"), r, "text", COL_LINES, NULL);
+ col = gtk_tree_view_column_new_with_attributes (_("Lines"), r, NULL);
gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_fixed_width (col, _prefs.get_int (width_key, 60));
gtk_tree_view_column_set_resizable (col, true);
gtk_tree_view_column_set_sort_column_id (col, COL_LINES);
+ gtk_tree_view_column_set_cell_data_func (col, r, render_lines, this, 0);
gtk_tree_view_append_column (tree_view, col);
}
else if (name == "bytes")
@@ -1756,11 +1818,12 @@ HeaderPane :: build_tree_columns ()
"ypad", 0,
NULL));
ellipsize_if_supported (G_OBJECT(r));
- col = gtk_tree_view_column_new_with_attributes (_("Date"), r, "text", COL_DATE_STR, NULL);
+ col = gtk_tree_view_column_new_with_attributes (_("Date"), r, NULL);
gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_fixed_width (col, _prefs.get_int (width_key, 120));
gtk_tree_view_column_set_resizable (col, true);
gtk_tree_view_column_set_sort_column_id (col, COL_DATE);
+ gtk_tree_view_column_set_cell_data_func (col, r, render_date, this, 0);
gtk_tree_view_append_column (tree_view, col);
}
@@ -1923,8 +1986,11 @@ HeaderPane :: HeaderPane (ActionManager & action_manager,
_selection_changed_idle_tag (0),
_cache (cache),
_gui (gui),
- _cleared (true)
+ _cleared (true),
+ _fg(prefs.get_color_str ("text-color-fg", def_color_fg_str)),
+ _bg(prefs.get_color_str ("text-color-bg", def_color_str))
{
+
// init the icons
for (guint i=0; i<ICON_QTY; ++i)
_icons[i].pixbuf = gdk_pixbuf_new_from_inline (-1, _icons[i].pixbuf_txt, FALSE, 0);
@@ -2405,6 +2471,19 @@ HeaderPane :: on_prefs_string_changed (const StringView& key, const StringView&)
build_tree_columns ();
}
+void
+HeaderPane :: on_prefs_color_changed (const StringView& key, const GdkColor&)
+{
+ if (key == "text-color-fg" || key == "text-color-bg")
+ {
+ _fg = _prefs.get_color_str ("text-color-fg", def_color_fg_str).c_str();
+ _bg = _prefs.get_color_str ("text-color-bg", def_color_str).c_str();
+ refresh_font();
+ build_tree_columns();
+ }
+
+}
+
/***
****
***/
diff --git a/pan/gui/header-pane.h b/pan/gui/header-pane.h
index 024e523..15fa499 100644
--- a/pan/gui/header-pane.h
+++ b/pan/gui/header-pane.h
@@ -35,6 +35,7 @@
#include <pan/gui/group-prefs.h>
#include <pan/gui/wait.h>
#include <pan/gui/gui.h>
+#include <pan/gui/body-pane.h>
namespace pan
{
@@ -150,7 +151,7 @@ namespace pan
virtual void on_prefs_flag_changed (const StringView&, bool);
virtual void on_prefs_int_changed (const StringView&, int) { }
virtual void on_prefs_string_changed (const StringView&, const StringView&);
- virtual void on_prefs_color_changed (const StringView&, const GdkColor&) {}
+ virtual void on_prefs_color_changed (const StringView&, const GdkColor&);
public:
virtual void on_article_flag_changed (articles_t& a, const Quark& group);
@@ -322,6 +323,10 @@ namespace pan
Data::ShowType _show_type;
guint _selection_changed_idle_tag;
+ // default text colors, updated on prefs change
+ std::string _fg;
+ std::string _bg;
+
private:
void rebuild_filter (const std::string&, int);
void rebuild_rules (bool enable=false);
@@ -361,6 +366,8 @@ namespace pan
static RenderFunc render_bytes;
static RenderFunc render_subject;
static RenderFunc render_author;
+ static RenderFunc render_lines;
+ static RenderFunc render_date;
private:
Row* get_row (const Quark& message_id);
diff --git a/pan/gui/prefs-ui.cc b/pan/gui/prefs-ui.cc
index e6806c3..00ad2d3 100644
--- a/pan/gui/prefs-ui.cc
+++ b/pan/gui/prefs-ui.cc
@@ -1166,7 +1166,7 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
HIG :: workarea_finish (t, &row);
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), t, new_label_with_icon(_("_Fonts"), _("Fonts"), icon_prefs_fonts, prefs));
- // Colors
+ // default color theme's Colors
const PanColors& colors (PanColors::get());
const char* def_color_str (colors.def_bg.c_str());
const char* def_color_fg_str (colors.def_fg.c_str());
@@ -1233,6 +1233,14 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
HIG :: workarea_add_row (t, &row, _("Signature:"), h);
HIG :: workarea_finish (t, &row);
+ // colors for others texts (score == 0 or body pane etc.... )
+ HIG :: workarea_add_section_title (t, &row, _("Other Texts"));
+ h = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, PAD_SMALL);
+ pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("text-color-fg", def_color_fg_str, prefs));
+ pan_box_pack_start_defaults (GTK_BOX(h), new_color_button ("text-color-bg", def_color_str, prefs));
+ HIG :: workarea_add_row (t, &row, _("Text Color:"), h);
+ HIG :: workarea_finish (t, &row);
+
HIG :: workarea_add_section_divider (t, &row);
HIG :: workarea_add_section_title (t, &row, _("Group Pane"));
HIG :: workarea_add_section_spacer (t, row, 1);
@@ -1298,6 +1306,7 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
_root = dialog;
+ // initially set notebook to page 1 or last selected page from last visit
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), prefs.get_int("prefs-last-selected-page",1));
}
diff --git a/pan/gui/render-bytes.cc b/pan/gui/render-bytes.cc
index f1b513a..b7b80da 100644
--- a/pan/gui/render-bytes.cc
+++ b/pan/gui/render-bytes.cc
@@ -1,3 +1,22 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Pan - A Newsreader for Gtk+
+ * Copyright (C) 2002-2006 Charles Kerr <charles rebelbase com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
#include <glib.h> // g_snprintf
#include "render-bytes.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]