[gnome-applets] don't use panel_applet_get_size
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets] don't use panel_applet_get_size
- Date: Sat, 20 Sep 2014 23:21:16 +0000 (UTC)
commit 370466363c3b53ffcf53aafd891ce2294968251e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Sep 21 02:16:48 2014 +0300
don't use panel_applet_get_size
accessx-status/applet.c | 28 ++++++++++++++++++----------
accessx-status/applet.h | 1 +
charpick/charpick.c | 4 +---
cpufreq/src/cpufreq-applet.c | 1 -
gweather/gweather-applet.c | 8 +++-----
mini-commander/src/mini-commander_applet.c | 1 -
multiload/global.h | 2 ++
multiload/load-graph.c | 2 +-
multiload/main.c | 19 +++++++++++++------
stickynotes/stickynotes_applet.c | 1 -
10 files changed, 39 insertions(+), 28 deletions(-)
---
diff --git a/accessx-status/applet.c b/accessx-status/applet.c
index 4c928d9..5d10a37 100644
--- a/accessx-status/applet.c
+++ b/accessx-status/applet.c
@@ -1049,7 +1049,6 @@ create_applet (PanelApplet *applet)
GtkWidget *box, *stickyfoo;
AtkObject *atko;
GdkPixbuf *pixbuf;
- gint large_toolbar_pixels;
g_set_application_name (_("AccessX Status"));
@@ -1071,12 +1070,10 @@ create_applet (PanelApplet *applet)
stickyfoo = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
}
gtk_box_set_homogeneous (GTK_BOX (stickyfoo), TRUE);
- large_toolbar_pixels = 24; /* FIXME */
- if (panel_applet_get_size (sapplet->applet) >= large_toolbar_pixels)
- icon_size_spec = GTK_ICON_SIZE_LARGE_TOOLBAR;
- else
- icon_size_spec = GTK_ICON_SIZE_SMALL_TOOLBAR;
-
+
+ sapplet->size = 24;
+ icon_size_spec = GTK_ICON_SIZE_LARGE_TOOLBAR;
+
accessx_applet_add_stock_icons (sapplet, box);
pixbuf = accessx_status_applet_mousekeys_image (sapplet, NULL);
sapplet->mousefoo = gtk_image_new_from_pixbuf (pixbuf);
@@ -1162,9 +1159,20 @@ accessx_status_applet_reorient (GtkWidget *widget, PanelAppletOrient o, gpointer
}
static void
-accessx_status_applet_resize (GtkWidget *widget, int size, gpointer user_data)
+accessx_status_applet_resize (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data)
{
- ; /* TODO: either rescale icons to fit panel, or tile them when possible */
+ AccessxStatusApplet *sapplet = (AccessxStatusApplet *) user_data;
+ gint old_size = sapplet->size;
+
+ if (sapplet->orient == PANEL_APPLET_ORIENT_LEFT || sapplet->orient == PANEL_APPLET_ORIENT_RIGHT) {
+ sapplet->size = allocation->width;
+ } else {
+ sapplet->size = allocation->height;
+ }
+
+ if (sapplet->size != old_size) {
+ /* TODO: either rescale icons to fit panel, or tile them when possible */
+ }
}
static gboolean
@@ -1259,7 +1267,7 @@ accessx_status_applet_fill (PanelApplet *applet)
g_object_connect (sapplet->applet,
"signal::destroy", accessx_status_applet_destroy, sapplet,
"signal::change_orient", accessx_status_applet_reorient, sapplet,
- "signal::change_size", accessx_status_applet_resize, sapplet,
+ "signal::size-allocate", accessx_status_applet_resize, sapplet,
NULL);
g_signal_connect (sapplet->applet, "button_press_event",
diff --git a/accessx-status/applet.h b/accessx-status/applet.h
index 5afaa75..6d47cad 100644
--- a/accessx-status/applet.h
+++ b/accessx-status/applet.h
@@ -77,6 +77,7 @@ typedef struct
XkbDescRec *xkb;
Display *xkb_display;
AccessxStatusErrorType error_type;
+ gint size;
} AccessxStatusApplet;
typedef enum
diff --git a/charpick/charpick.c b/charpick/charpick.c
index bf619de..05504cb 100644
--- a/charpick/charpick.c
+++ b/charpick/charpick.c
@@ -756,9 +756,7 @@ charpicker_applet_fill (PanelApplet *applet)
} else {
curr_data->charlist = curr_data->chartable->data;
}
-
- curr_data->panel_size = panel_applet_get_size (applet);
-
+
orientation = panel_applet_get_orient (applet);
curr_data->panel_vertical = (orientation == PANEL_APPLET_ORIENT_LEFT)
|| (orientation == PANEL_APPLET_ORIENT_RIGHT);
diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c
index a703aed..40b8439 100644
--- a/cpufreq/src/cpufreq-applet.c
+++ b/cpufreq/src/cpufreq-applet.c
@@ -191,7 +191,6 @@ cpufreq_applet_init (CPUFreqApplet *applet)
panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR);
panel_applet_set_background_widget (PANEL_APPLET (applet), GTK_WIDGET (applet));
- applet->size = panel_applet_get_size (PANEL_APPLET (applet));
applet->orient = panel_applet_get_orient (PANEL_APPLET (applet));
switch (applet->orient) {
diff --git a/gweather/gweather-applet.c b/gweather/gweather-applet.c
index 74e9afa..9d963d6 100644
--- a/gweather/gweather-applet.c
+++ b/gweather/gweather-applet.c
@@ -153,7 +153,7 @@ static void place_widgets (GWeatherApplet *gw_applet)
if (icon_name != NULL) {
gtk_widget_show (gw_applet->image);
- gtk_widget_size_request(gw_applet->image, &req);
+ gtk_widget_get_preferred_size(gw_applet->image, &req, NULL);
if (horizontal)
total_size += req.height;
else
@@ -171,7 +171,7 @@ static void place_widgets (GWeatherApplet *gw_applet)
/* Check the label size to determine box layout */
gtk_widget_show (gw_applet->label);
- gtk_widget_size_request(gw_applet->label, &req);
+ gtk_widget_get_preferred_size(gw_applet->label, &req, NULL);
if (horizontal)
total_size += req.height;
else
@@ -180,7 +180,7 @@ static void place_widgets (GWeatherApplet *gw_applet)
/* Pack the box */
if (gw_applet->box)
gtk_widget_destroy (gw_applet->box);
-
+
if (horizontal && (total_size <= panel_size))
gw_applet->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
else if (horizontal && (total_size > panel_size))
@@ -354,8 +354,6 @@ void gweather_applet_create (GWeatherApplet *gw_applet)
if (GTK_IS_ACCESSIBLE (atk_obj))
atk_object_set_name (atk_obj, _("GNOME Weather"));
- gw_applet->size = panel_applet_get_size (gw_applet->applet);
-
gw_applet->orient = panel_applet_get_orient (gw_applet->applet);
action_group = gtk_action_group_new ("GWeather Applet Actions");
diff --git a/mini-commander/src/mini-commander_applet.c b/mini-commander/src/mini-commander_applet.c
index 73b9e89..e6313a8 100644
--- a/mini-commander/src/mini-commander_applet.c
+++ b/mini-commander/src/mini-commander_applet.c
@@ -385,7 +385,6 @@ mini_commander_applet_fill (PanelApplet *applet)
g_signal_connect (mc->applet, "size_allocate",
G_CALLBACK (mc_pixel_size_changed), mc);
- mc->preferences.normal_size_y = panel_applet_get_size (applet);
mc->orient = panel_applet_get_orient (applet);
mc_applet_draw(mc);
gtk_widget_show (GTK_WIDGET (mc->applet));
diff --git a/multiload/global.h b/multiload/global.h
index e57739e..a2651cc 100644
--- a/multiload/global.h
+++ b/multiload/global.h
@@ -121,6 +121,8 @@ struct _MultiloadApplet
GtkWidget *notebook;
int last_clicked;
+ guint size;
+
GSettings *settings;
};
diff --git a/multiload/load-graph.c b/multiload/load-graph.c
index d53dafb..ac306f3 100644
--- a/multiload/load-graph.c
+++ b/multiload/load-graph.c
@@ -283,7 +283,7 @@ load_graph_new (MultiloadApplet *ma, guint n, const gchar *label,
g->id = id;
g->speed = MAX (speed, 50);
g->size = MAX (size, 10);
- g->pixel_size = panel_applet_get_size (ma->applet);
+ g->pixel_size = ma->size;
g->tooltip_update = FALSE;
g->show_frame = TRUE;
g->multiload = ma;
diff --git a/multiload/main.c b/multiload/main.c
index 5f120a2..161599e 100644
--- a/multiload/main.c
+++ b/multiload/main.c
@@ -171,13 +171,20 @@ start_procman_cb (GtkAction *action,
}
static void
-multiload_change_size_cb(PanelApplet *applet, gint size, gpointer data)
+multiload_change_size_cb (PanelApplet *applet, GtkAllocation *allocation, gpointer data)
{
MultiloadApplet *ma = (MultiloadApplet *)data;
-
- multiload_applet_refresh(ma);
-
- return;
+ PanelAppletOrient orient = panel_applet_get_orient (applet);
+ gint old_size = ma->size;
+
+ if (orient == PANEL_APPLET_ORIENT_LEFT || orient == PANEL_APPLET_ORIENT_RIGHT) {
+ ma->size = allocation->width;
+ } else {
+ ma->size = allocation->height;
+ }
+
+ if (old_size != ma->size)
+ multiload_applet_refresh(ma);
}
static void
@@ -522,7 +529,7 @@ multiload_applet_new(PanelApplet *applet, const gchar *iid, gpointer data)
g_object_unref (settings);
g_object_unref (action_group);
- g_signal_connect(G_OBJECT(applet), "change_size",
+ g_signal_connect(G_OBJECT(applet), "size-allocate",
G_CALLBACK(multiload_change_size_cb), ma);
g_signal_connect(G_OBJECT(applet), "change_orient",
G_CALLBACK(multiload_change_orient_cb), ma);
diff --git a/stickynotes/stickynotes_applet.c b/stickynotes/stickynotes_applet.c
index 12e0834..0e52750 100644
--- a/stickynotes/stickynotes_applet.c
+++ b/stickynotes/stickynotes_applet.c
@@ -360,7 +360,6 @@ StickyNotesApplet * stickynotes_applet_new(PanelApplet *panel_applet)
/* Add the applet icon */
gtk_container_add(GTK_CONTAINER(panel_applet), applet->w_image);
- applet->panel_size = panel_applet_get_size (panel_applet);
applet->panel_orient = panel_applet_get_orient (panel_applet);
stickynotes_applet_update_icon(applet);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]