2 # -*- coding: utf-8 -*-
5 This file is part of Multilist.
7 Multilist is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 Multilist is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Multilist. If not, see <http://www.gnu.org/licenses/>.
20 Copyright (C) 2008 Christoph Würstle
37 _moduleLogger = logging.getLogger(__name__)
40 class Bottombar(gtk.VBox):
45 def __init__(self, db, view, isHildon):
46 gtk.VBox.__init__(self, homogeneous = False, spacing = 3)
49 self.isHildon = isHildon
52 _moduleLogger.info("libBottomBar, init")
54 buttonHBox = gtk.HBox()
55 self.pack_start(buttonHBox, expand = False, fill = True, padding = 3)
57 button = gtk.Button(stock = gtk.STOCK_ADD)
58 button.connect("clicked", self.new_item, None)
59 buttonHBox.pack_start(button, expand = True, fill = True, padding = 3)
61 button = gtk.Button(stock = gtk.STOCK_DELETE)
62 button.connect("clicked", self.del_item, None)
63 buttonHBox.pack_start(button, expand = True, fill = True, padding = 3)
65 @gtk_toolbox.log_exception(_moduleLogger)
66 def new_item(self, widget = None, data1 = None, data2 = None):
67 dialog = gtk.Dialog(_("New item name:"), None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
68 dialog.set_position(gtk.WIN_POS_CENTER)
69 entryKlasse = gtk.Entry()
70 entryKlasse.set_text("")
72 dialog.vbox.pack_start(entryKlasse, True, True, 0)
74 dialog.vbox.show_all()
75 #dialog.set_size_request(400, 300)
77 if dialog.run() == gtk.RESPONSE_ACCEPT:
78 #_moduleLogger.info("new category name "+entryKlasse.get_text())
79 #self.view.liststorehandler.rename_category(entryKlasse.get_text())
80 self.view.liststorehandler.add_row(entryKlasse.get_text())
83 @gtk_toolbox.log_exception(_moduleLogger)
84 def del_item(self, widget = None, data1 = None, data2 = None):
85 path, col = self.view.treeview.get_cursor()
87 mbox = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, _("Delete current item?"))
91 if response == gtk.RESPONSE_YES:
92 self.view.del_active_row()
94 mbox = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("No item selected!"))
99 def rename_category(self, widget = None, data1 = None, data2 = None):
100 dialog = gtk.Dialog(_("New category name:"), None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
102 dialog.set_position(gtk.WIN_POS_CENTER)
103 entryKlasse = gtk.Entry()
104 entryKlasse.set_text(self.view.liststorehandler.selection.get_category())
106 dialog.vbox.pack_start(entryKlasse, True, True, 0)
108 dialog.vbox.show_all()
110 if dialog.run() == gtk.RESPONSE_ACCEPT:
111 _moduleLogger.info("new category name "+entryKlasse.get_text())
112 self.view.liststorehandler.rename_category(entryKlasse.get_text())
117 def rename_list(self, widget = None, data1 = None, data2 = None):
118 dialog = gtk.Dialog(_("New list name:"), None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
120 dialog.set_position(gtk.WIN_POS_CENTER)
121 entryKlasse = gtk.Entry()
122 entryKlasse.set_text(self.view.liststorehandler.selection.get_list())
124 dialog.vbox.pack_start(entryKlasse, True, True, 0)
126 dialog.vbox.show_all()
128 if dialog.run() == gtk.RESPONSE_ACCEPT:
129 _moduleLogger.info("new list name "+entryKlasse.get_text())
130 self.view.liststorehandler.rename_list(entryKlasse.get_text())