bye bye Manage Emoticons Window
This commit is contained in:
parent
7a31531882
commit
2e393b0d37
205
src/config.py
205
src/config.py
|
@ -521,12 +521,6 @@ class PreferencesWindow:
|
|||
for win in gajim.interface.msg_win_mgr.windows():
|
||||
win.toggle_emoticons()
|
||||
|
||||
def on_manage_emoticons_button_clicked(self, widget):
|
||||
if gajim.interface.instances.has_key('manage_emots'):
|
||||
gajim.interface.instances['manage_emots'].window.present()
|
||||
else:
|
||||
gajim.interface.instances['manage_emots'] = ManageEmoticonsWindow()
|
||||
|
||||
def on_iconset_combobox_changed(self, widget):
|
||||
model = widget.get_model()
|
||||
active = widget.get_active()
|
||||
|
@ -2074,205 +2068,6 @@ class GroupchatConfigWindow(DataFormWindow):
|
|||
list)
|
||||
self.window.destroy()
|
||||
|
||||
#---------- ManageEmoticonsWindow class -------------#
|
||||
class ManageEmoticonsWindow:
|
||||
def __init__(self):
|
||||
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'manage_emoticons_window', APP)
|
||||
self.window = self.xml.get_widget('manage_emoticons_window')
|
||||
|
||||
#emoticons
|
||||
self.emot_tree = self.xml.get_widget('emoticons_treeview')
|
||||
model = gtk.ListStore(str, str, gtk.Image)
|
||||
model.set_sort_column_id(0, gtk.SORT_ASCENDING)
|
||||
self.emot_tree.set_model(model)
|
||||
col = gtk.TreeViewColumn(_('Text'))
|
||||
self.emot_tree.append_column(col)
|
||||
renderer = gtk.CellRendererText()
|
||||
renderer.connect('edited', self.on_emot_cell_edited)
|
||||
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 = cell_renderer_image.CellRendererImage(1, 2)
|
||||
col.pack_start(renderer, expand = False)
|
||||
col.add_attribute(renderer, 'image', 2)
|
||||
|
||||
self.fill_emot_treeview()
|
||||
self.emot_tree.get_model().connect('row-changed',
|
||||
self.on_emoticons_treemodel_row_changed)
|
||||
|
||||
self.window.show_all()
|
||||
self.xml.signal_autoconnect(self)
|
||||
|
||||
def on_manage_emoticons_window_destroy(self, widget):
|
||||
gajim.interface.init_emoticons() # update emoticons
|
||||
gajim.interface.make_regexps()
|
||||
# remove us from open windows
|
||||
del gajim.interface.instances['manage_emots']
|
||||
|
||||
def on_close_button_clicked(self, widget):
|
||||
self.window.destroy()
|
||||
|
||||
def on_emoticons_treemodel_row_changed(self, model, path, iter):
|
||||
emots = gajim.config.get_per('emoticons')
|
||||
emot = model.get_value(iter, 0).decode('utf-8').upper()
|
||||
if not emot in emots:
|
||||
gajim.config.add_per('emoticons', emot)
|
||||
gajim.interface.init_emoticons() # update emoticons
|
||||
image = model[iter][1]
|
||||
if image:
|
||||
image = image.decode('utf-8')
|
||||
gajim.config.set_per('emoticons', emot, 'path', image)
|
||||
gajim.interface.save_config()
|
||||
|
||||
def image_is_ok(self, image):
|
||||
if not os.path.exists(image):
|
||||
return False
|
||||
img = gtk.Image()
|
||||
try:
|
||||
img.set_from_file(image)
|
||||
except:
|
||||
return False
|
||||
t = img.get_storage_type()
|
||||
if t not in (gtk.IMAGE_PIXBUF, gtk.IMAGE_ANIMATION):
|
||||
return False
|
||||
return True
|
||||
|
||||
def fill_emot_treeview(self):
|
||||
model = self.emot_tree.get_model()
|
||||
model.clear()
|
||||
emot_theme = gajim.config.get('emoticons_theme')
|
||||
if not emot_theme:
|
||||
return
|
||||
path = os.path.join(gajim.DATA_DIR, 'emoticons', emot_theme)
|
||||
sys.path.append(path)
|
||||
from emoticons import emoticons as emots
|
||||
for emot in emots:
|
||||
file = os.path.join(path, emots[emot])
|
||||
iter = model.append((emot, file, None))
|
||||
if not os.path.exists(file):
|
||||
continue
|
||||
img = gtk.Image()
|
||||
img.show()
|
||||
img.set_from_file(file)
|
||||
model.set(iter, 2, img)
|
||||
sys.path.remove(path)
|
||||
del emots
|
||||
|
||||
def on_emot_cell_edited(self, cell, row, new_text):
|
||||
emots = gajim.config.get_per('emoticons')
|
||||
model = self.emot_tree.get_model()
|
||||
iter = model.get_iter_from_string(row)
|
||||
old_text = model.get_value(iter, 0).decode('utf-8')
|
||||
if old_text in emots:
|
||||
gajim.config.del_per('emoticons', old_text)
|
||||
emots = gajim.config.get_per('emoticons')
|
||||
emot = new_text.decode('utf-8').upper()
|
||||
if emot in emots:
|
||||
model.remove(iter)
|
||||
else:
|
||||
gajim.config.add_per('emoticons', emot)
|
||||
gajim.interface.init_emoticons() # update emoticons
|
||||
gajim.config.set_per('emoticons', emot, 'path',
|
||||
model[iter][1].decode('utf-8'))
|
||||
model[iter][0] = emot
|
||||
gajim.interface.save_config()
|
||||
|
||||
def update_preview(self, widget):
|
||||
path_to_file = widget.get_preview_filename()
|
||||
if path_to_file is None or os.path.isdir(path_to_file):
|
||||
# nothing to preview or directory
|
||||
# make sure you clean image do show nothing
|
||||
widget.get_preview_widget().set_from_file(None)
|
||||
return
|
||||
try:
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path_to_file, 32, 32)
|
||||
except (gobject.GError, TypeError):
|
||||
return
|
||||
widget.get_preview_widget().set_from_pixbuf(pixbuf)
|
||||
|
||||
def on_set_image_button_clicked(self, widget, data=None):
|
||||
(model, iter) = self.emot_tree.get_selection().get_selected()
|
||||
if not iter:
|
||||
return
|
||||
file = model[iter][1].decode('utf-8')
|
||||
dialog = gtk.FileChooserDialog(_('Choose Image'), None,
|
||||
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
||||
dialog.set_default_response(gtk.RESPONSE_OK)
|
||||
last_emoticons_dir = gajim.config.get('last_emoticons_dir')
|
||||
if last_emoticons_dir and os.path.isdir('last_emoticons_dir'):
|
||||
dialog.set_current_folder(last_emoticons_dir)
|
||||
else:
|
||||
dialog.set_current_folder(gajim.HOME_DIR)
|
||||
filter = gtk.FileFilter()
|
||||
filter.set_name(_('All files'))
|
||||
filter.add_pattern('*')
|
||||
dialog.add_filter(filter)
|
||||
|
||||
filter = gtk.FileFilter()
|
||||
filter.set_name(_('Images'))
|
||||
filter.add_mime_type('image/png')
|
||||
filter.add_mime_type('image/jpeg')
|
||||
filter.add_mime_type('image/gif')
|
||||
filter.add_mime_type('image/tiff')
|
||||
filter.add_mime_type('image/x-xpixmap') # xpm
|
||||
dialog.add_filter(filter)
|
||||
dialog.set_filter(filter)
|
||||
dialog.set_use_preview_label(False)
|
||||
dialog.set_preview_widget(gtk.Image())
|
||||
dialog.connect('selection-changed', self.update_preview)
|
||||
|
||||
file = os.path.join(os.getcwd(), file)
|
||||
dialog.set_filename(file)
|
||||
file = ''
|
||||
ok = False
|
||||
while not ok:
|
||||
response = dialog.run()
|
||||
if response == gtk.RESPONSE_OK:
|
||||
file = dialog.get_filename()
|
||||
try:
|
||||
file = file.decode(sys.getfilesystemencoding())
|
||||
except:
|
||||
pass
|
||||
if self.image_is_ok(file):
|
||||
ok = True
|
||||
else:
|
||||
file = None
|
||||
ok = True
|
||||
dialog.destroy()
|
||||
if file:
|
||||
directory = os.path.dirname(file)
|
||||
gajim.config.set('last_emoticons_dir', directory)
|
||||
model.set_value(iter, 1, file)
|
||||
img = gtk.Image()
|
||||
img.show()
|
||||
img.set_from_file(file)
|
||||
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, 'EMOTICON', 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()
|
||||
if not iter:
|
||||
return
|
||||
gajim.config.del_per('emoticons', model.get_value(iter, 0).decode('utf-8'))
|
||||
gajim.interface.init_emoticons() # update emoticons
|
||||
gajim.interface.save_config()
|
||||
model.remove(iter)
|
||||
|
||||
def on_emoticons_treeview_key_press_event(self, widget, event):
|
||||
if event.keyval == gtk.keysyms.Delete:
|
||||
self.on_button_remove_emoticon_clicked(widget)
|
||||
|
||||
#---------- RemoveAccountWindow class -------------#
|
||||
class RemoveAccountWindow:
|
||||
'''ask for removing from gajim only or from gajim and server too
|
||||
|
|
207
src/gtkgui.glade
207
src/gtkgui.glade
|
@ -3808,23 +3808,6 @@ Per type</property>
|
|||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="manage_emoticons_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Manage...</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_manage_emoticons_button_clicked" last_modification_time="Sun, 05 Feb 2006 14:08:33 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
|
@ -11087,196 +11070,6 @@ Custom</property>
|
|||
</child>
|
||||
</widget>
|
||||
|
||||
<widget class="GtkWindow" id="manage_emoticons_window">
|
||||
<property name="border_width">6</property>
|
||||
<property name="title" translatable="yes">Manage Emoticons</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="default_width">300</property>
|
||||
<property name="default_height">350</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>
|
||||
<signal name="destroy" handler="on_manage_emoticons_window_destroy" last_modification_time="Sun, 13 Nov 2005 14:52:28 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Emoticon set:</property>
|
||||
<property name="use_underline">False</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.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</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="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">Animated
|
||||
Static</property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="emoticons_scrolledwindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="emoticons_treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="rules_hint">False</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
<property name="fixed_height_mode">False</property>
|
||||
<property name="hover_selection">False</property>
|
||||
<property name="hover_expand">False</property>
|
||||
<signal name="key_press_event" handler="on_emoticons_treeview_key_press_event" last_modification_time="Wed, 06 Apr 2005 17:03:22 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVButtonBox" id="vbuttonbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_START</property>
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_new_emoticon">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-add</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_button_new_emoticon_clicked" last_modification_time="Sun, 13 Feb 2005 14:30:54 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button_remove_emoticon">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-remove</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_button_remove_emoticon_clicked" last_modification_time="Sun, 13 Feb 2005 14:31:17 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="set_image_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Set Image...</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_set_image_button_clicked" last_modification_time="Wed, 06 Apr 2005 13:55:38 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="close_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">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>
|
||||
<signal name="clicked" handler="on_close_button_clicked" last_modification_time="Wed, 06 Apr 2005 15:35:16 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</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>
|
||||
|
||||
<widget class="GtkWindow" id="data_form_window">
|
||||
<property name="border_width">6</property>
|
||||
<property name="title" translatable="yes">Room Configuration</property>
|
||||
|
|
Loading…
Reference in New Issue