Help with an Epilicious patch
- From: "Andrew Conkling" <andrew conkling gmail com>
- To: epiphany-list gnome org
- Subject: Help with an Epilicious patch
- Date: Mon, 31 Jul 2006 20:01:49 -0400
Hello all,
I'm working on a GUI configuration for epilicious but am having a bit
of trouble. I'm having a hard time setting the gconf keys; the
appropriate events are triggered but the options never "make it"
there.
Also, I'd like the menu item to show up beneath the "Extensions..."
item. I took a look at the code for the Python Console (which does
this) but was unable to see any significant difference.
Attached is my patch against the development branch [1]. Any help
would be much appreciated; this is my first work on Epiphany. (I am
having a lot of fun with it. :)
Cheers,
Andrew Conkling
[1] http://therning.org/magnus/computer/epilicious
=== added file 'libepilicious/config.py'
--- /dev/null
+++ libepilicious/config.py
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2006 by Magnus Therning
+
+# 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 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.
+
+# 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
+
+import libepilicious
+import gtk, gtk.glade
+import gconf
+import os
+
+class ConfigWindow:
+
+ def __init__(self):
+ self.gui = gtk.glade.XML(os.path.join(libepilicious.LOCATION, \
+ 'libepilicious', 'epilicious.glade'))
+ self.gui.signal_autoconnect(self)
+
+ # I can't remember how to get the whole friggin' lot of 'em...
+ self.config = self.gui.get_widget('dlgConfig')
+ self.entname = self.gui.get_widget('entname')
+ self.entpassword = self.gui.get_widget('entpassword')
+ self.enttag = self.gui.get_widget('enttag')
+ self.rbinclude = self.gui.get_widget('rbinclude')
+ self.rbexclude = self.gui.get_widget('rbexclude')
+ self.btnhelp = self.gui.get_widget('btnhelp')
+ self.btnclose = self.gui.get_widget('btnclose')
+ self.client = gconf.client_get_default ()
+
+ # For some reason this gets messed up if set in Glade
+ self.entpassword.set_visibility(False)
+ self.entpassword.set_invisible_char('â??')
+
+ def show(self):
+ self.entname.set_text(self.client.get_string('/apps/epiphany/extensions/epilicious/username'))
+ self.entpassword.set_text(self.client.get_string('/apps/epiphany/extensions/epilicious/password'))
+ self.enttag.set_text(self.client.get_string('/apps/epiphany/extensions/epilicious/keyword'))
+ # Set radio buttons
+ self.rbexclude.set_active(self.client.get_bool('/apps/epiphany/extensions/epilicious/exclude'))
+
+ def hide(self):
+ # Make sure all settings have been applied
+ #self.config.hide()
+ self.client.set_string('/apps/epiphany/extensions/epilicious/username', self.entname.get_text())
+ self.client.set_string('/apps/epiphany/extensions/epilicious/password', self.entpassword.get_text())
+ self.client.set_string('/apps/epiphany/extensions/epilicious/keyword', self.enttag.get_text())
+ self.client.set_bool('/apps/epiphany/extensions/epilicious/exclude', self.rbexclude.get_active())
+ return False
+
+ ### signal handlers
+ def on_entname_focus_out_event(self, widget):
+ print 'focus out'
+ self.client.set_string('/apps/epiphany/extensions/epilicious/username', self.entname.get_text())
+
+ def on_entpassword_focus_out_event(self, widget):
+ self.client.set_string('/apps/epiphany/extensions/epilicious/password', self.entpassword.get_text())
+
+ def on_enttag_focus_out_event(self, widget):
+ self.client.set_string('/apps/epiphany/extensions/epilicious/keyword', self.enttag.get_text())
+
+ def on_rb_clicked(self, widget):
+ self.client.set_bool('/apps/epiphany/extensions/epilicious/exclude', self.rbexclude.get_active())
+ pass
+
+ def on_btnhelp_clicked(self, widget):
+ # Figure out how to open help and open it to the yet-unwritten
+ # Epilicious help file. :)
+ pass
+
+ def on_btnclose_clicked(self, widget):
+ self.hide()
+ del(self)
=== added file 'libepilicious/epilicious.glade'
--- /dev/null
+++ libepilicious/epilicious.glade
@@ -0,0 +1,315 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkDialog" id="dlgconfig">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes" context="yes">Epilicious Configuration</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_EDGE</property>
+
+ <child>
+ <widget class="GtkButton" id="btnhelp">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="label">gtk-help</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="on_btnhelp_clicked" last_modification_time="Mon, 17 Jul 2006 00:06:24 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="btnclose">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="on_btnclose_clicked" last_modification_time="Sun, 16 Jul 2006 21:12:20 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="n_rows">4</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">1</property>
+ <property name="column_spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="lblName">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" context="yes">_Name:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">entname</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="lblpassword">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" context="yes">_Password:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">entpassword</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="lbltag">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" context="yes">_Tag:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">enttag</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="lblaction">
+ <property name="width_request">120</property>
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" context="yes">Action for tagged bookmarks:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">True</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">rbinclude</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="entname">
+ <property name="visible">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">â??</property>
+ <property name="activates_default">False</property>
+ <signal name="focus_out_event" handler="on_entname_focus_out_event" last_modification_time="Sun, 23 Jul 2006 02:49:10 GMT"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="entpassword">
+ <property name="visible">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">â??</property>
+ <property name="activates_default">False</property>
+ <signal name="focus_out_event" handler="on_entpassword_focus_out_event" last_modification_time="Sun, 23 Jul 2006 02:49:20 GMT"/>
+ </widget>
+ <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>
+
+ <child>
+ <widget class="GtkEntry" id="enttag">
+ <property name="visible">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">â??</property>
+ <property name="activates_default">False</property>
+ <signal name="focus_out_event" handler="on_enttag_focus_out_event" last_modification_time="Sun, 23 Jul 2006 02:49:29 GMT"/>
+ </widget>
+ <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>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkRadioButton" id="rbinclude">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" context="yes">_Include</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="clicked" handler="on_rb_clicked" last_modification_time="Sun, 23 Jul 2006 17:12:16 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkRadioButton" id="rbexclude">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" context="yes">_Exclude</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">rbinclude</property>
+ <signal name="clicked" handler="on_rb_clicked" last_modification_time="Sun, 23 Jul 2006 17:12:27 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">fill</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
=== modified file 'epilicious.m4.py'
--- epilicious.m4.py
+++ epilicious.m4.py
@@ -97,6 +97,12 @@
gobject.idle_add(sync_gen.next)
libepilicious.get_logger().info('Sync done')
+def _CB_Config(action, window):
+ from libepilicious.config import ConfigWindow
+ config = ConfigWindow()
+ config.show()
+ #libepilicious.get_logger().info('Setting configuration')
+
def _do_sync():
'''Perform the synchronisation.
@@ -167,7 +173,6 @@
except:
libepilicious.get_logger().exception('Failed sync')
-
## Epiphany integration ##
_menu_ui = '''
@@ -178,6 +183,9 @@
<menuitem name="%s" action="EpiliciousSync" />
<separator />
</menu>
+ <menu name="ToolsMenu" action="Tools">
+ <menuitem name="EpiliciousConfig" action="EpiliciousConfig"/>
+ </menu>
</menubar>
</ui>
''' % (_('Epilicious Synchronize'))
@@ -185,6 +193,8 @@
_actions = [ \
('EpiliciousSync', None, _('Epilicious Synchronize'),
None, None, _CB_Sync), \
+ ('EpiliciousConfig', None, ('Epilicious Configuration'),
+ None, None, _CB_Config), \
]
# Epiphany extension interface
=== modified file 'libepilicious/__init__.py'
--- libepilicious/__init__.py
+++ libepilicious/__init__.py
@@ -48,7 +48,7 @@
def get_old():
'''Read the base snapshot.
- The base snapshot is read from ~/.gnome2/epiphany/epilicoius_old.
+ The base snapshot is read from ~/.gnome2/epiphany/epilicious_old.
@return: the base snapshot (an empty dictionary if none exists)
'''
@@ -64,7 +64,7 @@
def save_snapshot(snap):
'''Save a snapshot for future synchronisations.
- The base snapshot is written to ~/.gnome2/epiphany/epilicoius_old.
+ The base snapshot is written to ~/.gnome2/epiphany/epilicious_old.
@param snap: The snapshot
'''
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]