[pybliographer] ui: Replace GnomeApp by a regular GtkWindow
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pybliographer] ui: Replace GnomeApp by a regular GtkWindow
- Date: Mon, 26 Mar 2018 03:51:47 +0000 (UTC)
commit 4d035e8a420f0e347a8839431073273e4c184340
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Mon Mar 26 00:00:32 2018 -0300
ui: Replace GnomeApp by a regular GtkWindow
* Move the main window from libglabe to gtkbuilder
* Remove python-gnome requirement for gnomeui/document
Pyblio/GnomeUI/Document.py | 37 ++-
Pyblio/GnomeUI/__init__.py | 9 +-
Pyblio/GnomeUI/glade/Makefile.am | 12 +-
Pyblio/GnomeUI/glade/pyblio.glade.in | 626 ----------------------------------
Pyblio/GnomeUI/glade/pyblio.ui.in | 53 +++
Pyblio/Resource.py | 52 ++--
6 files changed, 108 insertions(+), 681 deletions(-)
---
diff --git a/Pyblio/GnomeUI/Document.py b/Pyblio/GnomeUI/Document.py
index 5ed0992..e03ce0d 100644
--- a/Pyblio/GnomeUI/Document.py
+++ b/Pyblio/GnomeUI/Document.py
@@ -2,8 +2,8 @@
#
# This file is part of pybliographer
#
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -26,7 +26,6 @@
import gobject
import gtk
-import gtk.glade
from Pyblio.GnomeUI import Editor, Entry, FileSelector, Format
from Pyblio.GnomeUI import Index, OpenURL, Search, Utils
@@ -193,26 +192,30 @@ class Document (Connector.Publisher):
self.uim.ensure_update ()
- gp = os.path.join(Utils.glade_root, 'pyblio.glade')
+ gp = os.path.join(Utils.glade_root, 'pyblio.ui')
- self.xml = gtk.glade.XML (gp, 'main', domain = 'pybliographer')
- self.xml.signal_autoconnect (self)
+ self.xml = gtk.Builder()
+ self.xml.set_translation_domain('pybliographer')
+ self.xml.add_from_file(gp)
+ self.xml.connect_signals(self)
- self.w = self.xml.get_widget ('main')
- self.paned = self.xml.get_widget ('main_pane')
+ self.w = self.xml.get_object('main')
+ self.paned = self.xml.get_object('main_pane')
- self.w.set_menus (self.uim.get_widget ('/Menubar'))
- self.w.set_toolbar (self.uim.get_widget ('/Toolbar'))
+ box = self.xml.get_object('table')
+ menubar = (self.uim.get_widget ('/Menubar'))
+ toolbar = (self.uim.get_widget ('/Toolbar'))
+ box.attach(menubar, 0, 1, 0, 1, yoptions=0)
+ box.attach(toolbar, 0, 1, 1, 2, yoptions=0)
self.w.add_accel_group (self.uim.get_accel_group ())
self.w.add_events (gtk.gdk.KEY_PRESS_MASK)
- self.w_save_btn = self.xml.get_widget ('_w_save_btn')
- self.w_save_mnu = self.xml.get_widget ('_w_save_mnu')
+ self.w_save_btn = self.xml.get_object('_w_save_btn')
+ self.w_save_mnu = self.xml.get_object('_w_save_mnu')
# We manually add a simple search area
- t = self.uim.get_widget ('/Toolbar')
h = gtk.HBox()
i = gtk.Image()
@@ -232,7 +235,7 @@ class Document (Connector.Publisher):
i = gtk.ToolItem()
i.add(h)
- t.insert(i, -1)
+ toolbar.insert(i, -1)
i.show_all()
@@ -257,7 +260,7 @@ class Document (Connector.Publisher):
self.paned.add2 (self.display.w)
# Status bar
- self.statusbar = self.xml.get_widget ('statusbar')
+ self.statusbar = self.xml.get_object('statusbar')
# set window size
ui_width = Utils.config.get_int ('/apps/pybliographic/ui/width') or -1
@@ -448,8 +451,8 @@ class Document (Connector.Publisher):
self.actiongroup.get_action ('Save').set_property ('sensitive', self.changed)
- self.statusbar.set_default (text)
- return
+ self.context_id = self.statusbar.get_context_id('main')
+ self.statusbar.push(self.context_id, text)
def confirm (self):
diff --git a/Pyblio/GnomeUI/__init__.py b/Pyblio/GnomeUI/__init__.py
index 2845626..b53be83 100644
--- a/Pyblio/GnomeUI/__init__.py
+++ b/Pyblio/GnomeUI/__init__.py
@@ -31,12 +31,10 @@ sys.argv = sys.argv [:2] + ['--'] + files
import pygtk
pygtk.require ('2.0')
-import gnome, gtk
+import gtk
from Pyblio import version
-prg = gnome.init ('pybliographer', version.version)
-prg.set_property (gnome.PARAM_APP_DATADIR, version.datadir)
def _vnum (t):
return string.join (map (str, t), '.')
@@ -49,8 +47,3 @@ ui_version = _("This is Pybliographic %s [Python %s, Gtk %s, PyGTK %s]") % (
sys.argv = sys.argv [:2] + files
del sys, files
-
-import gtk.glade
-
-gtk.glade.bindtextdomain ("pybliographer", version.localedir)
-
diff --git a/Pyblio/GnomeUI/glade/Makefile.am b/Pyblio/GnomeUI/glade/Makefile.am
index 3e61fd0..5e18c34 100644
--- a/Pyblio/GnomeUI/glade/Makefile.am
+++ b/Pyblio/GnomeUI/glade/Makefile.am
@@ -3,7 +3,7 @@ appicondir = $(datadir)/$(PACKAGE)/pixmaps
glade_DATA = \
fields1.glade \
- pyblio.glade \
+ pyblio.ui \
search.glade \
sort.glade \
format.glade \
@@ -11,9 +11,11 @@ glade_DATA = \
config1.glade \
openurl.glade
-EXTRA_DIST = $(glade_DATA) pyblio.glade.in
+EXTRA_DIST = $(glade_DATA) pyblio.ui.in
-pyblio.glade: pyblio.glade.in Makefile
+pyblio.ui: pyblio.ui.in Makefile
sed -e 's^\@icondir\@^$(appicondir)^g' \
- < $(srcdir)/pyblio.glade.in > pyblio.glade.tmp \
- && mv pyblio.glade.tmp pyblio.glade
+ < $(srcdir)/pyblio.ui.in > pyblio.ui.tmp \
+ && mv pyblio.ui.tmp pyblio.ui
+
+DISTCLEANFILES = pyblio.ui
diff --git a/Pyblio/GnomeUI/glade/pyblio.ui.in b/Pyblio/GnomeUI/glade/pyblio.ui.in
new file mode 100644
index 0000000..5f9bcc4
--- /dev/null
+++ b/Pyblio/GnomeUI/glade/pyblio.ui.in
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.24"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkWindow" id="main">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Pybliographer</property>
+ <property name="icon">@icondir@/pybliographic.png</property>
+ <signal name="key-press-event" handler="key_pressed" swapped="no"/>
+ <signal name="delete-event" handler="close_or_exit" swapped="no"/>
+ <child>
+ <object class="GtkTable" id="table">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">4</property>
+ <child>
+ <object class="GtkVPaned" id="main_pane">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkStatusbar" id="statusbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">2</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/Pyblio/Resource.py b/Pyblio/Resource.py
index 236df58..ef407ee 100644
--- a/Pyblio/Resource.py
+++ b/Pyblio/Resource.py
@@ -1,29 +1,29 @@
# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyright (C) 2005 Peter Schulte-Stracke
-# Email : mail schulte-stracke de
-#
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 2005 Peter Schulte-Stracke <mail schulte-stracke de>
+#
# 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; either version 2
+# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
-#
+#
# 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.
-#
+# 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.
-#
+#
"""
Pyblio.Resource -- handle (electronic) resourcces
- View: start an application to display a rresource
- --
+ View: start an application to display a rresource
+ --
"""
@@ -59,7 +59,7 @@ def get_viewables (item, priority=[]):
"""Return a list of possible viewable resources for an item"""
R = userexit.resource_viewer_select (Director, item)
if R: return R
- viewables = Config.get (config_fields).data
+ viewables = Config.get (config_fields).data
return [ (key, item[key], item [key].get_url ()) for key
in priority + viewables if item.has_key (key)]
@@ -73,41 +73,42 @@ def StartViewer (entry, key, stringuri, parent=None, document=None):
uri = Fields.URL (stringuri)
scheme, location, path, parameters, query, fragment = uri.url
fileuri = uri.get_url ()
-
+
if uri.invalid or uri.inexact:
message = Utils.Callback (
_("Warning: This URL is marked as Invalid or Approximate: %s\nContinue?") % fileuri)
if not message.answer (): return
if document:
- document.statusbar.set_status (_("Determining Mime Type… "))
+ document.statusbar.push(document.context_id,
+ _(u"Determining Mime Type… "))
try:
mimetype = gio.content_type_guess(fileuri)
except RuntimeError, mesg:
- Utils.error_dialog(_("Cannot determine mime type for item %s ") % entry.key.key,
+ Utils.error_dialog(_("Cannot determine mime type for item %s ") % entry.key.key,
_("URL in question is: %s\n"
"You should check the url or path given for errors.\n"
"Details: %s")
% (fileuri, mesg))
if document:
- document.statusbar.pop ()
+ document.statusbar.pop(document.context_id)
return
mimetype1 = mimetype.split ('/', 1) [0]
if document:
- document.statusbar.set_status (_("Accessing resource…"))
+ document.statusbar.push(document.context_id, _(u"Accessing resource…"))
if scheme == 'file' and not location:
filename = path
-
+
elif mimetype in ['text/html', 'text/plain']:
filename = fileuri
else:
filename, headers = urllib.urlretrieve (fileuri)
-
+
if mimetype == 'application/x-gzip':
try:
tempname = os.tmpnam ()
@@ -119,7 +120,7 @@ def StartViewer (entry, key, stringuri, parent=None, document=None):
% entry.key.key, _("URL: %s\nDetails: %s")
% (filename, mesg))
if document:
- document.statusbar.pop ()
+ document.statusbar.pop(document.context_id)
return
viewers = [
@@ -136,7 +137,8 @@ def StartViewer (entry, key, stringuri, parent=None, document=None):
) or "%s %s&" %(cmd, filename)
if document:
- document.statusbar.set_status (_("Starting application…"))
+ document.statusbar.push(document.context_id,
+ _(u"Starting application…"))
os.system (command)
else:
Utils.error_dialog (_("No application to view resource"),
@@ -145,12 +147,12 @@ def StartViewer (entry, key, stringuri, parent=None, document=None):
"Please consider adding one.\n"
"URL: %s") % (mimetype, fileuri))
if document:
- document.statusbar.pop ()
+ document.statusbar.pop(document.context_id)
+
+ return
- return
-
# Local Variables:
# py-master-file: "ut_resource.py"
-# coding: "latin-1"
+# coding: "utf-8"
# End:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]