Skip to content

Commit ae62abb

Browse files
gtkui: fix weird toolbar styling in various property editor UIs
1 parent a561183 commit ae62abb

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

plugins/gtkui/scriptable/gtkScriptableListEditViewController.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ _init_treeview_cell_from_scriptable_item (
9999
scriptableItem_t *item);
100100

101101
static GtkWidget *
102-
_create_tool_button_with_image_name (GtkIconSize icon_size, const char *image_name);
102+
_create_tool_button_with_image_name (const char *image_name);
103103

104104
static void
105105
_did_edit_name (GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data);
@@ -176,44 +176,38 @@ gtkScriptableListEditViewControllerLoad (gtkScriptableListEditViewController_t *
176176
gtk_widget_show (button_box);
177177
gtk_box_pack_start (GTK_BOX (vbox), button_box, FALSE, FALSE, 0);
178178

179-
GtkWidget *toolbar = gtk_toolbar_new ();
179+
GtkWidget *toolbar = gtk_hbox_new(TRUE, 0);
180180
gtk_widget_show (toolbar);
181181
gtk_box_pack_start (GTK_BOX (button_box), toolbar, FALSE, FALSE, 0);
182-
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
183-
gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
184-
185-
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR);
186182

187183
#if GTK_CHECK_VERSION(3, 0, 0)
188184
const char *add_icon = "list-add-symbolic";
189185
const char *remove_icon = "list-remove-symbolic";
190186
const char *preferences_icon = "document-edit-symbolic";
191187
const char *copy_icon = "edit-copy-symbolic";
192188
#else
193-
const char *add_icon = "gtk-add";
194-
const char *remove_icon = "gtk-remove";
189+
const char *add_icon = "list-add";
190+
const char *remove_icon = "list-remove";
195191
const char *preferences_icon = "gtk-preferences";
196-
const char *copy_icon = "gtk-copy";
192+
const char *copy_icon = "edit-copy";
197193
#endif
198194

199-
GtkIconSize icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar));
200-
201-
GtkWidget *add_button = _create_tool_button_with_image_name (icon_size, add_icon);
195+
GtkWidget *add_button = _create_tool_button_with_image_name (add_icon);
202196
gtk_widget_show (add_button);
203197
gtk_container_add (GTK_CONTAINER (toolbar), add_button);
204198
self->add_button = add_button;
205199

206-
GtkWidget *remove_button = _create_tool_button_with_image_name (icon_size, remove_icon);
200+
GtkWidget *remove_button = _create_tool_button_with_image_name (remove_icon);
207201
gtk_widget_show (remove_button);
208202
gtk_container_add (GTK_CONTAINER (toolbar), remove_button);
209203
self->remove_button = remove_button;
210204

211-
GtkWidget *config_button = _create_tool_button_with_image_name (icon_size, preferences_icon);
205+
GtkWidget *config_button = _create_tool_button_with_image_name (preferences_icon);
212206
gtk_widget_show (config_button);
213207
gtk_container_add (GTK_CONTAINER (toolbar), config_button);
214208
self->config_button = config_button;
215209

216-
GtkWidget *duplicate_button = _create_tool_button_with_image_name (icon_size, copy_icon);
210+
GtkWidget *duplicate_button = _create_tool_button_with_image_name (copy_icon);
217211
gtk_widget_show (duplicate_button);
218212
gtk_container_add (GTK_CONTAINER (toolbar), duplicate_button);
219213
self->duplicate_button = duplicate_button;
@@ -613,16 +607,16 @@ _list_selection_did_change (GtkTreeSelection *treeselection, gpointer user_data)
613607
}
614608

615609
static GtkWidget *
616-
_create_tool_button_with_image_name (GtkIconSize icon_size, const char *image_name) {
617-
GtkToolItem *button = gtk_tool_button_new (NULL, "");
610+
_create_tool_button_with_image_name (const char *image_name) {
611+
GtkWidget *img = gtk_image_new_from_icon_name(image_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
612+
GtkWidget *btn = gtk_button_new();
613+
gtk_button_set_image(GTK_BUTTON(btn), img);
618614
#if GTK_CHECK_VERSION(3, 0, 0)
619-
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (button), image_name);
615+
gtk_style_context_add_class(gtk_widget_get_style_context(btn), "flat");
620616
#else
621-
GtkWidget *image = gtk_image_new_from_stock (image_name, icon_size);
622-
gtk_widget_show (image);
623-
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (button), image);
617+
gtk_button_set_relief(GTK_BUTTON(btn), GTK_RELIEF_NONE);
624618
#endif
625-
return GTK_WIDGET (button);
619+
return btn;
626620
}
627621

628622
static void

0 commit comments

Comments
 (0)