Merge lp:~jbernard/acire/no-desktop-couch into lp:acire

Proposed by Andrea Colangelo
Status: Needs review
Proposed branch: lp:~jbernard/acire/no-desktop-couch
Merge into: lp:acire
Diff against target: 250 lines (+1/-217)
4 files modified
acire/PreferencesAcireDialog.py (+0/-131)
bin/acire (+1/-10)
data/ui/PreferencesAcireDialog.ui (+0/-67)
data/ui/preferences_acire_dialog.xml (+0/-9)
To merge this branch: bzr merge lp:~jbernard/acire/no-desktop-couch
Reviewer Review Type Date Requested Status
Jono Bacon Pending
Review via email: mp+75899@code.launchpad.net

Commit message

Drop unused preferences dialog code and dependency on desktop-couch. Fixes: #531059

Description of the change

Drop unused preferences dialog code and dependency on desktop-couch. Fixes: #531059

To post a comment you must log in.

Unmerged revisions

48. By Jon Bernard

Remove preferences files and dependency on desktop-couch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed file 'acire/PreferencesAcireDialog.py'
--- acire/PreferencesAcireDialog.py 2010-02-26 13:49:32 +0000
+++ acire/PreferencesAcireDialog.py 1970-01-01 00:00:00 +0000
@@ -1,131 +0,0 @@
1# -*- coding: utf-8 -*-
2### BEGIN LICENSE
3# Copyright (C) 2009 Jono Bacon <jono@ubuntu.com>
4#This program is free software: you can redistribute it and/or modify it
5#under the terms of the GNU General Public License version 3, as published
6#by the Free Software Foundation.
7#
8#This program is distributed in the hope that it will be useful, but
9#WITHOUT ANY WARRANTY; without even the implied warranties of
10#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11#PURPOSE. See the GNU General Public License for more details.
12#
13#You should have received a copy of the GNU General Public License along
14#with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE
16
17import sys
18import os
19import gtk
20from desktopcouch.records.server import CouchDatabase
21from desktopcouch.records.record import Record
22
23from acire.acireconfig import getdatapath
24
25class PreferencesAcireDialog(gtk.Dialog):
26 __gtype_name__ = "PreferencesAcireDialog"
27 prefernces = {}
28
29 def __init__(self):
30 """__init__ - This function is typically not called directly.
31 Creation of a PreferencesAcireDialog requires redeading the associated ui
32 file and parsing the ui definition extrenally,
33 and then calling PreferencesAcireDialog.finish_initializing().
34
35 Use the convenience function NewPreferencesAcireDialog to create
36 NewAboutAcireDialog objects.
37 """
38
39 pass
40
41 def finish_initializing(self, builder):
42 """finish_initalizing should be called after parsing the ui definition
43 and creating a AboutAcireDialog object with it in order to finish
44 initializing the start of the new AboutAcireDialog instance.
45 """
46
47 #get a reference to the builder and set up the signals
48 self.builder = builder
49 self.builder.connect_signals(self)
50
51 #set up couchdb and the preference info
52 self.__db_name = "acire"
53 self.__database = CouchDatabase(self.__db_name, create=True)
54 self.__preferences = None
55 self.__key = None
56
57 #set the record type and then initalize the preferences
58 self.__record_type = "http://wiki.ubuntu.com/Quickly/RecordTypes/Acire/Preferences"
59 self.__preferences = self.get_preferences()
60 #TODO:code for other initialization actions should be added here
61
62 def get_preferences(self):
63 """get_preferences -returns a dictionary object that contain
64 preferences for acire. Creates a couchdb record if
65 necessary.
66 """
67
68 if self.__preferences == None: #the dialog is initializing
69 self.__load_preferences()
70
71 #if there were no saved preference, this
72 return self.__preferences
73
74 def __load_preferences(self):
75 #TODO: add prefernces to the self.__preferences dict
76 #default preferences that will be overwritten if some are saved
77 self.__preferences = {"record_type":self.__record_type}
78
79 results = self.__database.get_records(record_type=self.__record_type, create_view=True)
80
81 if len(results.rows) == 0:
82 #no preferences have ever been saved
83 #save them before returning
84 self.__key = self.__database.put_record(Record(self.__preferences))
85 else:
86 self.__preferences = results.rows[0].value
87 self.__key = results.rows[0].value["_id"]
88
89 def __save_preferences(self):
90 self.__database.update_fields(self.__key, self.__preferences)
91
92 def ok(self, widget, data=None):
93 """ok - The user has elected to save the changes.
94 Called before the dialog returns gtk.RESONSE_OK from run().
95 """
96
97 #make any updates to self.__preferences here
98 #self.__preferences["preference1"] = "value2"
99 self.__save_preferences()
100
101 def cancel(self, widget, data=None):
102 """cancel - The user has elected cancel changes.
103 Called before the dialog returns gtk.RESPONSE_CANCEL for run()
104 """
105
106 #restore any changes to self.__preferences here
107 pass
108
109def NewPreferencesAcireDialog():
110 """NewPreferencesAcireDialog - returns a fully instantiated
111 PreferencesAcireDialog object. Use this function rather than
112 creating a PreferencesAcireDialog instance directly.
113 """
114
115 #look for the ui file that describes the ui
116 ui_filename = os.path.join(getdatapath(), 'ui', 'PreferencesAcireDialog.ui')
117 if not os.path.exists(ui_filename):
118 ui_filename = None
119
120 builder = gtk.Builder()
121 builder.set_translation_domain('acire')
122 builder.add_from_file(ui_filename)
123 dialog = builder.get_object("preferences_acire_dialog")
124 dialog.finish_initializing(builder)
125 return dialog
126
127if __name__ == "__main__":
128 dialog = NewPreferencesAcireDialog()
129 dialog.show()
130 gtk.main()
131
1320
=== modified file 'bin/acire'
--- bin/acire 2010-03-26 19:41:43 +0000
+++ bin/acire 2011-09-18 14:44:26 +0000
@@ -46,7 +46,7 @@
46 fullPath = os.getcwd()46 fullPath = os.getcwd()
47sys.path.insert(0, os.path.dirname(fullPath))47sys.path.insert(0, os.path.dirname(fullPath))
4848
49from acire import AboutAcireDialog, PreferencesAcireDialog49from acire import AboutAcireDialog
50from acire.acireconfig import getdatapath50from acire.acireconfig import getdatapath
5151
52# Set up translations52# Set up translations
@@ -471,15 +471,6 @@
471 response = about.run()471 response = about.run()
472 about.destroy()472 about.destroy()
473473
474 def preferences(self, widget, data=None):
475 """preferences - display the preferences window for acire """
476 prefs = PreferencesAcireDialog.NewPreferencesAcireDialog()
477 response = prefs.run()
478 if response == gtk.RESPONSE_OK:
479 #make any updates based on changed preferences here
480 pass
481 prefs.destroy()
482
483 def quit(self, widget, data=None):474 def quit(self, widget, data=None):
484 """quit - signal handler for closing the AcireWindow"""475 """quit - signal handler for closing the AcireWindow"""
485 self.destroy()476 self.destroy()
486477
=== removed file 'data/ui/PreferencesAcireDialog.ui'
--- data/ui/PreferencesAcireDialog.ui 2010-02-26 13:49:32 +0000
+++ data/ui/PreferencesAcireDialog.ui 1970-01-01 00:00:00 +0000
@@ -1,67 +0,0 @@
1<?xml version="1.0"?>
2<interface>
3 <requires lib="gtk+" version="2.16"/>
4 <!-- interface-requires preferences_acire_dialog 1.0 -->
5 <!-- interface-naming-policy project-wide -->
6 <object class="PreferencesAcireDialog" id="preferences_acire_dialog">
7 <property name="border_width">5</property>
8 <property name="icon">../media/icon.png</property>
9 <property name="type_hint">normal</property>
10 <property name="has_separator">False</property>
11 <child internal-child="vbox">
12 <object class="GtkVBox" id="dialog-vbox1">
13 <property name="visible">True</property>
14 <property name="orientation">vertical</property>
15 <property name="spacing">2</property>
16 <child>
17 <placeholder/>
18 </child>
19 <child internal-child="action_area">
20 <object class="GtkHButtonBox" id="dialog-action_area1">
21 <property name="visible">True</property>
22 <property name="layout_style">end</property>
23 <child>
24 <object class="GtkButton" id="button2">
25 <property name="label">gtk-cancel</property>
26 <property name="visible">True</property>
27 <property name="can_focus">True</property>
28 <property name="receives_default">True</property>
29 <property name="use_stock">True</property>
30 <signal name="clicked" handler="cancel"/>
31 </object>
32 <packing>
33 <property name="expand">False</property>
34 <property name="fill">False</property>
35 <property name="position">0</property>
36 </packing>
37 </child>
38 <child>
39 <object class="GtkButton" id="button1">
40 <property name="label">gtk-ok</property>
41 <property name="visible">True</property>
42 <property name="can_focus">True</property>
43 <property name="receives_default">True</property>
44 <property name="use_stock">True</property>
45 <signal name="clicked" handler="ok"/>
46 </object>
47 <packing>
48 <property name="expand">False</property>
49 <property name="fill">False</property>
50 <property name="position">1</property>
51 </packing>
52 </child>
53 </object>
54 <packing>
55 <property name="expand">False</property>
56 <property name="pack_type">end</property>
57 <property name="position">0</property>
58 </packing>
59 </child>
60 </object>
61 </child>
62 <action-widgets>
63 <action-widget response="-6">button2</action-widget>
64 <action-widget response="-5">button1</action-widget>
65 </action-widgets>
66 </object>
67</interface>
680
=== removed file 'data/ui/preferences_acire_dialog.xml'
--- data/ui/preferences_acire_dialog.xml 2009-12-29 12:07:58 +0000
+++ data/ui/preferences_acire_dialog.xml 1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
1<glade-catalog name="preferences_acire_dialog" domain="glade-3"
2 depends="gtk+" version="1.0">
3 <glade-widget-classes>
4 <glade-widget-class title="Acire Preferences Dialog" name="PreferencesAcireDialog"
5 generic-name="PreferenceAcireDialog" parent="GtkDialog"
6 icon-name="widget-gtk-dialog"/>
7 </glade-widget-classes>
8
9</glade-catalog>

Subscribers

People subscribed via source and target branches