diff options
author | Felipe Erias Morandeira <femorandeira@igalia.com> | 2013-05-30 16:29:34 +0200 |
---|---|---|
committer | Felipe Erias Morandeira <femorandeira@igalia.com> | 2013-06-03 12:19:03 +0200 |
commit | fe0ceec09b893a617e3b1cfd99e4cc6c3454844f (patch) | |
tree | b1da3d54d9a9842f17c500bca7d6b75a90d64dca /endless/eosactionbutton.c | |
parent | 12a5a83f4e7f2e5c20b13e48f7b70c519b37f592 (diff) |
EosActionButton: removed EOS_SDK_ALL_API_VERSIONS, as this is a private header,
setting a NULL icon id clears the icon (was displaying a warning before)
some changes to code style
[endlessm/eos-sdk#30]
Diffstat (limited to 'endless/eosactionbutton.c')
-rw-r--r-- | endless/eosactionbutton.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/endless/eosactionbutton.c b/endless/eosactionbutton.c index 94aa11d..14106d4 100644 --- a/endless/eosactionbutton.c +++ b/endless/eosactionbutton.c @@ -185,8 +185,7 @@ eos_action_button_init (EosActionButton *self) gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->grid)); - // TODO positioning is not really working right - // it will be done manually in draw () + // TODO positioning is not really working right, it will be done manually in draw () gtk_widget_set_hexpand (GTK_WIDGET(self), FALSE); gtk_widget_set_halign (GTK_WIDGET(self), GTK_ALIGN_CENTER); @@ -237,30 +236,36 @@ eos_action_button_load_icon (EosActionButton *button) // TODO maybe use gtk_image_set_from_icon_set - g_return_if_fail (priv->icon_id != NULL); - - icon_info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), - priv->icon_id, - icon_sizes[priv->size].icon_size, - GTK_ICON_LOOKUP_FORCE_SIZE - | GTK_ICON_LOOKUP_GENERIC_FALLBACK - | GTK_ICON_LOOKUP_USE_BUILTIN ); - - new_icon = gtk_icon_info_load_symbolic_for_context (icon_info, - gtk_widget_get_style_context (GTK_WIDGET(button)), - &was_symbolic, - &error); - - if (!was_symbolic) + if (priv->icon_id != NULL) { - g_warning ("Icon for %s is not symbolic\n", priv->icon_id); + icon_info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), + priv->icon_id, + icon_sizes[priv->size].icon_size, + GTK_ICON_LOOKUP_FORCE_SIZE + | GTK_ICON_LOOKUP_GENERIC_FALLBACK + | GTK_ICON_LOOKUP_USE_BUILTIN ); + + new_icon = gtk_icon_info_load_symbolic_for_context (icon_info, + gtk_widget_get_style_context (GTK_WIDGET(button)), + &was_symbolic, + &error); + + if (!was_symbolic) + { + g_warning ("Icon for %s is not symbolic\n", priv->icon_id); + } + if (error != NULL) + { + g_warning ("Unable to load icon for %s : %s\n", priv->icon_id, error->message); + g_error_free (error); + } + g_object_ref (new_icon); + g_object_unref (icon_info); } - if (error != NULL) + else { - g_warning ("Unable to load icon for %s : %s\n", priv->icon_id, error->message); - g_error_free (error); + new_icon = NULL; } - g_object_unref (icon_info); if (priv->icon_pixbuf != NULL) { @@ -268,7 +273,6 @@ eos_action_button_load_icon (EosActionButton *button) } priv->icon_pixbuf = new_icon; - g_object_ref (priv->icon_pixbuf); gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon_image), priv->icon_pixbuf); } @@ -381,13 +385,13 @@ eos_action_button_get_property (GObject *object, switch (property_id) { - case PROP_SIZE : + case PROP_SIZE: g_value_set_int (value, priv->size); break; - case PROP_LABEL : + case PROP_LABEL: g_value_set_string (value, priv->label); break; - case PROP_ICON_ID : + case PROP_ICON_ID: g_value_set_string (value, priv->icon_id); break; default: |