Add method for creating image buttons
This commit is contained in:
parent
9ce6299e1a
commit
4ad5fd9cdc
2 changed files with 19 additions and 25 deletions
|
@ -3399,41 +3399,23 @@ class XMLConsoleWindow(Gtk.Window):
|
||||||
|
|
||||||
self.actionbar = Gtk.ActionBar()
|
self.actionbar = Gtk.ActionBar()
|
||||||
|
|
||||||
icon = gtkgui_helpers.get_icon_pixmap('edit-clear-all-symbolic')
|
button = gtkgui_helpers.get_image_button(
|
||||||
image = Gtk.Image()
|
'edit-clear-all-symbolic', 'Clear')
|
||||||
image.set_from_pixbuf(icon)
|
|
||||||
button = Gtk.Button()
|
|
||||||
button.set_tooltip_text(_('Clear'))
|
|
||||||
button.connect('clicked', self.on_clear)
|
button.connect('clicked', self.on_clear)
|
||||||
button.set_image(image)
|
|
||||||
self.actionbar.pack_start(button)
|
self.actionbar.pack_start(button)
|
||||||
|
|
||||||
icon = gtkgui_helpers.get_icon_pixmap('applications-system-symbolic')
|
button = gtkgui_helpers.get_image_button(
|
||||||
image = Gtk.Image()
|
'applications-system-symbolic', 'Filter')
|
||||||
image.set_from_pixbuf(icon)
|
|
||||||
button = Gtk.Button()
|
|
||||||
button.set_tooltip_text(_('Filter'))
|
|
||||||
button.connect('clicked', self.on_filter_options)
|
button.connect('clicked', self.on_filter_options)
|
||||||
button.set_image(image)
|
|
||||||
self.actionbar.pack_start(button)
|
self.actionbar.pack_start(button)
|
||||||
|
|
||||||
icon = gtkgui_helpers.get_icon_pixmap('document-edit-symbolic')
|
button = gtkgui_helpers.get_image_button(
|
||||||
image = Gtk.Image()
|
'document-edit-symbolic', 'XML Input', toggle=True)
|
||||||
image.set_from_pixbuf(icon)
|
|
||||||
button = Gtk.ToggleButton()
|
|
||||||
button.set_tooltip_text(_('XML Input'))
|
|
||||||
button.set_active(False)
|
|
||||||
button.connect('toggled', self.on_input)
|
button.connect('toggled', self.on_input)
|
||||||
button.set_image(image)
|
|
||||||
self.actionbar.pack_start(button)
|
self.actionbar.pack_start(button)
|
||||||
|
|
||||||
icon = gtkgui_helpers.get_icon_pixmap('emblem-ok-symbolic')
|
button = gtkgui_helpers.get_image_button('emblem-ok-symbolic', 'Send')
|
||||||
image = Gtk.Image()
|
|
||||||
image.set_from_pixbuf(icon)
|
|
||||||
button = Gtk.Button()
|
|
||||||
button.set_tooltip_text(_('Send'))
|
|
||||||
button.connect('clicked', self.on_send)
|
button.connect('clicked', self.on_send)
|
||||||
button.set_image(image)
|
|
||||||
self.actionbar.pack_end(button)
|
self.actionbar.pack_end(button)
|
||||||
|
|
||||||
listbox = Gtk.ListBox()
|
listbox = Gtk.ListBox()
|
||||||
|
|
|
@ -106,6 +106,18 @@ def add_image_to_button(button, icon_name):
|
||||||
img.set_from_file(path_img)
|
img.set_from_file(path_img)
|
||||||
button.set_image(img)
|
button.set_image(img)
|
||||||
|
|
||||||
|
def get_image_button(icon_name, tooltip, toggle=False):
|
||||||
|
icon = get_icon_pixmap(icon_name)
|
||||||
|
image = Gtk.Image()
|
||||||
|
image.set_from_pixbuf(icon)
|
||||||
|
if toggle:
|
||||||
|
button = Gtk.ToggleButton()
|
||||||
|
else:
|
||||||
|
button = Gtk.Button()
|
||||||
|
button.set_tooltip_text(_(tooltip))
|
||||||
|
button.set_image(image)
|
||||||
|
return button
|
||||||
|
|
||||||
GUI_DIR = os.path.join(gajim.DATA_DIR, 'gui')
|
GUI_DIR = os.path.join(gajim.DATA_DIR, 'gui')
|
||||||
def get_gtk_builder(file_name, widget=None):
|
def get_gtk_builder(file_name, widget=None):
|
||||||
file_path = os.path.join(GUI_DIR, file_name)
|
file_path = os.path.join(GUI_DIR, file_name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue