Merge lp:~pitti/gtimelog/pygi into lp:~gtimelog-dev/gtimelog/trunk

Proposed by Martin Pitt
Status: Merged
Approved by: Barry Warsaw
Approved revision: no longer in the source branch.
Merged at revision: 190
Proposed branch: lp:~pitti/gtimelog/pygi
Merge into: lp:~gtimelog-dev/gtimelog/trunk
Diff against target: 59 lines (+12/-8)
1 file modified
src/gtimelog/main.py (+12/-8)
To merge this branch: bzr merge lp:~pitti/gtimelog/pygi
Reviewer Review Type Date Requested Status
Barry Warsaw Approve
Review via email: mp+62682@code.launchpad.net

Description of the change

This adds support for using GTK 3 in addition to pygtk2 and PyGI with GTK2.

It initially crashed on startup, I fixed that in the second commit. Now it works fine with all three.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

I pushed a commit to work with Pango 1.29.x.

Revision history for this message
Martin Pitt (pitti) wrote :

I also pushed a commit to work with the upcoming pygobject 3.0, which now requires consistency wrt. glib and gobject imports (either use static only or GI only).

Revision history for this message
Barry Warsaw (barry) wrote :

Looks good!

review: Approve
lp:~pitti/gtimelog/pygi updated
190. By Barry Warsaw

Merge pitti's GTK3 branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/gtimelog/main.py'
--- src/gtimelog/main.py 2011-03-02 16:43:01 +0000
+++ src/gtimelog/main.py 2011-08-17 05:23:58 +0000
@@ -15,13 +15,13 @@
15import ConfigParser15import ConfigParser
16from operator import itemgetter16from operator import itemgetter
1717
18import gobject
1918
20# we have to try pygtk first, then fall back to GI; if we have a too old GI19# we have to try pygtk first, then fall back to GI; if we have a too old GI, we
21# (without require_version()), we can't import pygtk on top of gi.repo.Gtk.20# can't import pygtk on top of gi.repo.Gtk.
22try:21try:
23 import pygtk22 import pygtk
24 pygtk.require('2.0')23 pygtk.require('2.0')
24 import gobject
25 import gtk25 import gtk
26 from gtk import gdk as gdk26 from gtk import gdk as gdk
27 import pango27 import pango
@@ -41,22 +41,23 @@
41 new_app_indicator = None41 new_app_indicator = None
4242
43except ImportError:43except ImportError:
44 import gi44 from gi.repository import GObject as gobject
45 gi.require_version('Gdk', '2.0')
46 gi.require_version('Gtk', '2.0')
47 from gi.repository import Gdk as gdk45 from gi.repository import Gdk as gdk
48 from gi.repository import Gtk as gtk46 from gi.repository import Gtk as gtk
49 from gi.repository import Pango as pango47 from gi.repository import Pango as pango
50 pygtk = None48 pygtk = None
5149
52 # these are hacks until we fully switch to GI50 # these are hacks until we fully switch to GI
53 PANGO_ALIGN_LEFT = pango.TabAlign.LEFT51 PANGO_ALIGN_LEFT = pango.TabAlign.TAB_LEFT
54 GTK_RESPONSE_OK = gtk.ResponseType.OK52 GTK_RESPONSE_OK = gtk.ResponseType.OK
55 gtk_status_icon_new = gtk.StatusIcon.new_from_file53 gtk_status_icon_new = gtk.StatusIcon.new_from_file
56 pango_tabarray_new = pango.TabArray.new54 pango_tabarray_new = pango.TabArray.new
5755
58 try:56 try:
59 from gi.repository import AppIndicator57 if gtk._version.startswith('2'):
58 from gi.repository import AppIndicator
59 else:
60 from gi.repository import AppIndicator3 as AppIndicator
60 new_app_indicator = AppIndicator.Indicator.new61 new_app_indicator = AppIndicator.Indicator.new
61 APPINDICATOR_CATEGORY = AppIndicator.IndicatorCategory.APPLICATION_STATUS62 APPINDICATOR_CATEGORY = AppIndicator.IndicatorCategory.APPLICATION_STATUS
62 APPINDICATOR_ACTIVE = AppIndicator.IndicatorStatus.ACTIVE63 APPINDICATOR_ACTIVE = AppIndicator.IndicatorStatus.ACTIVE
@@ -1345,6 +1346,9 @@
13451346
1346 def set_up_log_view_columns(self):1347 def set_up_log_view_columns(self):
1347 """Set up tab stops in the log view."""1348 """Set up tab stops in the log view."""
1349 # we can't get a Pango context for unrealized widgets
1350 if not self.log_view.get_realized():
1351 self.log_view.realize()
1348 pango_context = self.log_view.get_pango_context()1352 pango_context = self.log_view.get_pango_context()
1349 em = pango_context.get_font_description().get_size()1353 em = pango_context.get_font_description().get_size()
1350 tabs = pango_tabarray_new(2, False)1354 tabs = pango_tabarray_new(2, False)

Subscribers

People subscribed via source and target branches