diff options
author | Timm Bäder <mail@baedert.org> | 2015-03-14 21:50:00 +0100 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2015-05-25 13:00:34 +0200 |
commit | 1ea75bf8fbd4c19eea0f3b880b7c73d0432d91c9 (patch) | |
tree | c27bb53018d25ed74bbbb2cfa17715aac2683aac | |
parent | deb476266c4775b3b43736e47dc39262f6932784 (diff) | |
download | gtk+-1ea75bf8fbd4c19eea0f3b880b7c73d0432d91c9.tar.gz |
popover: Expand buttons over entire width
-rw-r--r-- | gtk/gtkmenusectionbox.c | 29 | ||||
-rw-r--r-- | gtk/gtkmodelbutton.c | 25 | ||||
-rw-r--r-- | gtk/theme/Adwaita/gtk-contained.css | 6 |
3 files changed, 34 insertions, 26 deletions
diff --git a/gtk/gtkmenusectionbox.c b/gtk/gtkmenusectionbox.c index 1f38e1b81f..6bd117a9d0 100644 --- a/gtk/gtkmenusectionbox.c +++ b/gtk/gtkmenusectionbox.c @@ -405,7 +405,10 @@ gtk_menu_section_box_new_toplevel (GtkStack *stack, { GtkMenuSectionBox *box; - box = g_object_new (GTK_TYPE_MENU_SECTION_BOX, "margin", 10, NULL); + box = g_object_new (GTK_TYPE_MENU_SECTION_BOX, + "margin-top", 12, + "margin-bottom", 12, + NULL); gtk_stack_add_named (stack, GTK_WIDGET (box), "main"); box->tracker = gtk_menu_tracker_new (GTK_ACTION_OBSERVABLE (_gtk_widget_get_action_muxer (GTK_WIDGET (box), TRUE)), @@ -428,7 +431,10 @@ gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item, GtkMenuSectionBox *box; GtkWidget *button; - box = g_object_new (GTK_TYPE_MENU_SECTION_BOX, "margin", 10, NULL); + box = g_object_new (GTK_TYPE_MENU_SECTION_BOX, + "margin-top", 12, + "margin-bottom", 12, + NULL); button = g_object_new (GTK_TYPE_MODEL_BUTTON, "menu-name", name, @@ -480,6 +486,8 @@ gtk_menu_section_box_new_section (GtkMenuTrackerItem *item, gtk_orientable_set_orientation (GTK_ORIENTABLE (box->item_box), GTK_ORIENTATION_HORIZONTAL); gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (box->item_box)), GTK_STYLE_CLASS_LINKED); box->iconic = TRUE; + gtk_widget_set_margin_start (GTK_WIDGET (box->item_box), 12); + gtk_widget_set_margin_end (GTK_WIDGET (box->item_box), 12); } if (label != NULL) @@ -494,12 +502,6 @@ gtk_menu_section_box_new_section (GtkMenuTrackerItem *item, box->separator = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); g_object_ref_sink (box->separator); - g_object_set (box->separator, - "margin-start", 12, - "margin-end", 12, - "margin-top", 6, - "margin-bottom", 3, - NULL); gtk_container_add (GTK_CONTAINER (box->separator), title); gtk_container_add (GTK_CONTAINER (box->separator), separator); gtk_widget_show_all (box->separator); @@ -509,14 +511,13 @@ gtk_menu_section_box_new_section (GtkMenuTrackerItem *item, box->separator = separator; g_object_ref_sink (box->separator); - g_object_set (box->separator, - "margin-start", 12, - "margin-end", 12, - "margin-top", 3, - "margin-bottom", 3, - NULL); gtk_widget_show (box->separator); } + g_object_set (box->separator, + "margin-top", 4, + "margin-bottom", 4, + NULL); + box->tracker = gtk_menu_tracker_new_for_item_link (item, G_MENU_LINK_SECTION, FALSE, FALSE, gtk_menu_section_box_insert_func, diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c index a3c62bc52e..6a16b00ba3 100644 --- a/gtk/gtkmodelbutton.c +++ b/gtk/gtkmodelbutton.c @@ -35,6 +35,8 @@ #include "gtkpopover.h" #include "gtkintl.h" +#define INDICATOR_MARGIN 24 + /** * SECTION:gtkmodelbutton * @Short_description: A button that uses a GAction as model @@ -293,6 +295,7 @@ gtk_model_button_set_iconic (GtkModelButton *button, gtk_style_context_remove_class (context, GTK_STYLE_CLASS_MENUITEM); gtk_style_context_add_class (context, "image-button"); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NORMAL); + g_object_set (G_OBJECT (button->box), "margin", 4, NULL); } else { @@ -415,7 +418,7 @@ gtk_model_button_get_full_border (GtkModelButton *button, border_width = gtk_container_get_border_width (GTK_CONTAINER (button)); gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &indicator_size, NULL); - indicator_spacing = indicator_size / 8; + indicator_spacing = indicator_size / 2; border->left = border_width; border->right = border_width; @@ -425,7 +428,7 @@ gtk_model_button_get_full_border (GtkModelButton *button, if (button->iconic) *indicator = 0; else - *indicator = indicator_size + 2 * indicator_spacing; + *indicator = indicator_size + indicator_spacing; } static gboolean @@ -634,7 +637,7 @@ indicator_is_left (GtkWidget *widget) return ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL && !button->inverted) || (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR && button->inverted)); - + } static void @@ -660,7 +663,7 @@ gtk_model_button_size_allocate (GtkWidget *widget, { GtkBorder border; gint indicator; - + gtk_model_button_get_full_border (button, &border, &indicator); if (button->centered) @@ -722,7 +725,7 @@ gtk_model_button_draw (GtkWidget *widget, gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &indicator_size, NULL); indicator_spacing = indicator_size / 8; - x = width - border_width - indicator_spacing - indicator_size; + x = width - border_width - INDICATOR_MARGIN - indicator_size; if (indicator_is_left (widget)) x = width - (indicator_size + x); @@ -777,7 +780,7 @@ gtk_model_button_draw (GtkWidget *widget, if (gtk_widget_has_visible_focus (widget)) { GtkBorder border; - + gtk_style_context_get_border (context, gtk_style_context_get_state (context), &border); gtk_render_focus (context, cr, @@ -861,7 +864,7 @@ gtk_model_button_class_init (GtkModelButtonClass *class) * * Since: 3.16 */ - properties[PROP_ICON] = + properties[PROP_ICON] = g_param_spec_object ("icon", P_("Icon"), P_("The icon"), @@ -968,10 +971,10 @@ gtk_model_button_init (GtkModelButton *button) { gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); button->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_widget_set_margin_start (button->box, 12); - gtk_widget_set_margin_end (button->box, 12); - gtk_widget_set_margin_top (button->box, 3); - gtk_widget_set_margin_bottom (button->box, 3); + gtk_widget_set_margin_start (button->box, 24); + gtk_widget_set_margin_end (button->box, 24); + gtk_widget_set_margin_top (button->box, 4); + gtk_widget_set_margin_bottom (button->box, 4); gtk_widget_set_halign (button->box, GTK_ALIGN_FILL); gtk_widget_show (button->box); button->image = gtk_image_new (); diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css index 8074dc99c7..071e7103a2 100644 --- a/gtk/theme/Adwaita/gtk-contained.css +++ b/gtk/theme/Adwaita/gtk-contained.css @@ -2057,8 +2057,12 @@ column-header .titlebar .button.titlebutton, /*************** * Popovers * ***************/ + +.popover .menuitem.button { + border-radius: 0px; +} + .popover { - padding: 2px; border: 1px solid #a1a1a1; border-radius: 5px; background-color: #f6f6f6; |