Commit ba65b427 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

ev-toolbar: Remove the margin of the buttons and center them vertically

This makes the buttons small again after whatever changed in
gnome-themes-standard. Based on patch by Yosef Or Boczko.

https://bugzilla.gnome.org/show_bug.cgi?id=709005
parent cad2cf93
...@@ -189,18 +189,6 @@ button_pressed (GtkWidget *button, ...@@ -189,18 +189,6 @@ button_pressed (GtkWidget *button,
return GDK_EVENT_PROPAGATE; return GDK_EVENT_PROPAGATE;
} }
static gint
get_icon_margin (EvHistoryActionWidget *history_widget)
{
gint toolbar_size_px, menu_size_px;
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (history_widget));
gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU, &menu_size_px, NULL);
gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_LARGE_TOOLBAR, &toolbar_size_px, NULL);
return (gint)floor ((toolbar_size_px - menu_size_px) / 2.0);
}
static GtkWidget * static GtkWidget *
ev_history_action_widget_create_button (EvHistoryActionWidget *history_widget, ev_history_action_widget_create_button (EvHistoryActionWidget *history_widget,
EvHistoryActionButton action_button) EvHistoryActionButton action_button)
...@@ -214,6 +202,7 @@ ev_history_action_widget_create_button (EvHistoryActionWidget *history_widget, ...@@ -214,6 +202,7 @@ ev_history_action_widget_create_button (EvHistoryActionWidget *history_widget,
rtl = (gtk_widget_get_direction (GTK_WIDGET (history_widget)) == GTK_TEXT_DIR_RTL); rtl = (gtk_widget_get_direction (GTK_WIDGET (history_widget)) == GTK_TEXT_DIR_RTL);
button = gtk_button_new (); button = gtk_button_new ();
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
g_signal_connect (button, "clicked", g_signal_connect (button, "clicked",
G_CALLBACK (button_clicked), G_CALLBACK (button_clicked),
history_widget); history_widget);
...@@ -233,7 +222,6 @@ ev_history_action_widget_create_button (EvHistoryActionWidget *history_widget, ...@@ -233,7 +222,6 @@ ev_history_action_widget_create_button (EvHistoryActionWidget *history_widget,
} }
image = gtk_image_new (); image = gtk_image_new ();
g_object_set (image, "margin", get_icon_margin (history_widget), NULL);
gtk_button_set_image (GTK_BUTTON (button), image); gtk_button_set_image (GTK_BUTTON (button), image);
gtk_image_set_from_icon_name (GTK_IMAGE (image), icon_name, GTK_ICON_SIZE_MENU); gtk_image_set_from_icon_name (GTK_IMAGE (image), icon_name, GTK_ICON_SIZE_MENU);
gtk_widget_set_tooltip_text (button, tooltip_text); gtk_widget_set_tooltip_text (button, tooltip_text);
......
...@@ -61,32 +61,6 @@ ev_toolbar_set_property (GObject *object, ...@@ -61,32 +61,6 @@ ev_toolbar_set_property (GObject *object,
} }
} }
static gint
get_icon_margin (EvToolbar *ev_toolbar)
{
GtkIconSize toolbar_size;
gint toolbar_size_px, menu_size_px;
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (ev_toolbar));
toolbar_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR (ev_toolbar));
gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU, &menu_size_px, NULL);
gtk_icon_size_lookup_for_settings (settings, toolbar_size, &toolbar_size_px, NULL);
return (gint)floor ((toolbar_size_px - menu_size_px) / 2.0);
}
static void
ev_toolbar_set_button_image (EvToolbar *ev_toolbar,
GtkButton *button)
{
GtkWidget *image;
image = gtk_image_new ();
g_object_set (image, "margin", get_icon_margin (ev_toolbar), NULL);
gtk_button_set_image (button, image);
}
static void static void
ev_toolbar_set_button_action (EvToolbar *ev_toolbar, ev_toolbar_set_button_action (EvToolbar *ev_toolbar,
GtkButton *button, GtkButton *button,
...@@ -104,7 +78,8 @@ ev_toolbar_create_button (EvToolbar *ev_toolbar, ...@@ -104,7 +78,8 @@ ev_toolbar_create_button (EvToolbar *ev_toolbar,
{ {
GtkWidget *button = gtk_button_new (); GtkWidget *button = gtk_button_new ();
ev_toolbar_set_button_image (ev_toolbar, GTK_BUTTON (button)); gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_button_set_image (GTK_BUTTON (button), gtk_image_new ());
ev_toolbar_set_button_action (ev_toolbar, GTK_BUTTON (button), action); ev_toolbar_set_button_action (ev_toolbar, GTK_BUTTON (button), action);
return button; return button;
...@@ -116,7 +91,8 @@ ev_toolbar_create_toggle_button (EvToolbar *ev_toolbar, ...@@ -116,7 +91,8 @@ ev_toolbar_create_toggle_button (EvToolbar *ev_toolbar,
{ {
GtkWidget *button = gtk_toggle_button_new (); GtkWidget *button = gtk_toggle_button_new ();
ev_toolbar_set_button_image (ev_toolbar, GTK_BUTTON (button)); gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_button_set_image (GTK_BUTTON (button), gtk_image_new ());
ev_toolbar_set_button_action (ev_toolbar, GTK_BUTTON (button), action); ev_toolbar_set_button_action (ev_toolbar, GTK_BUTTON (button), action);
return button; return button;
...@@ -130,7 +106,8 @@ ev_toolbar_create_menu_button (EvToolbar *ev_toolbar, ...@@ -130,7 +106,8 @@ ev_toolbar_create_menu_button (EvToolbar *ev_toolbar,
{ {
GtkWidget *button = gtk_menu_button_new (); GtkWidget *button = gtk_menu_button_new ();
ev_toolbar_set_button_image (ev_toolbar, GTK_BUTTON (button)); gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_button_set_image (GTK_BUTTON (button), gtk_image_new ());
gtk_image_set_from_icon_name (GTK_IMAGE (gtk_button_get_image (GTK_BUTTON (button))), gtk_image_set_from_icon_name (GTK_IMAGE (gtk_button_get_image (GTK_BUTTON (button))),
icon_name, GTK_ICON_SIZE_MENU); icon_name, GTK_ICON_SIZE_MENU);
gtk_widget_set_halign (menu, menu_align); gtk_widget_set_halign (menu, menu_align);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment