summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-09-18 20:06:24 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-09-18 20:06:24 (EDT)
commit6eb6482e94ee5a82891a7e3294e4f8d72f2104d5 (patch)
tree947a0c57672abf4bee4f1f2bc317691316c54831 /src
parent402bde1446f7af77ea8f70b43891167ad2cef0d0 (diff)
downloadmarquee-6eb6482e94ee5a82891a7e3294e4f8d72f2104d5.zip
marquee-6eb6482e94ee5a82891a7e3294e4f8d72f2104d5.tar.gz
marquee-6eb6482e94ee5a82891a7e3294e4f8d72f2104d5.tar.bz2
src/tab-chrome.c: Try to synchronize tab history list icon sizes
Doesn't work.
Diffstat (limited to 'src')
-rw-r--r--src/tab-chrome.c52
1 files changed, 48 insertions, 4 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c
index 88c440d..25d132b 100644
--- a/src/tab-chrome.c
+++ b/src/tab-chrome.c
@@ -50,9 +50,44 @@ back_forward_toggle_button_toggled(GtkToggleButton *toggle_button,
"text" : "list"));
}
+static GtkRequisition *
+get_max_requisition(GtkWidget *widget_a, GtkWidget *widget_b)
+{
+ GtkRequisition *req_a;
+ GtkRequisition *req_b;
+ GtkRequisition *max_req;
+
+ /* Allocate widget requisitions. */
+ req_a = g_malloc(sizeof(*req_a));
+ req_b = g_malloc(sizeof(*req_b));
+
+ /* Get requisitions. */
+ gtk_widget_get_preferred_size(widget_a, req_a, NULL);
+ gtk_widget_get_preferred_size(widget_b, req_b, NULL);
+
+ /* Allocate and calculate maximum requisition. */
+ max_req = g_malloc(sizeof(*max_req));
+ max_req->width = MAX(req_a->width, req_b->width);
+ max_req->height = MAX(req_a->height, req_b->height);
+
+ /* Free widget requisitions. */
+ g_free(req_a);
+ g_free(req_b);
+
+ /* For convenience, remove the widgets' floating references (assume
+ * ownership) and decrease their reference counts (finalize them).
+ * They're instantiated only for this function. */
+ g_object_ref_sink(widget_a);
+ g_object_ref_sink(widget_b);
+ g_object_unref(widget_a);
+ g_object_unref(widget_b);
+
+ return max_req;
+}
+
static GtkWidget *
back_forward_list_item_new(WebKitBackForwardListItem *list_item,
- GtkWidget *icon)
+ GtkWidget *icon, GtkRequisition *max_req)
{
GtkWidget *label;
GtkWidget *box;
@@ -60,6 +95,7 @@ back_forward_list_item_new(WebKitBackForwardListItem *list_item,
label = gtk_label_new(webkit_back_forward_list_item_get_title(
list_item));
gtk_widget_set_halign(label, GTK_ALIGN_START);
+ gtk_widget_set_size_request(icon, max_req->width, max_req->height);
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start(GTK_BOX(box), icon, FALSE, FALSE, 0);
@@ -76,6 +112,7 @@ back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event,
{
WebKitBackForwardList *back_forward_list;
GtkWidget *list_box;
+ GtkRequisition *max_req;
GList *list_item;
GtkWidget *stack;
GtkWidget *toggle_button;
@@ -94,9 +131,14 @@ back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event,
GTK_SELECTION_BROWSE);
gtk_list_box_set_activate_on_single_click(GTK_LIST_BOX(list_box), TRUE);
+ max_req = get_max_requisition(gtk_radio_button_new(NULL),
+ gtk_image_new_from_icon_name("go-previous",
+ GTK_ICON_SIZE_BUTTON));
+
gtk_list_box_insert(GTK_LIST_BOX(list_box), back_forward_list_item_new(
webkit_back_forward_list_get_current_item(
- back_forward_list), gtk_radio_button_new(NULL)),
+ back_forward_list), gtk_radio_button_new(NULL),
+ max_req),
-1);
gtk_list_box_select_row(GTK_LIST_BOX(list_box),
gtk_list_box_get_row_at_index(GTK_LIST_BOX(list_box), 0));
@@ -107,7 +149,7 @@ back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event,
gtk_list_box_insert(GTK_LIST_BOX(list_box),
back_forward_list_item_new(list_item->data,
gtk_image_new_from_icon_name("go-previous",
- GTK_ICON_SIZE_BUTTON)), 0);
+ GTK_ICON_SIZE_BUTTON), max_req), 0);
}
list_item = webkit_back_forward_list_get_forward_list(
@@ -116,9 +158,11 @@ back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event,
gtk_list_box_insert(GTK_LIST_BOX(list_box),
back_forward_list_item_new(list_item->data,
gtk_image_new_from_icon_name("go-next",
- GTK_ICON_SIZE_BUTTON)), -1);
+ GTK_ICON_SIZE_BUTTON), max_req), -1);
}
+ g_free(max_req);
+
stack = gtk_stack_new();
gtk_stack_add_named(GTK_STACK(stack), list_box, "list");
gtk_stack_add_named(GTK_STACK(stack), gtk_label_new("Text"), "text");