Add method for creating image buttons
This commit is contained in:
parent
9ce6299e1a
commit
4ad5fd9cdc
|
@ -3399,41 +3399,23 @@ class XMLConsoleWindow(Gtk.Window):
|
|||
|
||||
self.actionbar = Gtk.ActionBar()
|
||||
|
||||
icon = gtkgui_helpers.get_icon_pixmap('edit-clear-all-symbolic')
|
||||
image = Gtk.Image()
|
||||
image.set_from_pixbuf(icon)
|
||||
button = Gtk.Button()
|
||||
button.set_tooltip_text(_('Clear'))
|
||||
button = gtkgui_helpers.get_image_button(
|
||||
'edit-clear-all-symbolic', 'Clear')
|
||||
button.connect('clicked', self.on_clear)
|
||||
button.set_image(image)
|
||||
self.actionbar.pack_start(button)
|
||||
|
||||
icon = gtkgui_helpers.get_icon_pixmap('applications-system-symbolic')
|
||||
image = Gtk.Image()
|
||||
image.set_from_pixbuf(icon)
|
||||
button = Gtk.Button()
|
||||
button.set_tooltip_text(_('Filter'))
|
||||
button = gtkgui_helpers.get_image_button(
|
||||
'applications-system-symbolic', 'Filter')
|
||||
button.connect('clicked', self.on_filter_options)
|
||||
button.set_image(image)
|
||||
self.actionbar.pack_start(button)
|
||||
|
||||
icon = gtkgui_helpers.get_icon_pixmap('document-edit-symbolic')
|
||||
image = Gtk.Image()
|
||||
image.set_from_pixbuf(icon)
|
||||
button = Gtk.ToggleButton()
|
||||
button.set_tooltip_text(_('XML Input'))
|
||||
button.set_active(False)
|
||||
button = gtkgui_helpers.get_image_button(
|
||||
'document-edit-symbolic', 'XML Input', toggle=True)
|
||||
button.connect('toggled', self.on_input)
|
||||
button.set_image(image)
|
||||
self.actionbar.pack_start(button)
|
||||
|
||||
icon = gtkgui_helpers.get_icon_pixmap('emblem-ok-symbolic')
|
||||
image = Gtk.Image()
|
||||
image.set_from_pixbuf(icon)
|
||||
button = Gtk.Button()
|
||||
button.set_tooltip_text(_('Send'))
|
||||
button = gtkgui_helpers.get_image_button('emblem-ok-symbolic', 'Send')
|
||||
button.connect('clicked', self.on_send)
|
||||
button.set_image(image)
|
||||
self.actionbar.pack_end(button)
|
||||
|
||||
listbox = Gtk.ListBox()
|
||||
|
|
|
@ -106,6 +106,18 @@ def add_image_to_button(button, icon_name):
|
|||
img.set_from_file(path_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')
|
||||
def get_gtk_builder(file_name, widget=None):
|
||||
file_path = os.path.join(GUI_DIR, file_name)
|
||||
|
|
Loading…
Reference in New Issue