[pybliographer] ui: Port format dialog to GtkBuilder
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pybliographer] ui: Port format dialog to GtkBuilder
- Date: Mon, 26 Mar 2018 20:38:44 +0000 (UTC)
commit ddd28121d60f76ba4b090c85eaff1eb90a0e235c
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Mon Mar 26 17:37:46 2018 -0300
ui: Port format dialog to GtkBuilder
Pyblio/GnomeUI/Format.py | 72 ++++++------
Pyblio/GnomeUI/glade/Makefile.am | 2 +-
Pyblio/GnomeUI/glade/format.glade | 244 -------------------------------------
Pyblio/GnomeUI/glade/format.ui | 171 ++++++++++++++++++++++++++
4 files changed, 208 insertions(+), 281 deletions(-)
---
diff --git a/Pyblio/GnomeUI/Format.py b/Pyblio/GnomeUI/Format.py
index f9eff74..5b80b1d 100644
--- a/Pyblio/GnomeUI/Format.py
+++ b/Pyblio/GnomeUI/Format.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,6 +23,7 @@
''' Defines a Dialog to format a subset of entries as a bibliography '''
import gtk
+import gobject
import string, os
@@ -29,8 +31,7 @@ from Pyblio import Connector, version, Autoload
from Pyblio.GnomeUI import Utils
-class FormatDialog (Connector.Publisher, Utils.GladeWindow):
-
+class FormatDialog(Connector.Publisher, Utils.Builder):
""" Class implementing the Format dialog. This class issues a
'format-query'
@@ -38,7 +39,7 @@ class FormatDialog (Connector.Publisher, Utils.GladeWindow):
signal when the user applies its settings
"""
- gladeinfo = { 'file': 'format.glade',
+ gladeinfo = { 'file': 'format.ui',
'root': '_w_format',
'name': 'format'
}
@@ -46,58 +47,57 @@ class FormatDialog (Connector.Publisher, Utils.GladeWindow):
style = os.path.join (version.pybdir, 'Styles', 'Alpha.xml')
output = None
- def __init__ (self, parent = None):
-
- Utils.GladeWindow.__init__ (self, parent)
+ def __init__ (self, parent=None):
+ Utils.Builder.__init__(self, parent)
- # Fill the output format drop-down menu
- menu = gtk.Menu ()
- self._w_menu.set_menu (menu)
+ cell = gtk.CellRendererText()
+ self._w_menu.pack_start (cell, True)
+ self._w_menu.add_attribute (cell, 'text', 0)
outlist = Autoload.available ('output')
outlist.sort ()
-
+
for avail in outlist:
- Utils.popup_add (menu, avail, self._menu_select, avail)
+ self._w_menu.append_text(avail)
- self._w_menu.set_history (0)
- self.menu_item = outlist [0]
+ self._w_menu.set_active(0)
+ self.menu_item = outlist[0]
- self._w_style_entry.set_default_path (FormatDialog.style)
- self._w_style.set_text (FormatDialog.style)
+ self._w_style.set_filename(FormatDialog.style)
if FormatDialog.output:
- self._w_output_entry.set_default_path (FormatDialog.output)
- self._w_output.set_text (FormatDialog.output)
-
- self._w_format.show ()
- return
+ self._w_output.set_filename(FormatDialog.output)
+ self._w_format.show ()
- def _menu_select (self, menu, item):
- self.menu_item = item
- return
-
+ def _menu_select(self, menu):
+ self.menu_item = menu.get_active_text()
- def _on_validate (self, * arg):
+ def _set_output_file(self, widget):
+ FormatDialog.output = self._w_output.get_filename()
+ self._w_output.set_filename(FormatDialog.output)
- style = self._w_style_entry.get_full_path (False)
- output = self._w_output_entry.get_full_path (False)
+ def _on_validate(self, *arg):
+ style = self._w_style.get_filename()
+ output = self._w_output.get_filename()
FormatDialog.style = style
FormatDialog.output = output
format = Autoload.get_by_name ('output', self.menu_item).data
+ # FIXME: We can't use GtkFileChooserButton for saving a file
+ # So, now we are not saving anything
+ if output is None:
+ import inspect
+ fname, lineno, funcname = inspect.getframeinfo(inspect.currentframe())[:3]
+ print 'FIXME: Data not saved. %s:%d (%s)' % (fname, lineno, funcname)
+
if style is None or output is None: return
self._w_format.destroy ()
self.issue ('format-query', style, format, output)
- return
-
-
- def _on_close (self, * arg):
- self.size_save ()
- self._w_format.destroy ()
- return
+ def _on_close(self, *arg):
+ self.size_save()
+ self._w_format.destroy()
diff --git a/Pyblio/GnomeUI/glade/Makefile.am b/Pyblio/GnomeUI/glade/Makefile.am
index 4812026..0a20c67 100644
--- a/Pyblio/GnomeUI/glade/Makefile.am
+++ b/Pyblio/GnomeUI/glade/Makefile.am
@@ -6,7 +6,7 @@ glade_DATA = \
pyblio.ui \
search.glade \
sort.ui \
- format.glade \
+ format.ui \
medline.glade \
config1.glade \
openurl.ui
diff --git a/Pyblio/GnomeUI/glade/format.ui b/Pyblio/GnomeUI/glade/format.ui
new file mode 100644
index 0000000..2917ccb
--- /dev/null
+++ b/Pyblio/GnomeUI/glade/format.ui
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.24"/>
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="_w_format">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Format entries</property>
+ <property name="type_hint">dialog</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="cancelbutton1">
+ <property name="label">gtk-cancel</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">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="okbutton1">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_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_validate" 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="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">5</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">Bibliography style:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </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">Output format:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Output file:</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton" id="_w_style">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton" id="_w_output">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Save formatted as</property>
+ <signal name="file-set" handler="_set_output_file" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="_w_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">liststore1</property>
+ <signal name="changed" handler="_menu_select" swapped="no"/>
+ </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>
+ <property name="y_options"/>
+ </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="-6">cancelbutton1</action-widget>
+ <action-widget response="-5">okbutton1</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name G_TYPE_STRING -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]