[pybliographer/wip/gtk3: 6/42] format: Port dialog to gtk+3
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pybliographer/wip/gtk3: 6/42] format: Port dialog to gtk+3
- Date: Sat, 7 Oct 2017 01:18:11 +0000 (UTC)
commit c2fac51e8dc089549a17a13cad76ea6ed6e9c156
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Wed May 29 23:57:18 2013 -0700
format: Port dialog to gtk+3
Regression: It is necessary to change the widget to choose
the output file
Signed-off-by: Germán Poo-Caamaño <gpoo gnome org>
Pyblio/GnomeUI/Format.py | 69 +++++------
Pyblio/GnomeUI/glade/Makefile.am | 2 +-
Pyblio/GnomeUI/glade/format.glade | 244 -------------------------------------
Pyblio/GnomeUI/glade/format.ui | 174 ++++++++++++++++++++++++++
4 files changed, 208 insertions(+), 281 deletions(-)
---
diff --git a/Pyblio/GnomeUI/Format.py b/Pyblio/GnomeUI/Format.py
index 0f2797f..f45bdbc 100644
--- a/Pyblio/GnomeUI/Format.py
+++ b/Pyblio/GnomeUI/Format.py
@@ -1,8 +1,11 @@
+# -*- coding: utf-8 -*-
# This file is part of pybliographer
#
# Copyright (C) 1998-2004 Frederic GOBRY
# Email : gobry pybliographer org
-#
+# Copyright (C) 2013 Germán Poo-Caamaño
+# Email : gpoo gnome org
+#
# 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
@@ -22,7 +25,6 @@
''' Defines a Dialog to format a subset of entries as a bibliography '''
from gi.repository import Gtk
-# from gnome import ui
import string, os
@@ -30,8 +32,7 @@ from Pyblio import Connector, version, Autoload
from Pyblio.GnomeUI import Utils
-class FormatDialog (Connector.Publisher, Utils.GladeWindow):
-
+class FormatDialog(Connector.Publisher, Utils.GladeWindow):
""" Class implementing the Format dialog. This class issues a
'format-query'
@@ -39,66 +40,62 @@ 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'
}
- style = os.path.join (version.pybdir, 'Styles', 'Alpha.xml')
+ style = os.path.join(version.pybdir, 'Styles', 'Alpha.xml')
output = None
- def __init__ (self, parent = None):
-
- Utils.GladeWindow.__init__ (self, parent)
-
- # Fill the output format drop-down menu
- menu = Gtk.Menu ()
- self._w_menu.set_menu (menu)
+ def __init__(self, parent=None):
+ Utils.GladeWindow.__init__(self, parent)
- outlist = Autoload.available ('output')
- outlist.sort ()
+ 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_output.set_filename(FormatDialog.output)
- self._w_format.show ()
- return
-
+ 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 _set_output_file(self, widget):
+ FormatDialog.output = self._w_output.get_filename()
+ self._w_output.set_filename(FormatDialog.output)
def _on_validate (self, * arg):
-
- style = self._w_style_entry.get_full_path (False)
- output = self._w_output_entry.get_full_path (False)
+ 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
+ self.size_save()
+ self._w_format.destroy()
diff --git a/Pyblio/GnomeUI/glade/Makefile.am b/Pyblio/GnomeUI/glade/Makefile.am
index 96936ca..0478bef 100644
--- a/Pyblio/GnomeUI/glade/Makefile.am
+++ b/Pyblio/GnomeUI/glade/Makefile.am
@@ -6,7 +6,7 @@ glade_DATA = \
pyblio.ui \
search.glade \
sort.glade \
- format.glade \
+ format.ui \
medline.glade \
config1.glade \
openurl.glade
diff --git a/Pyblio/GnomeUI/glade/format.ui b/Pyblio/GnomeUI/glade/format.ui
new file mode 100644
index 0000000..38ac575
--- /dev/null
+++ b/Pyblio/GnomeUI/glade/format.ui
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="_w_format">
+ <property name="width_request">300</property>
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Format entries</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" 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="use_action_appearance">False</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">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="okbutton1">
+ <property name="label">gtk-ok</property>
+ <property name="use_action_appearance">False</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>
+ <property name="image_position">top</property>
+ <signal name="clicked" handler="_on_validate" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</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="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</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"></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">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"></property>
+ </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"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton" id="_w_output">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</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">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton" id="_w_style">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</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="GtkComboBoxText" id="_w_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="entry_text_column">0</property>
+ <property name="id_column">1</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">GTK_FILL</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">cancelbutton1</action-widget>
+ <action-widget response="-5">okbutton1</action-widget>
+ </action-widgets>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]