[pybliographer] ui: Port fields dialog to GtkBuilder
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pybliographer] ui: Port fields dialog to GtkBuilder
- Date: Tue, 27 Mar 2018 03:43:38 +0000 (UTC)
commit 222b9ffd877b72d76c25cdea9423498a2c57b6b0
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Mon Mar 26 21:53:55 2018 -0300
ui: Port fields dialog to GtkBuilder
Pyblio/GnomeUI/Fields.py | 78 +++---
Pyblio/GnomeUI/glade/Makefile.am | 2 +-
Pyblio/GnomeUI/glade/fields.ui | 443 ++++++++++++++++++++++++++
Pyblio/GnomeUI/glade/fields1.glade | 602 ------------------------------------
po/POTFILES.in | 2 +-
5 files changed, 484 insertions(+), 643 deletions(-)
---
diff --git a/Pyblio/GnomeUI/Fields.py b/Pyblio/GnomeUI/Fields.py
index 524794a..64c886c 100644
--- a/Pyblio/GnomeUI/Fields.py
+++ b/Pyblio/GnomeUI/Fields.py
@@ -1,7 +1,8 @@
+# -*- coding: utf-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
@@ -43,22 +44,19 @@ _typename = {
Fields.Date : _('Date')
}
-class FieldsDialog (Utils.GladeWindow):
-
+class FieldsDialog (Utils.Builder):
gladeinfo = {
-
- 'file': 'fields1.glade',
+ 'file': 'fields1.ui',
'name': 'fields',
'root': 'fields1'
-
}
- def __init__ (self, parent = None):
+ def __init__(self, parent=None):
- Utils.GladeWindow.__init__ (self, parent)
+ Utils.Builder.__init__(self, parent)
- self.dialog = self.xml.get_widget ('fields1')
- self.w = self.xml.get_widget ('notebook')
+ self.dialog = self.xml.get_object('fields1')
+ self.w = self.xml.get_object('notebook')
## tooltips = gtk.Tooltips ()
## tooltips.enable ()
@@ -77,7 +75,7 @@ class FieldsDialog (Utils.GladeWindow):
self.dialog.show_all ()
def on_close (self, w):
- self.dialog.hide_all()
+ self.dialog.hide()
self.size_save ()
return
@@ -118,8 +116,9 @@ class FieldsDialog (Utils.GladeWindow):
# Page 1
def init_page_1 (self):
+ self.menu_items = []
- self.fields1 = self.xml.get_widget('f_list_1')
+ self.fields1 = self.xml.get_object('f_list_1')
rend = gtk.CellRendererText()
col = gtk.TreeViewColumn(_('Name'), rend, text = 0)
self.fields1.append_column(col)
@@ -127,8 +126,7 @@ class FieldsDialog (Utils.GladeWindow):
col = gtk.TreeViewColumn(_('Type'), rend, text = 1)
self.fields1.append_column(col)
- self.fm = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
- gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
+ self.fm = gtk.ListStore(str, str, str, object)
self.sfm = gtk.TreeModelSort(self.fm)
self.sfm.set_sort_column_id(2, gtk.SORT_ASCENDING)
self.fields1.set_model(self.sfm)
@@ -139,14 +137,19 @@ class FieldsDialog (Utils.GladeWindow):
self.fm.append((item.name,
_typename [item.type], key, item))
- self.name1 = self.xml.get_widget('name1')
- self.menu1 = self.xml.get_widget('type1')
- menu = gtk.Menu ()
- self.menu1.set_menu (menu)
- self.menu_items = _typename.keys ()
- for item in self.menu_items:
- Utils.popup_add (menu, _typename [item], self.select_menu, item)
- self.menu1.set_history (0)
+ self.name1 = self.xml.get_object('name1')
+ self.menu1 = self.xml.get_object('type1')
+
+ name_store = gtk.ListStore(str, object)
+ for k, v in sorted(_typename.items(), key=lambda x: x[1]):
+ name_store.append([v, k])
+ self.menu1.set_model(name_store)
+ self.menu1.set_entry_text_column(0)
+ renderer_text = gtk.CellRendererText()
+ self.menu1.pack_start(renderer_text, True)
+ self.menu1.add_attribute(renderer_text, 'text', 0)
+ self.menu1.set_active(0)
+ self.menu_items = [x[1] for x in name_store]
self.current_menu = self.menu_items [0]
self.check()
@@ -182,10 +185,9 @@ class FieldsDialog (Utils.GladeWindow):
data = self.fm[p]
self.name1.set_text(self.fm[p][0])
try:
- self.menu1.set_history (
- self.menu_items.index(self.fm[p][3].type))
+ self.menu1.set_active(self.menu_items.index(self.fm[p][3].type))
except ValueError:
- print self.menu_items, self.fm[p][0], self.fm[p][2]
+ print(self.menu_items, self.fm[p][0], self.fm[p][2])
def on_name1_changed (self, *args):
sel = self.fields1.get_selection()
@@ -204,7 +206,10 @@ class FieldsDialog (Utils.GladeWindow):
self.change_fields()
def on_type1_changed (self, *args):
- x = self.menu_items[self.menu1.get_history()]
+ if len(self.menu_items) <= 0:
+ return
+
+ x = self.menu_items[self.menu1.get_active()]
sel = self.fields1.get_selection()
m, iter = sel.get_selected()
if iter:
@@ -222,10 +227,8 @@ class FieldsDialog (Utils.GladeWindow):
def init_page_2 (self):
# PAGE 2
- self.entries2 = self.xml.get_widget('e_list_2')
- self.em = gtk.ListStore(gobject.TYPE_STRING,
- gobject.TYPE_PYOBJECT,
- gobject.TYPE_STRING )
+ self.entries2 = self.xml.get_object('e_list_2')
+ self.em = gtk.ListStore(str, object, str)
self.entries = copy.copy (Config.get ('base/entries').data)
for i in self.entries.itervalues():
self.em.append ((i.name, i, i.name.lower()))
@@ -235,7 +238,7 @@ class FieldsDialog (Utils.GladeWindow):
rend = gtk.CellRendererText()
col = gtk.TreeViewColumn(_('Entry type'), rend, text = 0)
self.entries2.append_column(col)
- self.name2 = self.xml.get_widget('name2')
+ self.name2 = self.xml.get_object('name2')
self.s2 = self.entries2.get_selection()
self.s2.connect('changed', self.elist_select)
self.check()
@@ -294,14 +297,14 @@ class FieldsDialog (Utils.GladeWindow):
def init_page_3 (self):
- self.flist3a = self.xml.get_widget ('f_list_3a')
+ self.flist3a = self.xml.get_object('f_list_3a')
self.flist3a.set_model (self.sfm)
rend = gtk.CellRendererText()
col = gtk.TreeViewColumn(_('Available'), rend, text = 0)
self.flist3a.append_column(col)
self.s3a = self.flist3a.get_selection()
- self.label3 = self.xml.get_widget ('entry_type_label')
- self.flist3b = self.xml.get_widget ('f_list_3b')
+ self.label3 = self.xml.get_object('entry_type_label')
+ self.flist3b = self.xml.get_object('f_list_3b')
rend = gtk.CellRendererToggle()
rend.connect('toggled', self.toggle_mandatory)
col = gtk.TreeViewColumn('X', rend, active = 1)
@@ -309,10 +312,7 @@ class FieldsDialog (Utils.GladeWindow):
rend = gtk.CellRendererText()
col = gtk.TreeViewColumn(_('Associated'), rend, text = 2)
self.flist3b.append_column(col)
- self.sm = gtk.ListStore(gobject.TYPE_STRING,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_STRING,
- gobject.TYPE_PYOBJECT)
+ self.sm = gtk.ListStore(str, bool, str, object)
self.ssm = gtk.TreeModelSort(self.sm)
self.ssm.set_sort_column_id(0, gtk.SORT_ASCENDING)
self.flist3b.set_model(self.ssm)
diff --git a/Pyblio/GnomeUI/glade/Makefile.am b/Pyblio/GnomeUI/glade/Makefile.am
index 0a20c67..61e06cb 100644
--- a/Pyblio/GnomeUI/glade/Makefile.am
+++ b/Pyblio/GnomeUI/glade/Makefile.am
@@ -2,7 +2,7 @@ gladedir = $(datadir)/$(PACKAGE)/Pyblio/GnomeUI/glade
appicondir = $(datadir)/$(PACKAGE)/pixmaps
glade_DATA = \
- fields1.glade \
+ fields.ui \
pyblio.ui \
search.glade \
sort.ui \
diff --git a/Pyblio/GnomeUI/glade/fields.ui b/Pyblio/GnomeUI/glade/fields.ui
new file mode 100644
index 0000000..3ee066f
--- /dev/null
+++ b/Pyblio/GnomeUI/glade/fields.ui
@@ -0,0 +1,443 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.24"/>
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="fields1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes">Entry types and field names configuration</property>
+ <property name="type_hint">normal</property>
+ <property name="has_separator">True</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="helpbutton">
+ <property name="label">gtk-help</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_help" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="removebutton">
+ <property name="label">gtk-remove</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_remove" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="addbutton">
+ <property name="label">gtk-add</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_add" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="closebutton">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_close" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkNotebook" id="notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTreeView" id="f_list_1">
+ <property name="width_request">153</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">6</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Name </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="name1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="text" translatable="yes">Editor</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <signal name="changed" handler="on_name1_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Type</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="type1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <signal name="changed" handler="on_type1_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Fields </property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTreeView" id="e_list_2">
+ <property name="width_request">173</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="reorderable">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox3">
+ <property name="width_request">125</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0.059999998658895493</property>
+ <property name="label" translatable="yes">Entry type</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="name2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="width_chars">20</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <signal name="changed" handler="on_name2_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xpad">12</property>
+ <property name="ypad">12</property>
+ <property name="label" translatable="yes">Select an entry type and specify
+its associated (mandatory and
+optional) fields on the next page.
+
+
+
+</property>
+ <property name="justify">fill</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Entries</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkHBox" id="hbox4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="entry_type_label">
+ <property name="height_request">16</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Information for <b>Article</b>
entry type</property>
+ <property name="use_markup">True</property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="padding">12</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">6</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow5">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTreeView" id="f_list_3a">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="padding">6</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow6">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTreeView" id="f_list_3b">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Association</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-11">helpbutton</action-widget>
+ <action-widget response="-6">removebutton</action-widget>
+ <action-widget response="-5">addbutton</action-widget>
+ <action-widget response="-7">closebutton</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5ff69e3..1220048 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -41,7 +41,7 @@ Pyblio/GnomeUI/Sort.py
Pyblio/GnomeUI/Utils.py
Pyblio/GnomeUI/__init__.py
Pyblio/GnomeUI/glade/config1.glade
-Pyblio/GnomeUI/glade/fields1.glade
+Pyblio/GnomeUI/glade/fields.ui
Pyblio/GnomeUI/glade/format.ui
Pyblio/GnomeUI/glade/medline.glade
Pyblio/GnomeUI/glade/openurl.ui
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]