[pan2: 10/23] Gtk3 compatibility finished.
- From: Petr Kovář <pmkovar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2: 10/23] Gtk3 compatibility finished.
- Date: Sun, 29 May 2011 13:04:23 +0000 (UTC)
commit be826863f4669358b9ec92d4e39d04b40ba0e059
Author: K. Haley <haleykd users sf net>
Date: Wed May 11 22:53:10 2011 -0600
Gtk3 compatibility finished.
pan/gui/body-pane.cc | 24 +++++++++++++++++++-----
pan/gui/e-charset-combo-box.c | 2 +-
pan/gui/e-charset-dialog.c | 2 +-
pan/gui/group-pane.cc | 17 ++++++++++++++---
pan/gui/gtk_compat.h | 33 +++++++++++++++++++++++++++++++++
pan/gui/gui.cc | 4 ++--
pan/gui/header-pane.cc | 14 ++++++++++++--
pan/gui/pan.cc | 2 +-
pan/gui/post-ui.cc | 2 +-
pan/gui/profiles-dialog.cc | 6 +++---
pan/gui/save-ui.cc | 1 +
pan/gui/score-add-ui.cc | 9 +++++----
pan/gui/score-view-ui.cc | 3 ++-
pan/gui/score-view-ui.h | 2 +-
pan/gui/server-ui.cc | 1 +
pan/gui/task-pane.h | 2 +-
16 files changed, 98 insertions(+), 26 deletions(-)
---
diff --git a/pan/gui/body-pane.cc b/pan/gui/body-pane.cc
index 026b295..3901914 100644
--- a/pan/gui/body-pane.cc
+++ b/pan/gui/body-pane.cc
@@ -24,6 +24,7 @@
extern "C" {
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+ #include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <gmime/gmime.h>
}
@@ -41,6 +42,7 @@ extern "C" {
#include "tango-colors.h"
#include "xface.h"
#include "url.h"
+#include "gtk_compat.h"
#define FIRST_PICTURE "first-picture"
@@ -171,8 +173,9 @@ namespace
GdkDisplay * display (gtk_widget_get_display (w));
int width, height;
- GtkStyle * style (gtk_widget_get_style (w));
const GtkIconSize size (GTK_ICON_SIZE_LARGE_TOOLBAR);
+#if !GTK_CHECK_VERSION(3,0,0)
+ GtkStyle * style (gtk_widget_get_style (w));
const GtkTextDirection dir (GTK_TEXT_DIR_NONE);
const GtkStateType state (GTK_STATE_PRELIGHT);
@@ -187,6 +190,17 @@ namespace
g_object_get (G_OBJECT(pixbuf), "width", &width, "height", &height, NULL);
cursors[CURSOR_ZOOM_OUT] = gdk_cursor_new_from_pixbuf (display, pixbuf, width/2, height/2);
g_object_unref (G_OBJECT(pixbuf));
+#else
+ GdkPixbuf * pixbuf = gtk_widget_render_icon_pixbuf (w, GTK_STOCK_ZOOM_IN, size);
+ g_object_get (G_OBJECT(pixbuf), "width", &width, "height", &height, NULL);
+ cursors[CURSOR_ZOOM_IN] = gdk_cursor_new_from_pixbuf (display, pixbuf, width/2, height/2);
+ g_object_unref (G_OBJECT(pixbuf));
+
+ pixbuf = gtk_widget_render_icon_pixbuf (w, GTK_STOCK_ZOOM_OUT, size);
+ g_object_get (G_OBJECT(pixbuf), "width", &width, "height", &height, NULL);
+ cursors[CURSOR_ZOOM_OUT] = gdk_cursor_new_from_pixbuf (display, pixbuf, width/2, height/2);
+ g_object_unref (G_OBJECT(pixbuf));
+#endif
cursors[CURSOR_IBEAM] = gdk_cursor_new (GDK_XTERM);
cursors[CURSOR_HREF] = gdk_cursor_new (GDK_HAND2);
@@ -484,8 +498,8 @@ namespace
gboolean handled (false);
g_return_val_if_fail (GTK_IS_TEXT_VIEW(w), false);
- const bool up = event->keyval==GDK_Up || event->keyval==GDK_KP_Up;
- const bool down = event->keyval==GDK_Down || event->keyval==GDK_KP_Down;
+ const bool up = event->keyval==GDK_KEY_Up || event->keyval==GDK_KEY_KP_Up;
+ const bool down = event->keyval==GDK_KEY_Down || event->keyval==GDK_KEY_KP_Down;
if (up || down)
{
@@ -1706,13 +1720,13 @@ BodyPane :: refresh_fonts ()
const bool monospace_font_enabled = _prefs.get_flag ("monospace-font-enabled", false);
if (!body_pane_font_enabled && !monospace_font_enabled)
- gtk_widget_modify_font (_text, 0);
+ gtk_widget_override_font (_text, 0);
else {
const std::string str (monospace_font_enabled
? _prefs.get_string ("monospace-font", "Monospace 10")
: _prefs.get_string ("body-pane-font", "Sans 10"));
PangoFontDescription * pfd (pango_font_description_from_string (str.c_str()));
- gtk_widget_modify_font (_text, pfd);
+ gtk_widget_override_font (_text, pfd);
pango_font_description_free (pfd);
}
}
diff --git a/pan/gui/e-charset-combo-box.c b/pan/gui/e-charset-combo-box.c
index 4110d39..2fe1948 100644
--- a/pan/gui/e-charset-combo-box.c
+++ b/pan/gui/e-charset-combo-box.c
@@ -100,7 +100,7 @@ charset_combo_box_run_dialog (ECharsetComboBox *combo_box)
dialog = GTK_DIALOG (widget);
- gtk_dialog_set_has_separator (dialog, FALSE);
+ //gtk_dialog_set_has_separator (dialog, FALSE);
gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
diff --git a/pan/gui/e-charset-dialog.c b/pan/gui/e-charset-dialog.c
index 6a27024..4d4fcb5 100644
--- a/pan/gui/e-charset-dialog.c
+++ b/pan/gui/e-charset-dialog.c
@@ -50,7 +50,7 @@ e_charset_dialog (const char *title, const char *prompt,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL));
- gtk_dialog_set_has_separator (dialog, FALSE);
+ //gtk_dialog_set_has_separator (dialog, FALSE);
gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
vbox = gtk_vbox_new (FALSE, 6);
diff --git a/pan/gui/group-pane.cc b/pan/gui/group-pane.cc
index 7e49f0b..378cf92 100644
--- a/pan/gui/group-pane.cc
+++ b/pan/gui/group-pane.cc
@@ -33,6 +33,7 @@ extern "C" {
#include <pan/data/data.h>
#include "group-pane.h"
#include "pad.h"
+#include "gtk_compat.h"
using namespace pan;
@@ -566,7 +567,11 @@ namespace
GdkEventFocus * ,
gpointer )
{
+#if !GTK_CHECK_VERSION(3,0,0)
gtk_widget_modify_text (w, GTK_STATE_NORMAL, NULL); // resets
+#else
+ gtk_widget_override_color(w, GTK_STATE_FLAG_NORMAL, NULL);
+#endif
set_search_entry (w, search_text.c_str());
return false;
}
@@ -575,10 +580,16 @@ namespace
{
if (search_text.empty() && !gtk_widget_has_focus(w))
{
+#if !GTK_CHECK_VERSION(3,0,0)
GdkColor c;
c.pixel = 0;
- c.red = c.green = c.blue = 0xAAAA; // light grey
+ c.red = c.green = c.blue = 0xAAAA;
gtk_widget_modify_text (w, GTK_STATE_NORMAL, &c);
+#else
+ GdkRGBA c;
+ gdk_rgba_parse (&c, "0xAAA");
+ gtk_widget_override_color(w, GTK_STATE_FLAG_NORMAL, &c);
+#endif
set_search_entry (w, _(mode_strings[mode]));
}
}
@@ -969,11 +980,11 @@ void
GroupPane :: refresh_font ()
{
if (!_prefs.get_flag ("group-pane-font-enabled", false))
- gtk_widget_modify_font (_tree_view, 0);
+ gtk_widget_override_font (_tree_view, 0);
else {
const std::string str (_prefs.get_string ("group-pane-font", "Sans 10"));
PangoFontDescription * pfd (pango_font_description_from_string (str.c_str()));
- gtk_widget_modify_font (_tree_view, pfd);
+ gtk_widget_override_font (_tree_view, pfd);
pango_font_description_free (pfd);
}
}
diff --git a/pan/gui/gtk_compat.h b/pan/gui/gtk_compat.h
index c10e1df..3867e9b 100644
--- a/pan/gui/gtk_compat.h
+++ b/pan/gui/gtk_compat.h
@@ -78,6 +78,39 @@ namespace
gtk_combo_box_remove_text(cb, p);
}
#endif
+
+#if !GTK_CHECK_VERSION(3,0,0)
+#ifndef GDK_KEY_Up
+#define GDK_KEY_Up GDK_Up
+#define GDK_KEY_KP_Up GDK_KP_Up
+#define GDK_KEY_Down GDK_Down
+#define GDK_KEY_KP_Down GDK_KP_Down
+#endif
+ typedef GtkStyle GtkStyleContext;
+ GtkStyleContext* gtk_widget_get_style_context(GtkWidget *w)
+ {
+ return gtk_widget_get_style(w);
+ }
+ GtkIconSet* gtk_style_context_lookup_icon_set(GtkStyleContext *s,
+ const char *id)
+ {
+
+ return gtk_style_lookup_icon_set(s,id);
+ }
+ void gtk_widget_override_font(GtkWidget *w, PangoFontDescription *f)
+ {
+ gtk_widget_modify_font(w,f);
+ }
+#endif
+#if GTK_CHECK_VERSION(3,0,0)
+#define GTK_OBJECT(w) w
+ typedef GtkWidget GtkObject;
+ void gdk_cursor_unref(GdkCursor *p)
+ {
+ g_object_unref(p);
+ }
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index fe11ecb..2494a19 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -85,7 +85,7 @@ namespace
}
void
- parent_set_cb (GtkWidget * widget, GtkObject *, gpointer ui_manager_g)
+ parent_set_cb (GtkWidget * widget, GtkWidget *, gpointer ui_manager_g)
{
GtkWidget * toplevel = gtk_widget_get_toplevel (widget);
if (GTK_IS_WINDOW (toplevel))
@@ -252,7 +252,7 @@ GUI :: GUI (Data& data, Queue& queue, ArticleCache& cache, Prefs& prefs, GroupPr
w = _queue_size_button = gtk_button_new();
gtk_widget_set_tooltip_text (w, _("Open the Task Manager"));
gtk_button_set_relief (GTK_BUTTON(w), GTK_RELIEF_NONE);
- g_signal_connect (GTK_OBJECT(w), "clicked", G_CALLBACK(show_task_window_cb), this);
+ g_signal_connect (w, "clicked", G_CALLBACK(show_task_window_cb), this);
gtk_container_add (GTK_CONTAINER(w), _queue_size_label);
frame = gtk_frame_new (NULL);
gtk_container_set_border_width (GTK_CONTAINER(frame), 0);
diff --git a/pan/gui/header-pane.cc b/pan/gui/header-pane.cc
index d2525f8..6f2b330 100644
--- a/pan/gui/header-pane.cc
+++ b/pan/gui/header-pane.cc
@@ -1196,7 +1196,11 @@ namespace
GdkEventFocus * ,
gpointer )
{
+#if !GTK_CHECK_VERSION(3,0,0)
gtk_widget_modify_text (w, GTK_STATE_NORMAL, NULL); // resets
+#else
+ gtk_widget_override_color (w, GTK_STATE_FLAG_NORMAL, NULL);
+#endif
set_search_entry (w, search_text.c_str());
return false;
}
@@ -1205,10 +1209,16 @@ namespace
{
if (search_text.empty() && !gtk_widget_has_focus(w))
{
+#if !GTK_CHECK_VERSION(3,0,0)
GdkColor c;
c.pixel = 0;
c.red = c.green = c.blue = 0xAAAA;
gtk_widget_modify_text (w, GTK_STATE_NORMAL, &c);
+#else
+ GdkRGBA c;
+ gdk_rgba_parse (&c, "0xAAA");
+ gtk_widget_override_color(w, GTK_STATE_FLAG_NORMAL, &c);
+#endif
set_search_entry (w, _(mode_strings[mode]));
}
}
@@ -2000,11 +2010,11 @@ void
HeaderPane :: refresh_font ()
{
if (!_prefs.get_flag ("header-pane-font-enabled", false))
- gtk_widget_modify_font (_tree_view, 0);
+ gtk_widget_override_font (_tree_view, 0);
else {
const std::string str (_prefs.get_string ("header-pane-font", "Sans 10"));
PangoFontDescription * pfd (pango_font_description_from_string (str.c_str()));
- gtk_widget_modify_font (_tree_view, pfd);
+ gtk_widget_override_font (_tree_view, pfd);
pango_font_description_free (pfd);
}
}
diff --git a/pan/gui/pan.cc b/pan/gui/pan.cc
index 3e50861..117cb03 100644
--- a/pan/gui/pan.cc
+++ b/pan/gui/pan.cc
@@ -108,7 +108,7 @@ namespace
Queue * queue;
};
- void add_grouplist_task (GtkObject *, gpointer user_data)
+ void add_grouplist_task (GtkWidget *, gpointer user_data)
{
DataAndQueue * foo (static_cast<DataAndQueue*>(user_data));
const quarks_t new_servers (foo->data->get_servers());
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 1312ced..177fb2d 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -1117,7 +1117,7 @@ PostUI :: create_body_widget (GtkTextBuffer*& buf, GtkWidget*& view, const Prefs
// always use a monospace font in the compose window
const std::string str (prefs.get_string ("monospace-font", "Monospace 10"));
PangoFontDescription *pfd (pango_font_description_from_string (str.c_str()));
- gtk_widget_modify_font (view, pfd);
+ gtk_widget_override_font (view, pfd);
// figure out how wide the text is before the wrap point
PangoContext * context = gtk_widget_create_pango_context (view);
diff --git a/pan/gui/profiles-dialog.cc b/pan/gui/profiles-dialog.cc
index 0dc3e6f..0b5da19 100644
--- a/pan/gui/profiles-dialog.cc
+++ b/pan/gui/profiles-dialog.cc
@@ -476,18 +476,18 @@ ProfilesDialog :: ProfilesDialog (const Data& data, Profiles &profiles, GtkWindo
// add button
w = gtk_button_new_from_stock (GTK_STOCK_ADD);
gtk_box_pack_start (GTK_BOX (bbox), w, false, false, 0);
- g_signal_connect (GTK_OBJECT(w), "clicked", G_CALLBACK(on_add_button), this);
+ g_signal_connect (w, "clicked", G_CALLBACK(on_add_button), this);
// edit button
w = gtk_button_new_from_stock (GTK_STOCK_EDIT);
_edit_button = w;
gtk_box_pack_start (GTK_BOX (bbox), w, false, false, 0);
- g_signal_connect (GTK_OBJECT(w), "clicked", G_CALLBACK(on_edit_button), this);
+ g_signal_connect (w, "clicked", G_CALLBACK(on_edit_button), this);
// remove button
_remove_button = w = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
gtk_box_pack_start (GTK_BOX (bbox), w, false, false, 0);
- g_signal_connect (GTK_OBJECT(w), "clicked", G_CALLBACK(on_delete_button), this);
+ g_signal_connect (w, "clicked", G_CALLBACK(on_delete_button), this);
// set sensitive buttons
refresh_buttons ();
diff --git a/pan/gui/save-ui.cc b/pan/gui/save-ui.cc
index a29ec8d..121bcdb 100644
--- a/pan/gui/save-ui.cc
+++ b/pan/gui/save-ui.cc
@@ -32,6 +32,7 @@ extern "C" {
#include "pad.h"
#include "pan-file-entry.h"
#include "save-ui.h"
+#include "gtk_compat.h"
using namespace pan;
diff --git a/pan/gui/score-add-ui.cc b/pan/gui/score-add-ui.cc
index ab8604f..9584736 100644
--- a/pan/gui/score-add-ui.cc
+++ b/pan/gui/score-add-ui.cc
@@ -29,6 +29,7 @@ extern "C" {
#include "pad.h"
#include "score-add-ui.h"
#include "score-view-ui.h"
+#include "gtk_compat.h"
using namespace pan;
@@ -332,8 +333,8 @@ namespace
gtk_box_pack_start (GTK_BOX(h), entry, true, true, 0);
g_object_set_data (G_OBJECT(h), "entry", entry);
- GtkObject * a = gtk_adjustment_new (100, -ULONG_MAX, ULONG_MAX, 1.0, 1.0, 0.0);
- GtkWidget * spin = setme_spin = gtk_spin_button_new (GTK_ADJUSTMENT(a), 100.0, 0u);
+ GtkAdjustment * a = (GtkAdjustment*)gtk_adjustment_new (100, -ULONG_MAX, ULONG_MAX, 1.0, 1.0, 0.0);
+ GtkWidget * spin = setme_spin = gtk_spin_button_new (a, 100.0, 0u);
gtk_box_pack_start (GTK_BOX(h), spin, false, false, 0);
g_object_set_data (G_OBJECT(h), "spin", spin);
@@ -647,8 +648,8 @@ ScoreAddDialog :: ScoreAddDialog (Data & data,
w = _score_menu = value_combo_new (model);
g_object_unref (model);
gtk_box_pack_start (GTK_BOX(h), w, true, true, 0);
- GtkObject * a = gtk_adjustment_new (100, INT_MIN, INT_MAX, 1.0, 1.0, 0.0);
- w = _score_spin = gtk_spin_button_new (GTK_ADJUSTMENT(a), 100.0, 0u);
+ GtkAdjustment * a = (GtkAdjustment*)gtk_adjustment_new (100, INT_MIN, INT_MAX, 1.0, 1.0, 0.0);
+ w = _score_spin = gtk_spin_button_new (a, 100.0, 0u);
gtk_box_pack_start (GTK_BOX(h), w, true, true, 0);
HIG::workarea_add_wide_control (t, &row, h);
gtk_widget_show_all (h);
diff --git a/pan/gui/score-view-ui.cc b/pan/gui/score-view-ui.cc
index e4ce49a..6bc1974 100644
--- a/pan/gui/score-view-ui.cc
+++ b/pan/gui/score-view-ui.cc
@@ -26,6 +26,7 @@ extern "C" {
#include "pad.h"
#include "score-add-ui.h"
#include "score-view-ui.h"
+#include "gtk_compat.h"
using namespace pan;
@@ -80,7 +81,7 @@ namespace
}
void
-ScoreView :: add_destroy_cb (GtkObject*, gpointer view_gpointer)
+ScoreView :: add_destroy_cb (GtkWidget*, gpointer view_gpointer)
{
static_cast<ScoreView*>(view_gpointer)->tree_view_refresh ();
}
diff --git a/pan/gui/score-view-ui.h b/pan/gui/score-view-ui.h
index 1e17bb3..fccaa5b 100644
--- a/pan/gui/score-view-ui.h
+++ b/pan/gui/score-view-ui.h
@@ -63,7 +63,7 @@ namespace pan
void on_remove ();
static void add_clicked_cb (GtkWidget*, gpointer);
void on_add ();
- static void add_destroy_cb (GtkObject*, gpointer);
+ static void add_destroy_cb (GtkWidget*, gpointer);
};
}
diff --git a/pan/gui/server-ui.cc b/pan/gui/server-ui.cc
index 15237a4..3ba8ee2 100644
--- a/pan/gui/server-ui.cc
+++ b/pan/gui/server-ui.cc
@@ -32,6 +32,7 @@ extern "C" {
#include "server-ui.h"
#include "pad.h"
#include "hig.h"
+#include "gtk_compat.h"
using namespace pan;
diff --git a/pan/gui/task-pane.h b/pan/gui/task-pane.h
index d18d7cc..99be244 100644
--- a/pan/gui/task-pane.h
+++ b/pan/gui/task-pane.h
@@ -66,7 +66,7 @@ namespace pan
void update_status (const Queue::task_states_t&);
static gboolean periodic_refresh_foreach (GtkTreeModel*, GtkTreePath*, GtkTreeIter*, gpointer);
static gboolean periodic_refresh (gpointer);
- static void root_destroyed_cb (GtkObject, gpointer);
+ static void root_destroyed_cb (GtkWidget, gpointer);
private:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]