diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-09-18 23:28:49 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-09-18 23:28:49 (EDT) |
commit | f86483d624227ea01a5d3ed2ddf814cb747cc246 (patch) | |
tree | 4bfb06d9d458413e31a097584ec4069270e956b5 /src | |
parent | 4091267e4aac077bff98b7d81549ce93f41893c0 (diff) | |
download | marquee-f86483d624227ea01a5d3ed2ddf814cb747cc246.zip marquee-f86483d624227ea01a5d3ed2ddf814cb747cc246.tar.gz marquee-f86483d624227ea01a5d3ed2ddf814cb747cc246.tar.bz2 |
src/tab-chrome.c: Try to resize tab history list icons
Ugly. Doesn't work.
Diffstat (limited to 'src')
-rw-r--r-- | src/tab-chrome.c | 68 |
1 files changed, 59 insertions, 9 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c index 1d10bfa..379aba2 100644 --- a/src/tab-chrome.c +++ b/src/tab-chrome.c @@ -26,6 +26,15 @@ #include "tab-chrome.h" +typedef struct { + guint length; + GtkWidget **icons; + guint allocated; + gint max_width; + gint max_height; +} BackForwardListIcons; + + static void back_clicked_cb(GtkButton __attribute__((unused)) *toolbutton, MqTabChrome *chrome) @@ -50,9 +59,30 @@ back_forward_toggle_button_toggled(GtkToggleButton *toggle_button, "text" : "list")); } +static void +back_forward_list_icon_size_allocate_cb( + GtkWidget __attribute__((unused)) *widget, GdkRectangle *allocation, + BackForwardListIcons *icons) +{ + guint i; + + icons->max_width = MAX(icons->max_width, allocation->width); + icons->max_height = MAX(icons->max_height, allocation->height); + + if (++icons->allocated == icons->length) { + for (i = 0; i < icons->length; ++i) { + gtk_widget_set_size_request(icons->icons[i], + icons->max_width, icons->max_height); + gtk_widget_queue_resize(icons->icons[i]); + } + g_free(icons->icons); + g_free(icons); + } +} + static GtkWidget * back_forward_list_item_new(WebKitBackForwardListItem *list_item, - GtkWidget *icon) + GtkWidget *icon, BackForwardListIcons *icons) { GtkWidget *label; GtkWidget *box; @@ -67,6 +97,9 @@ back_forward_list_item_new(WebKitBackForwardListItem *list_item, gtk_widget_set_tooltip_text(box, webkit_back_forward_list_item_get_uri(list_item)); + g_signal_connect(icon, "size-allocate", + G_CALLBACK(back_forward_list_icon_size_allocate_cb), icons); + return box; } @@ -76,6 +109,9 @@ back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event, { WebKitBackForwardList *back_forward_list; GtkWidget *list_box; + BackForwardListIcons *icons; + gint i; + GtkWidget *icon; GList *list_item; GtkWidget *stack; GtkWidget *toggle_button; @@ -94,29 +130,43 @@ 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); + icons = g_malloc(sizeof(*icons)); + icons->length = webkit_back_forward_list_get_length(back_forward_list); + icons->icons = g_malloc((webkit_back_forward_list_get_length( + back_forward_list) + 3) * sizeof(*icons->icons)); + icons->allocated = 0; + icons->max_width = 0; + icons->max_height = 0; + i = 0; + + icon = gtk_radio_button_new(NULL); 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)), - -1); + back_forward_list), icon, icons), -1); gtk_list_box_select_row(GTK_LIST_BOX(list_box), gtk_list_box_get_row_at_index(GTK_LIST_BOX(list_box), 0)); + icons->icons[i++] = icon; list_item = webkit_back_forward_list_get_back_list( back_forward_list); for (; list_item; list_item = list_item->next) { + icon = 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(list_item->data, - gtk_image_new_from_icon_name("go-previous", - GTK_ICON_SIZE_BUTTON)), 0); + back_forward_list_item_new(list_item->data, icon, + icons), 0); + icons->icons[i++] = icon; } list_item = webkit_back_forward_list_get_forward_list( back_forward_list); for (; list_item; list_item = list_item->next) { + icon = gtk_image_new_from_icon_name("go-next", + GTK_ICON_SIZE_BUTTON); 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); + back_forward_list_item_new(list_item->data, icon, + icons), -1); + icons->icons[i++] = icon; } stack = gtk_stack_new(); |