[pybliographer] ui: Port search dialog to GtkBuilder
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pybliographer] ui: Port search dialog to GtkBuilder
- Date: Tue, 27 Mar 2018 03:43:43 +0000 (UTC)
commit d09776042b6f49c1e888a3ae597e8433eb38cf52
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Mon Mar 26 22:18:11 2018 -0300
ui: Port search dialog to GtkBuilder
Pyblio/GnomeUI/Config.py | 25 +-
Pyblio/GnomeUI/Search.py | 76 ++--
Pyblio/GnomeUI/glade/Makefile.am | 4 +-
Pyblio/GnomeUI/glade/config.ui | 54 +++
Pyblio/GnomeUI/glade/config1.glade | 721 ------------------------------------
Pyblio/GnomeUI/glade/search.glade | 454 -----------------------
Pyblio/GnomeUI/glade/search.ui | 237 ++++++++++++
po/POTFILES.in | 4 +-
8 files changed, 341 insertions(+), 1234 deletions(-)
---
diff --git a/Pyblio/GnomeUI/Config.py b/Pyblio/GnomeUI/Config.py
index f73b2d6..21dd650 100644
--- a/Pyblio/GnomeUI/Config.py
+++ b/Pyblio/GnomeUI/Config.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
@@ -22,7 +23,7 @@
# TO DO:
# List view troubles
-import gobject, gtk, gtk.glade
+import gobject, gtk
import copy, os.path, re, string
@@ -33,20 +34,18 @@ from Pyblio.Utils import format
_map = string.maketrans ('\t\n', ' ')
_cpt = re.compile ('\s+')
-class ConfigDialog (Utils.GladeWindow):
-
+class ConfigDialog (Utils.Builder):
gladeinfo = {
- 'file': 'config1.glade',
- 'root': 'config1',
+ 'file': 'config.ui',
+ 'root': 'config',
'name': 'configuration'
}
- def __init__ (self, parent = None):
-
- Utils.GladeWindow.__init__ (self, parent, window = 'config1')
+ def __init__(self, parent=None):
+ Utils.Builder.__init__(self, parent, window='config')
- self.dialog = self.xml.get_widget ('config1')
- content = self.xml.get_widget ('dialog-vbox1')
+ self.dialog = self.xml.get_object('config')
+ content = self.xml.get_object('dialog-vbox1')
self.w = gtk.Notebook ()
@@ -128,7 +127,7 @@ class ConfigDialog (Utils.GladeWindow):
def on_close1 (self, w):
self.size_save ()
- self.dialog.hide_all()
+ self.dialog.hide()
def show (self):
self.dialog.show_all()
diff --git a/Pyblio/GnomeUI/Search.py b/Pyblio/GnomeUI/Search.py
index 7f2cec3..e300ed0 100644
--- a/Pyblio/GnomeUI/Search.py
+++ b/Pyblio/GnomeUI/Search.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
@@ -34,31 +35,28 @@ from Pyblio import Types, Search, Config, \
from Pyblio.GnomeUI import Utils
-class SearchDialog (Connector.Publisher, Utils.GladeWindow):
-
+class SearchDialog (Connector.Publisher, Utils.Builder):
''' The actual Search Dialog. This dialog is created once, and
only hidden, not destroyed, to keep it always available in the
same state.
This dialog emits a "search-data" signal when a new search
criterion is selected.
-
'''
- gladeinfo = { 'name': 'search',
- 'file': 'search.glade',
- 'root': '_w_search'
+ gladeinfo = { 'file': 'search.ui',
+ 'root': '_w_search',
+ 'name': 'search'
}
- def __init__ (self, parent = None):
-
- Utils.GladeWindow.__init__ (self, parent)
+ def __init__(self, parent=None):
+ Utils.Builder.__init__(self, parent)
# the tree model contains a string that explains the query,
# and a python object representing the actual query.
- self._model = gtk.TreeStore (str, gobject.TYPE_PYOBJECT)
- self._w_tree.set_model (self._model)
+ self._model = gtk.TreeStore(str, object)
+ self._w_tree.set_model(self._model)
# the view does not display the python column, of course.
col = gtk.TreeViewColumn ('field', gtk.CellRendererText (), text = 0)
@@ -74,27 +72,27 @@ class SearchDialog (Connector.Publisher, Utils.GladeWindow):
self._selection = self._w_tree.get_selection ()
self._selection.connect ('changed', self.selection)
- # fill the combo containing the available fields
- self._w_field.set_popdown_strings ([' - any field - '] +
- list (Config.get
- ('gnome/searched').data) +
- [' - type - ', ' - key - '])
+ field_items = [' - any field - '] + \
+ list(Config.get('gnome/searched').data) + \
+ [' - type - ', ' - key - ']
+
+ for f in field_items:
+ self._w_field.append_text(f)
+
+ self._w_field.set_active(0)
# connect a menu to the right button
self.menu = gtk.Menu ()
self.delete_button = Utils.popup_add (self.menu, _("Delete"),
self.search_delete)
- self.menu.show ()
# We are set up.
- self.show ()
- return
-
+ self.show()
def show (self):
''' Invoked to show the interface again when it has been closed '''
- self._w_search.show ()
+ self._w_search.show_all()
return
@@ -103,11 +101,8 @@ class SearchDialog (Connector.Publisher, Utils.GladeWindow):
self.size_save ()
self._w_search.hide ()
- return
-
def apply_cb (self, widget):
-
''' Construct the new query and add it to the query tree '''
page = self._w_notebook.get_current_page ()
@@ -126,14 +121,14 @@ class SearchDialog (Connector.Publisher, Utils.GladeWindow):
'before' : TextUI.before,
'after' : TextUI.after,
}
-
- search = self._w_expert_text.get_text ().encode ('latin-1')
+
+ search = self._w_expert.get_text().encode('latin-1')
try:
exec ('tester = ' + search, user_global)
except:
etype, value, tb = sys.exc_info ()
- traceback.print_exception (etype, value, tb)
+ traceback.print_exception (etype, value, tb)
d = gtk.MessageDialog (self._w_search,
gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL,
@@ -147,9 +142,8 @@ class SearchDialog (Connector.Publisher, Utils.GladeWindow):
# Simple Search
elif page == 0:
-
- field = self._w_field_text.get_text ().lower ()
- match = self._w_pattern_text.get_text ()
+ field = self._w_field.get_active_text().lower()
+ match = self._w_pattern.get_text()
if match == '': return
@@ -206,26 +200,24 @@ class SearchDialog (Connector.Publisher, Utils.GladeWindow):
name = str (test)
# Get the path to the query being refined
- s, iter = self._selection.get_selected ()
- if iter is None: iter = s.get_iter ((0,))
+ s, parent = self._selection.get_selected()
+ if parent is None: parent = s.get_iter((0,))
- i = s.get_path (iter)
+ parent_path = s.get_path(parent)
# If we are refining a previous query, build the new query as
# a logical and of the previous and new query.
- current = self._model [i] [1]
+ current = self._model[parent_path][1]
if current: test = current & test
# Add the new query in the tree and ensure it is visible and selected.
- iter = self._model.append (iter, (name, test))
- path = s.get_path (iter)
-
- self._w_tree.expand_row (path [:-1], True)
+ child = self._model.append(parent, (name, test))
+ path = s.get_path(child)
+
+ self._w_tree.expand_row(parent_path, True)
self._selection.select_path (path)
- return
-
def selection (self, *arg):
''' Called when the user clicks on a specific query '''
diff --git a/Pyblio/GnomeUI/glade/Makefile.am b/Pyblio/GnomeUI/glade/Makefile.am
index 61e06cb..31398ed 100644
--- a/Pyblio/GnomeUI/glade/Makefile.am
+++ b/Pyblio/GnomeUI/glade/Makefile.am
@@ -4,11 +4,11 @@ appicondir = $(datadir)/$(PACKAGE)/pixmaps
glade_DATA = \
fields.ui \
pyblio.ui \
- search.glade \
+ search.ui \
sort.ui \
format.ui \
medline.glade \
- config1.glade \
+ config.ui \
openurl.ui
EXTRA_DIST = $(glade_DATA) pyblio.ui.in
diff --git a/Pyblio/GnomeUI/glade/config.ui b/Pyblio/GnomeUI/glade/config.ui
new file mode 100644
index 0000000..2d7145e
--- /dev/null
+++ b/Pyblio/GnomeUI/glade/config.ui
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.24"/>
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="config">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Pybliographer Configuration</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="helpbutton1">
+ <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>
+ <accelerator key="Escape" signal="clicked"/>
+ <signal name="clicked" handler="on_close1" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</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>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-7">helpbutton1</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/Pyblio/GnomeUI/glade/search.ui b/Pyblio/GnomeUI/glade/search.ui
new file mode 100644
index 0000000..85f404d
--- /dev/null
+++ b/Pyblio/GnomeUI/glade/search.ui
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.24"/>
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="_w_search">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Search</property>
+ <property name="type_hint">normal</property>
+ <property name="has_separator">True</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button2">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="close_cb" 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="button1">
+ <property name="label">gtk-find</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="apply_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</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="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkNotebook" id="_w_notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Field</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Pattern</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="_w_field">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">liststore_field</property>
+ <property name="has_entry">True</property>
+ <property name="entry_text_column">0</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="_w_pattern">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</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>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Simple Search</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTable" id="table2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">2</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Query</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkEntry" id="_w_expert">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</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>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Expert Search</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkTreeView" id="_w_tree">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ <signal name="button-press-event" handler="popup_menu" swapped="no"/>
+ </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">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">button2</action-widget>
+ <action-widget response="0">button1</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkListStore" id="liststore_field">
+ <columns>
+ <!-- column-name field -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1220048..c9aca47 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -40,13 +40,13 @@ Pyblio/GnomeUI/Search.py
Pyblio/GnomeUI/Sort.py
Pyblio/GnomeUI/Utils.py
Pyblio/GnomeUI/__init__.py
-Pyblio/GnomeUI/glade/config1.glade
+Pyblio/GnomeUI/glade/config.ui
Pyblio/GnomeUI/glade/fields.ui
Pyblio/GnomeUI/glade/format.ui
Pyblio/GnomeUI/glade/medline.glade
Pyblio/GnomeUI/glade/openurl.ui
Pyblio/GnomeUI/glade/pyblio.ui.in
-Pyblio/GnomeUI/glade/search.glade
+Pyblio/GnomeUI/glade/search.ui
Pyblio/GnomeUI/glade/sort.ui
Pyblio/Help.py
Pyblio/Iterator.py
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]