Simplify lxpanel_button_{set,update}_icon() usage.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 15 Nov 2014 15:14:04 +0000 (17:14 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 15 Nov 2014 15:14:04 +0000 (17:14 +0200)
ChangeLog
plugins/dirmenu.c
plugins/launchtaskbar.c
plugins/menu.c
plugins/wincmd.c
src/misc.c
src/misc.h

index b595852..e4becf6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
     simpler.
 * Added new lxpanel_image_change_icon() API for simplification reasons so
     other lxpanel_image_* APIs can be replaced completely.
+* APIs lxpanel_button_set_icon() lxpanel_button_update_icon() now don't
+    require setting icon size since created button already follows size
+    from panel settings. Also it doesn't require refresh after the panel
+    configuration change.
 
 0.7.2
 -------------------------------------------------------------------------
index b07a815..28351c9 100644 (file)
@@ -339,8 +339,7 @@ static gboolean dirmenu_apply_configuration(gpointer user_data)
     config_group_set_string(dm->settings, "name", dm->name);
     config_group_set_string(dm->settings, "image", dm->image);
 
-    lxpanel_button_set_icon(p, ((dm->image != NULL) ? dm->image : "file-manager"),
-                            panel_get_icon_size(dm->panel));
+    lxpanel_button_set_icon(p, ((dm->image != NULL) ? dm->image : "file-manager"), -1);
 
     gtk_widget_set_tooltip_text(p, dm->path);
     gtk_container_foreach(GTK_CONTAINER(p), (GtkCallback) dirmenu_apply_configuration_to_children, (gpointer) dm);
index 250868a..0cdc549 100644 (file)
@@ -1461,8 +1461,6 @@ static void launchtaskbar_panel_configuration_changed(LXPanel *panel, GtkWidget
     if (new_icon_size != ltbp->icon_size)
     {
         Task * tk;
-        GSList * l;
-        ltbp->icon_size = new_icon_size;
         for (tk = ltbp->p_task_list; tk != NULL; tk = tk->p_task_flink_xwid)
         {
             GdkPixbuf * pixbuf = task_update_icon(ltbp, tk, None);
@@ -1472,13 +1470,6 @@ static void launchtaskbar_panel_configuration_changed(LXPanel *panel, GtkWidget
                 g_object_unref(pixbuf);
             }
         }
-        for (l = ltbp->buttons; l != NULL; l = l->next)
-        {
-            LaunchButton * btn = (LaunchButton *) l->data;
-            lxpanel_button_update_icon(btn->widget, fm_file_info_get_icon(btn->fi),
-                                       new_icon_size);
-        }
-
     }
 
     /* Redraw all the labels.  Icon size or font color may have changed. */
index c2fe8bc..63895d2 100644 (file)
@@ -1007,7 +1007,7 @@ static gboolean apply_config(gpointer user_data)
     menup* m = lxpanel_plugin_get_data(p);
 
     if( m->fname ) {
-        lxpanel_button_set_icon(m->img, m->fname, panel_get_icon_size(m->panel));
+        lxpanel_button_set_icon(m->img, m->fname, -1);
     }
     config_group_set_string(m->settings, "image", m->fname);
     config_group_set_string(m->settings, "name", m->caption);
index c80819c..4d79c18 100644 (file)
@@ -206,8 +206,9 @@ static gboolean wincmd_apply_configuration(gpointer user_data)
     GtkWidget * p = user_data;
     WinCmdPlugin * wc = lxpanel_plugin_get_data(p);
 
+    //lxpanel_button_set_icon(p, wc->image, -1);
     /* Just save settings */
-    config_group_set_string(wc->settings, "image", wc->image);
+    //config_group_set_string(wc->settings, "image", wc->image);
     config_group_set_string(wc->settings, "Button1",
                             wincmd_names[wc->button_1_command]);
     config_group_set_string(wc->settings, "Button2",
@@ -228,14 +229,6 @@ static GtkWidget *wincmd_configure(LXPanel *panel, GtkWidget *p)
 }
 
 
-/* Callback when panel configuration changes. */
-static void wincmd_panel_reconfigure(LXPanel *panel, GtkWidget *p)
-{
-    WinCmdPlugin * wc = lxpanel_plugin_get_data(p);
-
-    lxpanel_button_set_icon(p, wc->image, panel_get_icon_size(panel));
-}
-
 /* Plugin descriptor. */
 LXPanelPluginInit lxpanel_static_plugin_wincmd = {
     .name = N_("Minimize All Windows"),
@@ -243,6 +236,5 @@ LXPanelPluginInit lxpanel_static_plugin_wincmd = {
 
     .new_instance = wincmd_constructor,
     .config = wincmd_configure,
-    .reconfigure = wincmd_panel_reconfigure,
     .button_press_event = wincmd_button_clicked
 };
index 190b2c0..7904068 100644 (file)
@@ -964,6 +964,8 @@ static void _lxpanel_button_set_icon(GtkWidget* btn, FmIcon* icon, gint size)
     {
         ImgData * data = (ImgData *) g_object_get_qdata(G_OBJECT(img), img_data_id);
 
+        if (size <= 0)
+            size = data->size;
         if (icon != data->icon || size != data->size) /* something was changed */
         {
             g_object_unref(data->icon);
index 34c9b21..e21cafe 100644 (file)
@@ -156,8 +156,16 @@ guint32 gcolor2rgb24(GdkColor *color);
  */
 GtkWidget *lxpanel_button_new_for_icon(LXPanel *panel, const gchar *name, GdkColor *color, const gchar *label);
 GtkWidget *lxpanel_button_new_for_fm_icon(LXPanel *panel, FmIcon *icon, GdkColor *color, const gchar *label);
+
 /**
- * Deprecated since redudant.
+ * lxpanel_button_set_icon
+ * @btn: a button instance
+ * @name: icon name or path
+ * @size: new icon size
+ *
+ * Updates icon in the button created with lxpanel_button_new_for_icon()
+ * or lxpanel_button_new_for_fm_icon() before. If @size > 0 then stop
+ * follow panel icon size and use this fixed size, otherwise not change.
  */
 void lxpanel_button_set_icon(GtkWidget* btn, const gchar *name, gint size);
 void lxpanel_button_update_icon(GtkWidget* btn, FmIcon *icon, gint size);