Lookup icon size in relation to the according screen or widget

This commit is contained in:
Christian Dywan 2010-01-29 22:30:23 +01:00
parent 37d89d0986
commit cc6bb8fddb
4 changed files with 45 additions and 11 deletions

View file

@ -434,6 +434,7 @@ katze_net_icon_transfer_cb (KatzeNetRequest* request,
GdkPixbuf* pixbuf_scaled; GdkPixbuf* pixbuf_scaled;
gint icon_width, icon_height; gint icon_width, icon_height;
size_t ret; size_t ret;
GtkSettings* settings;
if (request->status == KATZE_NET_MOVED) if (request->status == KATZE_NET_MOVED)
return; return;
@ -479,7 +480,14 @@ katze_net_icon_transfer_cb (KatzeNetRequest* request,
return; return;
} }
} }
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_width, &icon_height);
if (priv->widget)
settings = gtk_widget_get_settings (priv->widget);
else
settings = gtk_settings_get_for_screen (gdk_screen_get_default ());
gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
&icon_width, &icon_height);
pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, icon_width, icon_height, pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, icon_width, icon_height,
GDK_INTERP_BILINEAR); GDK_INTERP_BILINEAR);
g_object_unref (pixbuf); g_object_unref (pixbuf);
@ -536,6 +544,7 @@ katze_net_load_icon (KatzeNet* net,
GdkPixbuf* pixbuf; GdkPixbuf* pixbuf;
gint icon_width, icon_height; gint icon_width, icon_height;
GdkPixbuf* pixbuf_scaled; GdkPixbuf* pixbuf_scaled;
GtkSettings* settings;
g_return_val_if_fail (KATZE_IS_NET (net), NULL); g_return_val_if_fail (KATZE_IS_NET (net), NULL);
g_return_val_if_fail (!widget || GTK_IS_WIDGET (widget), NULL); g_return_val_if_fail (!widget || GTK_IS_WIDGET (widget), NULL);
@ -599,7 +608,14 @@ katze_net_load_icon (KatzeNet* net,
else else
return NULL; return NULL;
} }
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_width, &icon_height);
if (widget)
settings = gtk_widget_get_settings (widget);
else
settings = gtk_settings_get_for_screen (gdk_screen_get_default ());
gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
&icon_width, &icon_height);
pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, icon_width, icon_height, pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, icon_width, icon_height,
GDK_INTERP_BILINEAR); GDK_INTERP_BILINEAR);
g_object_unref (pixbuf); g_object_unref (pixbuf);

View file

@ -34,13 +34,15 @@ proxy_toggle_button_toggled_cb (GtkToggleButton* button,
GObject* object) GObject* object)
{ {
gboolean toggled; gboolean toggled;
const gchar* property;
#ifdef HAVE_HILDON_2_2 #ifdef HAVE_HILDON_2_2
if (HILDON_IS_CHECK_BUTTON (button)) if (HILDON_IS_CHECK_BUTTON (button))
toggled = hildon_check_button_get_active (HILDON_CHECK_BUTTON (button)); toggled = hildon_check_button_get_active (HILDON_CHECK_BUTTON (button));
#else #else
toggled = gtk_toggle_button_get_active (button); toggled = gtk_toggle_button_get_active (button);
#endif #endif
const gchar* property = g_object_get_data (G_OBJECT (button), "property"); property = g_object_get_data (G_OBJECT (button), "property");
g_object_set (object, property, toggled, NULL); g_object_set (object, property, toggled, NULL);
} }
@ -620,8 +622,12 @@ katze_property_proxy (gpointer object,
GtkComboBox* combo; GtkComboBox* combo;
GList* apps; GList* apps;
const gchar* app_type = &hint[12]; const gchar* app_type = &hint[12];
GtkSettings* settings;
gint icon_width = 16; gint icon_width = 16;
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_width, NULL);
settings = gtk_settings_get_for_screen (gdk_screen_get_default ());
gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
&icon_width, NULL);
model = gtk_list_store_new (4, G_TYPE_APP_INFO, G_TYPE_STRING, model = gtk_list_store_new (4, G_TYPE_APP_INFO, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_INT); G_TYPE_STRING, G_TYPE_INT);

View file

@ -3512,10 +3512,12 @@ static void
_action_fullscreen_activate (GtkAction* action, _action_fullscreen_activate (GtkAction* action,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
GdkWindowState state;
if (!GTK_WIDGET (browser)->window) if (!GTK_WIDGET (browser)->window)
return; return;
GdkWindowState state = gdk_window_get_state (GTK_WIDGET (browser)->window); state = gdk_window_get_state (GTK_WIDGET (browser)->window);
if (state & GDK_WINDOW_STATE_FULLSCREEN) if (state & GDK_WINDOW_STATE_FULLSCREEN)
gtk_window_unfullscreen (GTK_WINDOW (browser)); gtk_window_unfullscreen (GTK_WINDOW (browser));
else else
@ -3526,13 +3528,15 @@ static void
_action_back_activate (GtkAction* action, _action_back_activate (GtkAction* action,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
GtkWidget* view;
if (g_object_get_data (G_OBJECT (action), "midori-middle-click")) if (g_object_get_data (G_OBJECT (action), "midori-middle-click"))
{ {
g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0); g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0);
return; return;
} }
GtkWidget* view = midori_browser_get_current_tab (browser); view = midori_browser_get_current_tab (browser);
if (view) if (view)
midori_view_go_back (MIDORI_VIEW (view)); midori_view_go_back (MIDORI_VIEW (view));
} }
@ -3541,13 +3545,15 @@ static void
_action_forward_activate (GtkAction* action, _action_forward_activate (GtkAction* action,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
GtkWidget* view;
if (g_object_get_data (G_OBJECT (action), "midori-middle-click")) if (g_object_get_data (G_OBJECT (action), "midori-middle-click"))
{ {
g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0); g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0);
return; return;
} }
GtkWidget* view = midori_browser_get_current_tab (browser); view = midori_browser_get_current_tab (browser);
if (view) if (view)
midori_view_go_forward (MIDORI_VIEW (view)); midori_view_go_forward (MIDORI_VIEW (view));
} }
@ -3556,13 +3562,15 @@ static void
_action_previous_activate (GtkAction* action, _action_previous_activate (GtkAction* action,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
GtkWidget* view;
if (g_object_get_data (G_OBJECT (action), "midori-middle-click")) if (g_object_get_data (G_OBJECT (action), "midori-middle-click"))
{ {
g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0); g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0);
return; return;
} }
GtkWidget* view = midori_browser_get_current_tab (browser); view = midori_browser_get_current_tab (browser);
if (view) if (view)
{ {
gchar* uri = g_strdup (midori_view_get_previous_page (MIDORI_VIEW (view))); gchar* uri = g_strdup (midori_view_get_previous_page (MIDORI_VIEW (view)));
@ -3575,13 +3583,15 @@ static void
_action_next_activate (GtkAction* action, _action_next_activate (GtkAction* action,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
GtkWidget* view;
if (g_object_get_data (G_OBJECT (action), "midori-middle-click")) if (g_object_get_data (G_OBJECT (action), "midori-middle-click"))
{ {
g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0); g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0);
return; return;
} }
GtkWidget* view = midori_browser_get_current_tab (browser); view = midori_browser_get_current_tab (browser);
if (view) if (view)
{ {
gchar* uri = g_strdup (midori_view_get_next_page (MIDORI_VIEW (view))); gchar* uri = g_strdup (midori_view_get_next_page (MIDORI_VIEW (view)));
@ -4341,7 +4351,8 @@ _action_bookmarks_import_activate (GtkAction* action,
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", 0); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", 0);
combobox = GTK_COMBO_BOX (combo); combobox = GTK_COMBO_BOX (combo);
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_width, NULL); gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (browser)),
GTK_ICON_SIZE_MENU, &icon_width, NULL);
for (i = 0; i < G_N_ELEMENTS (bookmark_clients); i++) for (i = 0; i < G_N_ELEMENTS (bookmark_clients); i++)
{ {
gchar* path = g_build_filename (g_get_home_dir (), gchar* path = g_build_filename (g_get_home_dir (),

View file

@ -811,7 +811,8 @@ midori_search_action_dialog_render_tick_cb (GtkTreeViewColumn* column,
gtk_tree_model_get (model, iter, 0, &item, -1); gtk_tree_model_get (model, iter, 0, &item, -1);
search_action = g_object_get_data (G_OBJECT (treeview), "search-action"); search_action = g_object_get_data (G_OBJECT (treeview), "search-action");
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, NULL); gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (treeview),
GTK_ICON_SIZE_MENU, &width, NULL);
g_object_set (renderer, "stock-id", g_object_set (renderer, "stock-id",
search_action->default_item == item ? GTK_STOCK_YES : NULL, search_action->default_item == item ? GTK_STOCK_YES : NULL,
"width", width + 4, NULL); "width", width + 4, NULL);