diff --git a/plugins/gtkgui/config.py b/plugins/gtkgui/config.py index c8e24e90a..17c5f4b40 100644 --- a/plugins/gtkgui/config.py +++ b/plugins/gtkgui/config.py @@ -238,6 +238,19 @@ class preference_Window: self.plugin.sleeper = common.sleepy.Sleepy(\ self.plugin.config['autoawaytime']*60, \ self.plugin.config['autoxatime']*60) + #Status messages + model = self.msg_tree.get_model() + iter = model.get_iter_first() + i = 0 + while iter: + self.plugin.config['msg%i_name' % i] = model.get_value(iter, 0) + self.plugin.config['msg%i' % i] = model.get_value(iter, 1) + iter = model.iter_next(iter) + i += 1 + while self.plugin.config.has_key('msg%s_name' % i): + del self.plugin.config['msg%i_name' % i] + del self.plugin.config['msg%i' % i] + i += 1 #trayicon if self.chk_trayicon.get_active(): self.plugin.config['trayicon'] = 1 @@ -262,7 +275,51 @@ class preference_Window: def on_presence_button_clicked(self, widget, data=None): self.change_notebook_page(2) - + + def fill_msg_treeview(self): + i = 0 + self.xml.get_widget('delete_msg_button').set_sensitive(False) + model = self.msg_tree.get_model() + model.clear() + while self.plugin.config.has_key('msg%s_name' % i): + iter = model.append() + model.set(iter, 0, self.plugin.config['msg%s_name' % i], 1, self.plugin.config['msg%s' % i]) + i += 1 + + def on_msg_cell_edited(self, cell, row, new_text): + model = self.msg_tree.get_model() + iter = model.get_iter_from_string(row) + model.set_value(iter, 0, new_text) + + def on_msg_treeview_cursor_changed(self, widget, data=None): + self.xml.get_widget('delete_msg_button').set_sensitive(True) + buf = self.xml.get_widget('msg_textview').get_buffer() + (model, iter) = self.msg_tree.get_selection().get_selected() + name = model.get_value(iter, 0) + msg = model.get_value(iter, 1) + buf.set_text(msg) + + def on_new_msg_button_clicked(self, widget, data=None): + model = self.msg_tree.get_model() + iter = model.append() + model.set(iter, 0, 'msg', 1, 'message') + + def on_delete_msg_button_clicked(self, widget, data=None): + (model, iter) = self.msg_tree.get_selection().get_selected() + buf = self.xml.get_widget('msg_textview').get_buffer() + model.remove(iter) + buf.set_text('') + self.xml.get_widget('delete_msg_button').set_sensitive(False) + + def on_msg_textview_focus_out_event(self, widget, data=None): + (model, iter) = self.msg_tree.get_selection().get_selected() + if not iter: + return + buf = self.xml.get_widget('msg_textview').get_buffer() + first_iter, end_iter = buf.get_bounds() + name = model.get_value(iter, 0) + model.set_value(iter, 1, buf.get_text(first_iter, end_iter)) + def __init__(self, plugin): """Initialize Preference window""" self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Preferences', APP) @@ -340,9 +397,24 @@ class preference_Window: st = self.plugin.config['autoxatime'] self.spin_autoxatime.set_value(st) + #Status messages + self.msg_tree = self.xml.get_widget('msg_treeview') + model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) + self.msg_tree.set_model(model) + col = gtk.TreeViewColumn('name') + self.msg_tree.append_column(col) + renderer = gtk.CellRendererText() + col.pack_start(renderer, True) + col.set_attributes(renderer, text=0) + renderer.connect('edited', self.on_msg_cell_edited) + renderer.set_property('editable', True) + self.fill_msg_treeview() + #trayicon st = self.plugin.config['trayicon'] self.chk_trayicon.set_active(st) + if self.plugin.sleeper.getState() == common.sleepy.STATE_UNKNOWN: + self.chk_trayicon.set_sensitive(False) #Color for account text colSt = self.plugin.config['accounttextcolor'] @@ -389,6 +461,14 @@ class preference_Window: self.xml.signal_connect('gtk_widget_destroy', self.delete_event) self.xml.signal_connect('on_ok_clicked', self.on_ok) self.xml.signal_connect('on_cancel_clicked', self.on_cancel) + self.xml.signal_connect('on_msg_treeview_cursor_changed', \ + self.on_msg_treeview_cursor_changed) + self.xml.signal_connect('on_new_msg_button_clicked', \ + self.on_new_msg_button_clicked) + self.xml.signal_connect('on_delete_msg_button_clicked', \ + self.on_delete_msg_button_clicked) + self.xml.signal_connect('on_msg_textview_focus_out_event', \ + self.on_msg_textview_focus_out_event) class accountPreference_Window: """Class for account informations""" diff --git a/plugins/gtkgui/dialogs.py b/plugins/gtkgui/dialogs.py index fb9656065..d4155a16d 100644 --- a/plugins/gtkgui/dialogs.py +++ b/plugins/gtkgui/dialogs.py @@ -254,15 +254,39 @@ class awayMsg_Window: if rep == gtk.RESPONSE_OK: beg, end = self.txtBuffer.get_bounds() msg = self.txtBuffer.get_text(beg, end, 0) + self.plugin.config['last_msg'] = msg else: msg = -1 self.xml.get_widget("Away_msg").destroy() return msg + + def on_entry_changed(self, widget, data=None): + model = widget.get_model() + active = widget.get_active() + if active < 0: + return None + name = model[active][0] + self.txtBuffer.set_text(self.values[name]) - def __init__(self): + def __init__(self, plugin): self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Away_msg', APP) + self.plugin = plugin txt = self.xml.get_widget("textview") self.txtBuffer = txt.get_buffer() + self.txtBuffer.set_text(self.plugin.config['last_msg']) + self.values = {'':''} + i = 0 + while self.plugin.config.has_key('msg%s_name' % i): + self.values[self.plugin.config['msg%s_name' % i]] = \ + self.plugin.config['msg%s' % i] + i += 1 + liststore = gtk.ListStore(str, str) + cb = self.xml.get_widget('comboboxentry') + cb.set_model(liststore) + cb.set_text_column(0) + for val in self.values.keys(): + cb.append_text(val) + self.xml.signal_connect('on_comboboxentry_changed', self.on_entry_changed) class addContact_Window: """Class for Add user window""" diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade index a69e7746a..9ca8f475a 100644 --- a/plugins/gtkgui/gtkgui.glade +++ b/plugins/gtkgui/gtkgui.glade @@ -3645,7 +3645,8 @@ on the server. 10 True - False + True + True False GTK_POS_TOP False @@ -4203,7 +4204,7 @@ on the server. True True - False + True True 0 @@ -4500,7 +4501,7 @@ when NOT online 325 - 142 + 82 True 0 0.5 @@ -4656,9 +4657,9 @@ when NOT online True - Auto Status + <b>Auto Status</b> False - False + True GTK_JUSTIFY_LEFT False False @@ -4677,6 +4678,180 @@ when NOT online 0 + + + + 325 + 220 + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 0 + + + + True + False + 0 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + False + True + + + + + + 0 + True + True + + + + + + 5 + True + GTK_BUTTONBOX_START + 5 + + + + True + True + True + New + True + GTK_RELIEF_NORMAL + True + + + + + + + True + True + True + Delete + True + GTK_RELIEF_NORMAL + True + + + + + + 0 + False + False + + + + + 0 + True + True + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + 0 + True + True + + + + + + + + + + True + <b>Status Messages</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + 84 + + False @@ -4771,187 +4946,6 @@ when NOT online - - 5 - True - Message - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - True - - - - True - False - 0 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - - - - - 0 - False - True - GTK_PACK_END - - - - - - 4 - True - False - 0 - - - - True - Enter your message : - False - False - GTK_JUSTIFY_LEFT - False - False - 0.02 - 0.5 - 0 - 0 - - - 10 - False - True - - - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - 0 - True - True - - - - - - True - Or choose your message : - False - False - GTK_JUSTIFY_LEFT - False - False - 0.02 - 0.5 - 0 - 0 - - - 10 - False - False - - - - - - True - False - True - False - True - False - - - - True - True - True - True - 0 - - True - * - False - - - - - - True - GTK_SELECTION_BROWSE - - - - - 0 - False - False - - - - - 0 - True - True - - - - - - 5 True @@ -8723,9 +8717,10 @@ when NOT online - + + 5 True - window1 + Message GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False @@ -8734,11 +8729,146 @@ when NOT online True False False - GDK_WINDOW_TYPE_HINT_NORMAL + GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True - - + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 4 + True + False + 5 + + + + True + Enter your message : + False + False + GTK_JUSTIFY_LEFT + False + False + 0.02 + 0.5 + 0 + 0 + + + 0 + False + True + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0 + True + True + + + + + + True + Or choose your message : + False + False + GTK_JUSTIFY_LEFT + False + False + 0.02 + 0.5 + 0 + 0 + + + 0 + False + True + + + + + + True + + + + 0 + False + False + + + + + 0 + True + True + + + diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py index a4a362c43..c770e4b14 100644 --- a/plugins/gtkgui/gtkgui.py +++ b/plugins/gtkgui/gtkgui.py @@ -115,7 +115,7 @@ class ImageCellRenderer(gtk.GenericCellRenderer): draw_rect = cell_area.intersect(pix_rect) draw_rect = expose_area.intersect(draw_rect) - + if self.image.get_storage_type() == gtk.IMAGE_ANIMATION: if not self.image.get_data('iter'): animation = self.image.get_animation() @@ -1372,7 +1372,7 @@ class roster_Window: def change_status(self, widget, account, status): if status != 'online' and status != 'offline': - w = awayMsg_Window() + w = awayMsg_Window(self.plugin) txt = w.run() if txt == -1: return @@ -1386,7 +1386,7 @@ class roster_Window: history = optionmenu.get_history() status = optionmenu.get_menu().get_children()[history].name if status != 'online' and status != 'offline': - w = awayMsg_Window() + w = awayMsg_Window(self.plugin) txt = w.run() if txt == -1: self.set_optionmenu() @@ -2380,6 +2380,13 @@ class plugin: 'autoawaytime':10,\ 'autoxa':1,\ 'autoxatime':20,\ + 'last_msg':'',\ + 'msg1_name':'Brb',\ + 'msg1':'Back in some minutes.',\ + 'msg2_name':'Eating',\ + 'msg2':'I\'m eating, so let a message.',\ + 'msg3_name':'Film',\ + 'msg3':'I\'m watching a film.',\ 'trayicon':1,\ 'iconstyle':'sun',\ 'inmsgcolor':'#ff0000',\ @@ -2395,7 +2402,7 @@ class plugin: 'usertextcolor': '#000000',\ 'userbgcolor': '#ffffff',\ 'userfont': 'Sans 10',\ - 'saveposition': 0,\ + 'saveposition': 1,\ 'x-position': 0,\ 'y-position': 0,\ 'width': 150,\