From 47d7464a7380e217cc7eb80456366a9b3bf91d46 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 14 Feb 2005 12:19:49 +0000 Subject: [PATCH] new emoticons binder in preferences window --- plugins/gtkgui/config.py | 57 +++++--- plugins/gtkgui/gtkgui.glade | 285 ++++++++++++++++-------------------- plugins/gtkgui/gtkgui.py | 13 +- 3 files changed, 172 insertions(+), 183 deletions(-) diff --git a/plugins/gtkgui/config.py b/plugins/gtkgui/config.py index a6519cbbf..02711cb3d 100644 --- a/plugins/gtkgui/config.py +++ b/plugins/gtkgui/config.py @@ -397,15 +397,26 @@ class preference_Window: model.clear() emots = self.load_emots() for i in emots: - iter = model.append() - model.set(iter, 0, i, 1,emots[i]) + file = emots[i] + iter = model.append((i, file, None)) + if not os.path.exists(file): + continue + img = gtk.Image() + img.show() + if file.find('.gif') != -1: + pix = gtk.gdk.PixbufAnimation(file) + img.set_from_animation(pix) + else: + pix = gtk.gdk.pixbuf_new_from_file(file) + img.set_from_pixbuf(pix) + model.set(iter, 2, img) def on_emot_cell_edited(self, cell, row, new_text): model = self.emot_tree.get_model() iter = model.get_iter_from_string(row) model.set_value(iter, 0, new_text) - def on_button_emoticons_clicked(self, widget, data=None): + def on_button_set_image_clicked(self, widget, data=None): (model, iter) = self.emot_tree.get_selection().get_selected() if not iter: return @@ -448,14 +459,23 @@ class preference_Window: ok = 1 dialog.destroy() if file: - self.xml.get_widget('entry_emoticons').set_text(file) - self.xml.get_widget('image_emoticon').set_from_file(file) model.set_value(iter, 1, file) + img = gtk.Image() + img.show() + if file.find('.gif') != -1: + pix = gtk.gdk.PixbufAnimation(file) + img.set_from_animation(pix) + else: + pix = gtk.gdk.pixbuf_new_from_file(file) + img.set_from_pixbuf(pix) + model.set(iter, 2, img) def on_button_new_emoticon_clicked(self, widget, data=None): model = self.emot_tree.get_model() iter = model.append() model.set(iter, 0, 'smeiley', 1, '') + col = self.emot_tree.get_column(0) + self.emot_tree.set_cursor(model.get_path(iter), col, True) def on_button_remove_emoticon_clicked(self, widget, data=None): (model, iter) = self.emot_tree.get_selection().get_selected() @@ -463,14 +483,6 @@ class preference_Window: return model.remove(iter) - def on_treeview_emoticons_cursor_changed(self, widget, data=None): - (model, iter) = self.emot_tree.get_selection().get_selected() - if not iter: - return - img_str = model.get_value(iter, 1) - self.xml.get_widget('entry_emoticons').set_text(img_str) - self.xml.get_widget('image_emoticon').set_from_file(img_str) - def on_chk_toggled(self, widget, widgets): """set or unset sensitivity of widgets when widget is toggled""" for w in widgets: @@ -607,13 +619,11 @@ class preference_Window: self.xml.get_widget('button_new_emoticon').set_sensitive(st) self.xml.get_widget('button_remove_emoticon').set_sensitive(st) self.xml.get_widget('treeview_emoticons').set_sensitive(st) - self.xml.get_widget('entry_emoticons').set_sensitive(st) - self.xml.get_widget('button_emoticons').set_sensitive(st) - self.xml.get_widget('image_emoticon').set_sensitive(st) + self.xml.get_widget('button_set_image').set_sensitive(st) #emoticons self.emot_tree = self.xml.get_widget('treeview_emoticons') - model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) + model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gtk.Image) self.emot_tree.set_model(model) col = gtk.TreeViewColumn('name') self.emot_tree.append_column(col) @@ -622,6 +632,13 @@ class preference_Window: renderer.set_property('editable', True) col.pack_start(renderer, True) col.set_attributes(renderer, text=0) + + col = gtk.TreeViewColumn('Image') + self.emot_tree.append_column(col) + renderer = gtkgui.ImageCellRenderer() + col.pack_start(renderer, expand = False) + col.add_attribute(renderer, 'image', 2) + self.fill_emot_treeview() #sound player @@ -759,10 +776,8 @@ class preference_Window: self.xml.get_widget('entry_emoticons'), self.xml.get_widget('button_emoticons'), self.xml.get_widget('image_emoticon')]) - self.xml.signal_connect('on_treeview_emoticons_cursor_changed', \ - self.on_treeview_emoticons_cursor_changed) - self.xml.signal_connect('on_button_emoticons_clicked', \ - self.on_button_emoticons_clicked) + self.xml.signal_connect('on_button_set_image_clicked', \ + self.on_button_set_image_clicked) self.xml.signal_connect('on_button_new_emoticon_clicked', \ self.on_button_new_emoticon_clicked) self.xml.signal_connect('on_button_remove_emoticon_clicked', \ diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade index 648867995..46d4a26da 100644 --- a/plugins/gtkgui/gtkgui.glade +++ b/plugins/gtkgui/gtkgui.glade @@ -44,7 +44,7 @@ True - + True gtk-convert 1 @@ -64,10 +64,9 @@ _Preferences True - - + True gtk-preferences 1 @@ -86,10 +85,9 @@ A_ccounts True - - + True gtk-select-color 1 @@ -110,7 +108,7 @@ - + True gtk-find 1 @@ -136,7 +134,7 @@ True - + True gtk-add 1 @@ -156,7 +154,6 @@ True False - @@ -183,7 +180,7 @@ - + True gtk-help 1 @@ -205,7 +202,7 @@ - + True gtk-quit 1 @@ -4361,45 +4358,28 @@ on the server. + 5 True False - 0 + 5 - - 5 + True - False - 0 - - - - True - True - Use Emoticons - True - GTK_RELIEF_NORMAL - True - False - False - True - - - - 0 - False - False - - - - - - + True + Use Emoticons + True + GTK_RELIEF_NORMAL + True + False + False + True + 0 False - True + False @@ -4415,79 +4395,30 @@ on the server. - - 5 + True False 0 - + True - False - 5 + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - + True True - gtk-add - True - GTK_RELIEF_NORMAL - True - + False + False + False + True + - - 0 - False - False - - - - - - True - True - gtk-remove - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - - - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - False - False - False - True - - - - - - - 0 - True - True - @@ -4498,80 +4429,112 @@ on the server. - + 5 True - False - 5 + GTK_BUTTONBOX_SPREAD + 0 - + True - False - 5 - - - - True - True - False - True - 0 - - True - * - False - - - 0 - True - True - - - - - - True - True - ... - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - GTK_PACK_END - - + True + True + gtk-add + True + GTK_RELIEF_NORMAL + True + - - 0 - False - True - - + True - 0.5 - 0.5 - 0 - 0 + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + True + + + + + + + True + True + True + GTK_RELIEF_NORMAL + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-file + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Set Image + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + - - 0 - True - True - 0 - True + False True diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py index 6c341f80c..8a6690767 100644 --- a/plugins/gtkgui/gtkgui.py +++ b/plugins/gtkgui/gtkgui.py @@ -427,7 +427,18 @@ class tabbed_chat_Window: nb = self.xml.get_widget("notebook") st = "1234567890" if event.keyval == gtk.keysyms.Escape: - self.on_close_clicked(widget) + jid = self.get_active_jid() + if len(self.xmls) == 1: + button.get_toplevel().destroy() + else: + nb.remove_page(nb.get_current_page()) + del self.plugin.windows[self.account]['chats'][jid] + del self.users[jid] + del self.nb_unread[jid] + del self.xmls[jid] + del self.tagIn[jid] + del self.tagOut[jid] + del self.tagStatus[jid] elif (event.string in st) \ and (event.state & gtk.gdk.MOD1_MASK): nb.set_current_page(st.index(event.string))