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
1=== modified file 'src/gtimelog/main.py'
2--- src/gtimelog/main.py 2011-03-02 16:43:01 +0000
3+++ src/gtimelog/main.py 2011-08-17 05:23:58 +0000
4@@ -15,13 +15,13 @@
5 import ConfigParser
6 from operator import itemgetter
7
8-import gobject
9
10-# we have to try pygtk first, then fall back to GI; if we have a too old GI
11-# (without require_version()), we can't import pygtk on top of gi.repo.Gtk.
12+# we have to try pygtk first, then fall back to GI; if we have a too old GI, we
13+# can't import pygtk on top of gi.repo.Gtk.
14 try:
15 import pygtk
16 pygtk.require('2.0')
17+ import gobject
18 import gtk
19 from gtk import gdk as gdk
20 import pango
21@@ -41,22 +41,23 @@
22 new_app_indicator = None
23
24 except ImportError:
25- import gi
26- gi.require_version('Gdk', '2.0')
27- gi.require_version('Gtk', '2.0')
28+ from gi.repository import GObject as gobject
29 from gi.repository import Gdk as gdk
30 from gi.repository import Gtk as gtk
31 from gi.repository import Pango as pango
32 pygtk = None
33
34 # these are hacks until we fully switch to GI
35- PANGO_ALIGN_LEFT = pango.TabAlign.LEFT
36+ PANGO_ALIGN_LEFT = pango.TabAlign.TAB_LEFT
37 GTK_RESPONSE_OK = gtk.ResponseType.OK
38 gtk_status_icon_new = gtk.StatusIcon.new_from_file
39 pango_tabarray_new = pango.TabArray.new
40
41 try:
42- from gi.repository import AppIndicator
43+ if gtk._version.startswith('2'):
44+ from gi.repository import AppIndicator
45+ else:
46+ from gi.repository import AppIndicator3 as AppIndicator
47 new_app_indicator = AppIndicator.Indicator.new
48 APPINDICATOR_CATEGORY = AppIndicator.IndicatorCategory.APPLICATION_STATUS
49 APPINDICATOR_ACTIVE = AppIndicator.IndicatorStatus.ACTIVE
50@@ -1345,6 +1346,9 @@
51
52 def set_up_log_view_columns(self):
53 """Set up tab stops in the log view."""
54+ # we can't get a Pango context for unrealized widgets
55+ if not self.log_view.get_realized():
56+ self.log_view.realize()
57 pango_context = self.log_view.get_pango_context()
58 em = pango_context.get_font_description().get_size()
59 tabs = pango_tabarray_new(2, False)

Subscribers

People subscribed via source and target branches