[Xfce4-commits] <postler:master> Support GTK+3 with a build switch for GTK+2
Christian Dywan
noreply at xfce.org
Tue Jul 5 21:58:01 CEST 2011
Updating branch refs/heads/master
to 84a6659446094b2d9982a692a5be17850e51a634 (commit)
from 54df0067073544e2c1e66ad5b9cf6077abfe15b4 (commit)
commit 84a6659446094b2d9982a692a5be17850e51a634
Author: Lucas Baudin <xapantu at gmail.com>
Date: Tue Jul 5 21:55:56 2011 +0200
Support GTK+3 with a build switch for GTK+2
Single instance with Gtk.Application is missing.
Fixes: https://bugs.launchpad.net/postler/+bug/806026
postler/postler-accountsetup.vala | 4 ++--
postler/postler-app.vala | 23 +++++++++++++++++++++--
postler/postler-bureau.vala | 20 ++++++++++++--------
postler/postler-cellrenderertoggle.vala | 10 +++++++++-
postler/postler-composer.vala | 8 ++++++++
postler/postler-content.vala | 19 +++++++++++++------
postler/postler-flowbox.vala | 18 ++++++++++++++++++
postler/postler-reader.vala | 4 ++++
postler/postler-shortcuts.vala | 6 ++++--
postler/wscript_build | 11 ++++++++---
wscript | 24 ++++++++++++++++++------
11 files changed, 117 insertions(+), 30 deletions(-)
diff --git a/postler/postler-accountsetup.vala b/postler/postler-accountsetup.vala
index a64d86a..47db453 100644
--- a/postler/postler-accountsetup.vala
+++ b/postler/postler-accountsetup.vala
@@ -325,7 +325,7 @@ public class Postler.AccountSetup : Gtk.Dialog {
remove.relief = Gtk.ReliefStyle.NONE;
remove.show ();
remove.image.show ();
- (setup.action_area as Gtk.Box).pack_start (remove, false, false, 0);
+ (setup.get_action_area () as Gtk.Box).pack_start (remove, false, false, 0);
remove.clicked.connect ((button) => {
var toplevel = setup.get_toplevel () as Gtk.Window;
var dialog = new Gtk.MessageDialog (toplevel, 0,
@@ -343,7 +343,7 @@ public class Postler.AccountSetup : Gtk.Dialog {
}
});
var apply = setup.add_button (update_label, Gtk.ResponseType.APPLY);
- (setup.action_area as Gtk.Box).set_child_packing (apply,
+ (setup.get_action_area () as Gtk.Box).set_child_packing (apply,
true, true, 0, Gtk.PackType.END);
setup.set_default_response (Gtk.ResponseType.APPLY);
setup.widget.address.changed.connect ((editable) => {
diff --git a/postler/postler-app.vala b/postler/postler-app.vala
index 9b224ae..52f2a9f 100644
--- a/postler/postler-app.vala
+++ b/postler/postler-app.vala
@@ -50,19 +50,29 @@ namespace Postler {
const string STOCK_REPORT_BUG = "lpi-bug";
}
+#if HAVE_GTK3
+public class Postler.App : Gtk.Application {
+#else
public class Postler.App : Unique.App {
+#endif
Bureau? bureau = null;
-
public static string argv0 { get; set; }
public App () {
+#if HAVE_GTK3
+ GLib.Object (application_id: "org.elementary.PostlerApp");
+#else
GLib.Object (name: "org.elementary.PostlerApp", startup_id: null);
+#endif
}
public new void watch_window (Bureau bureau) {
this.bureau = bureau;
}
+#if HAVE_GTK3
+ /* FIXME: Implement instance callback */
+#else
public override Unique.Response message_received (int command,
Unique.MessageData data, uint timestamp) {
if (command == Unique.Command.ACTIVATE) {
@@ -72,6 +82,7 @@ public class Postler.App : Unique.App {
}
return Unique.Response.OK;
}
+#endif
const Gtk.StockItem[] stock_items = {
{ STOCK_ACCOUNT_NEW, N_("New _Account"), 0, 0, "list-add" },
@@ -259,12 +270,20 @@ public class Postler.App : Unique.App {
ref bool push_in) {
/* Position the menu right below the widget */
var widget = menu.get_attach_widget ();
- Gtk.Allocation allocation = widget.allocation;
int widget_x, widget_y;
+#if HAVE_GTK3
+ Gtk.Allocation allocation = Gtk.Allocation ();
+ widget.get_allocation (out allocation);
+ widget.get_window ().get_position (out widget_x, out widget_y);
+ Gtk.Requisition? requisition = null;
+ int widget_height = widget.get_allocated_height ();
+#else
+ Gtk.Allocation allocation = widget.allocation;
widget.window.get_position (out widget_x, out widget_y);
Gtk.Requisition requisition;
widget.size_request (out requisition);
int widget_height = requisition.height;
+#endif
x = widget_x + allocation.x;
y = widget_y + allocation.y + widget_height;
push_in = true;
diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index ad09b78..4762c41 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -248,7 +248,7 @@ public class Postler.Bureau : Gtk.Window {
}
void action_fullscreen () {
- if ((window.get_state () & Gdk.WindowState.FULLSCREEN) == 0) {
+ if ((get_window ().get_state () & Gdk.WindowState.FULLSCREEN) == 0) {
fullscreen ();
} else {
unfullscreen ();
@@ -299,15 +299,19 @@ public class Postler.Bureau : Gtk.Window {
Gtk.main_quit ();
}
+#if HAVE_GTK3
+ public override bool delete_event (Gdk.EventAny event) {
+#else
public override bool delete_event (Gdk.Event event) {
+#endif
update_saved_state ();
return false;
}
void update_saved_state () {
- if ((window.get_state () & Gdk.WindowState.MAXIMIZED) != 0)
+ if ((get_window ().get_state () & Gdk.WindowState.MAXIMIZED) != 0)
previous_state.window_state = 1;
- else if ((window.get_state () & Gdk.WindowState.FULLSCREEN) != 0)
+ else if ((get_window ().get_state () & Gdk.WindowState.FULLSCREEN) != 0)
previous_state.window_state = 2;
else
previous_state.window_state = 0;
@@ -628,13 +632,13 @@ public class Postler.Bureau : Gtk.Window {
if (text != null) {
statuslabel.label = text;
progressbar.fraction = fraction;
- if (!statusitem.child.visible) {
- statusitem.child.show ();
+ if (!statusitem.get_child ().visible) {
+ statusitem.get_child ().show ();
actions.get_action ("MailReceive").sensitive = false;
}
} else {
- if (statusitem.child.visible) {
- statusitem.child.hide ();
+ if (statusitem.get_child ().visible) {
+ statusitem.get_child ().hide ();
actions.get_action ("MailReceive").sensitive = true;
}
}
@@ -884,7 +888,7 @@ public class Postler.Bureau : Gtk.Window {
if (Environment.get_variable ("POSTLER_MOCKUP") != null) {
progressbar.fraction = 0.7;
statuslabel.label = "Receiving 4 of 7 - Inbox";
- statusitem.child.show ();
+ statusitem.get_child ().show ();
search.set_text ("elementary");
search.activate ();
messages.notify["selected-message"].connect_after ((object, pspec) => {
diff --git a/postler/postler-cellrenderertoggle.vala b/postler/postler-cellrenderertoggle.vala
index ccd23ea..1e37e8a 100644
--- a/postler/postler-cellrenderertoggle.vala
+++ b/postler/postler-cellrenderertoggle.vala
@@ -49,11 +49,19 @@ public class Postler.CellRendererToggle : Gtk.CellRendererToggle {
if (&height != null)
height = icon_height;
}
+
+#if HAVE_GTK3
+ public override void render (Cairo.Context context, Gtk.Widget widget,
+ Gdk.Rectangle expose_area, Gdk.Rectangle cell_area,
+ Gtk.CellRendererState flags) {
+ Gdk.Rectangle background_area = expose_area;
+#else
public override void render (Gdk.Window window, Gtk.Widget widget,
Gdk.Rectangle background_area, Gdk.Rectangle cell_area,
Gdk.Rectangle expose_area, Gtk.CellRendererState flags) {
-
var context = Gdk.cairo_create (window);
+#endif
+
Gdk.cairo_rectangle (context, expose_area);
Gdk.cairo_rectangle (context, background_area);
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index a62d7f8..deeb1ba 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -22,7 +22,11 @@ public class Postler.Composer : Gtk.Window {
Gtk.ProgressBar progressbar;
Postler.Content content;
Postler.Attachments attachments;
+#if HAVE_GTK3
+ Gtk.ComboBoxText combo_from;
+#else
Gtk.ComboBox combo_from;
+#endif
Postler.RecipientEntry entry_to;
Postler.RecipientEntry entry_copy;
Postler.RecipientEntry entry_blind_copy;
@@ -611,7 +615,11 @@ public class Postler.Composer : Gtk.Window {
label_from.xalign = 1.0f;
box.pack_start (label_from, false, false, 4);
sizegroup.add_widget (label_from);
+#if HAVE_GTK3
+ combo_from = new Gtk.ComboBoxText ();
+#else
combo_from = new Gtk.ComboBox.text ();
+#endif
box.pack_start (combo_from, true, true, 12);
box = new Gtk.HBox (false, 0);
shelf.pack_start (box, false, false, 4);
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 67f9703..c0f35e5 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -246,7 +246,7 @@ public class Postler.Content : WebKit.WebView {
if (editable || can_copy_clipboard ())
return;
- menu.hide_all ();
+ menu.hide ();
var event = Gtk.get_current_event ();
var result = get_hit_test_result ((Gdk.EventButton?)event);
@@ -882,7 +882,8 @@ public class Postler.Content : WebKit.WebView {
<div class="body">%s</div>
"""
.printf (
- style_sheet.replace ("ButtonText", color_to_rgb (style.fg[state])),
+ style_sheet.replace ("ButtonText",
+ color_to_rgb (style.fg[widget_state])),
content_stylesheet,
message.subject,
linkify_address (reply_uri (message, "Re: ", message.recipients)),
@@ -971,6 +972,12 @@ public class Postler.Content : WebKit.WebView {
return color.to_string ().substring (0, 7);
}
+#if HAVE_GTK3
+ const Gtk.StateFlags widget_state = Gtk.StateFlags.NORMAL;
+#else
+ const Gtk.StateType widget_state = Gtk.StateType.NORMAL;
+#endif
+
string themed_style_sheet () {
/* Retrieve style from toplevel in case widget's not visible yet */
var widget = get_toplevel ();
@@ -978,10 +985,10 @@ public class Postler.Content : WebKit.WebView {
void* link_color;
widget.style_get ("link-color", out link_color);
return fallback_style_sheet.replace (
- "ButtonText", color_to_rgb (widget.style.fg[state])).replace (
- "ButtonFace", color_to_rgb (widget.style.bg[state])).replace (
- "WindowText", color_to_rgb (widget.style.fg[state])).replace (
- "Window", color_to_rgb (widget.style.base[state])).replace (
+ "ButtonText", color_to_rgb (widget.style.fg[widget_state])).replace (
+ "ButtonFace", color_to_rgb (widget.style.bg[widget_state])).replace (
+ "WindowText", color_to_rgb (widget.style.fg[widget_state])).replace (
+ "Window", color_to_rgb (widget.style.base[widget_state])).replace (
"Link", color_to_rgb (*((Gdk.Color*)link_color)));
}
diff --git a/postler/postler-flowbox.vala b/postler/postler-flowbox.vala
index b1988c3..dd27909 100644
--- a/postler/postler-flowbox.vala
+++ b/postler/postler-flowbox.vala
@@ -52,15 +52,24 @@ namespace Postler {
}
}
+#if HAVE_GTK3
+ public override void size_allocate (Gtk.Allocation allocation) {
+#else
public override void size_allocate (Gdk.Rectangle allocation) {
+#endif
int width = 0;
int row_count = 1;
int row_height = 1;
foreach (var child in children) {
if (child.visible) {
+#if HAVE_GTK3
+ Gtk.Requisition? child_size = null;
+ child.get_requisition (child_size);
+#else
Gtk.Requisition child_size;
child.size_request (out child_size);
+#endif
width += child_size.width;
if (width > allocation.width && width != child_size.width) {
@@ -81,15 +90,24 @@ namespace Postler {
int row = 1;
foreach (var child in children) {
if (child.visible) {
+#if HAVE_GTK3
+ Gtk.Requisition? child_size = null;
+ child.get_requisition (child_size);
+#else
Gtk.Requisition child_size;
child.size_request (out child_size);
+#endif
width += child_size.width;
if (width > allocation.width && width != child_size.width) {
row++;
width = child_size.width;
}
+#if HAVE_GTK3
+ var child_allocation = new Gtk.Allocation ();
+#else
var child_allocation = new Gdk.Rectangle ();
+#endif
child_allocation.width = child_size.width;
child_allocation.height = row_height;
child_allocation.x = allocation.x + width - child_size.width;
diff --git a/postler/postler-reader.vala b/postler/postler-reader.vala
index d9736a9..c9eb09f 100644
--- a/postler/postler-reader.vala
+++ b/postler/postler-reader.vala
@@ -217,6 +217,9 @@ public class Postler.Reader {
}
var app = new Postler.App ();
+#if HAVE_GTK3
+ /* FIXME: Implement instance check */
+#else
if (app.is_running) {
Unique.MessageData data = new Unique.MessageData ();
if (filenames != null && filenames[0] != null)
@@ -226,6 +229,7 @@ public class Postler.Reader {
return 0;
GLib.error (_("Failed to activate running instance"));
}
+#endif
var bureau = new Postler.Bureau ();
bureau.destroy.connect (Gtk.main_quit);
diff --git a/postler/postler-shortcuts.vala b/postler/postler-shortcuts.vala
index 6142689..e324b0c 100644
--- a/postler/postler-shortcuts.vala
+++ b/postler/postler-shortcuts.vala
@@ -16,8 +16,10 @@ namespace Postler {
public Shortcuts (Gtk.Window parent, Gtk.ActionGroup action_group) {
GLib.Object (transient_for: parent,
- title: _("Keyboard Shortcuts"),
- has_separator: false);
+#if !HAVE_GTK3
+ has_separator: false,
+#endif
+ title: _("Keyboard Shortcuts"));
var screen = get_screen ();
Gdk.Rectangle monitor;
diff --git a/postler/wscript_build b/postler/wscript_build
index d4540a5..78e9dcc 100644
--- a/postler/wscript_build
+++ b/postler/wscript_build
@@ -13,11 +13,16 @@ obj.name = 'postler'
obj.target = 'postler'
obj.includes = '. ..'
obj.find_sources_in_dirs ('.')
-obj.uselib = 'GIO GTHREAD GTK LIBNOTIFY LIBCANBERRA INDICATE UNIQUE WEBKIT SQLITE3 FOLKS ZEITGEIST FOLKS'
-obj.packages = 'config postler posix gio-2.0 gtk+-2.0 libnotify libcanberra ' \
- 'unique-1.0 webkit-1.0 sqlite3'
+obj.uselib = 'GIO GTHREAD GTK WEBKIT SQLITE3 LIBNOTIFY LIBCANBERRA \
+ UNIQUE INDICATE ZEITGEIST FOLKS'
+obj.packages = 'config postler posix gio-2.0 libnotify libcanberra sqlite3'
obj.vapi_dirs = '.'
+if bld.env['HAVE_GTK3']:
+ obj.packages += ' gtk+-3.0 webkitgtk-3.0'
+else:
+ obj.packages += ' gtk+-2.0 webkit-1.0 unique-1.0'
+
if bld.env['HAVE_FOLKS']:
obj.packages += ' gee-1.0'
if bld.env['HAVE_ZEITGEIST']:
diff --git a/wscript b/wscript
index 8beccb0..254c3aa 100644
--- a/wscript
+++ b/wscript
@@ -111,13 +111,27 @@ def configure (conf):
mandatory=mandatory, define_name=var)
check_pkg ('gio-2.0', '2.26.0')
- check_pkg ('unique-1.0', '0.9')
- check_pkg ('gtk+-2.0', '2.18.0', var='GTK')
- check_pkg ('webkit-1.0', '1.1.18')
check_pkg ('sqlite3', '3.0')
check_pkg ('libnotify', var='LIBNOTIFY')
check_pkg ('libcanberra', var='LIBCANBERRA')
+ if option_enabled ('gtk3'):
+ check_pkg ('gtk+-3.0', '2.18.0', var='GTK', mandatory=False)
+ check_pkg ('webkitgtk-3.0', '1.1.18', var='WEBKIT', mandatory=False)
+ if not conf.env['HAVE_GTK'] or not conf.env['HAVE_WEBKIT']:
+ Utils.pprint ('RED', 'GTK3 was not found.\n' \
+ 'Pass --disable-gtk3 to build with GTK3.')
+ sys.exit (1)
+ conf.env.append_value ('VALAFLAGS', '-D HAVE_GTK3')
+ else:
+ check_pkg ('gtk+-2.0', '2.18.0', var='GTK')
+ check_pkg ('webkit-1.0', '1.1.18')
+ check_pkg ('unique-1.0', '0.9')
+ if conf.check_cfg (modversion='unique-1.0') == '1.0.4':
+ Utils.pprint ('RED', 'unique 1.0.4 found, this version is erroneous.')
+ Utils.pprint ('RED', 'Please use an older or newer version.')
+ conf.env['HAVE_GTK3'] = option_enabled ('gtk3')
+
if option_enabled ('libfolks'):
check_pkg ('folks', '', mandatory=False)
if conf.env['HAVE_FOLKS']:
@@ -246,9 +260,6 @@ def configure (conf):
print '''
Localization: %(nls)s (intltool)
''' % locals ()
- if conf.check_cfg (modversion='unique-1.0') == '1.0.4':
- Utils.pprint ('RED', 'unique 1.0.4 found, this version is erroneous.')
- Utils.pprint ('RED', 'Please use an older or newer version.')
def set_options (opt):
def add_enable_option (option, desc, group=None, disable=False):
@@ -281,6 +292,7 @@ def set_options (opt):
help='Update localization files', dest='update_po')
add_enable_option ('docs', 'informational text files', group)
+ add_enable_option ('gtk3', 'gtk3 and webkitgtk3 support')
add_enable_option ('libfolks', 'libfolks support (Telepathy, EDS)')
add_enable_option ('zeitgeist', 'Zeitgeist support (Synapse, Unity)')
add_enable_option ('libindicate', 'Messaging Menu support (Ayatana)')
More information about the Xfce4-commits
mailing list