Let the applets choose if they want to expand or fill the available size

This commit is contained in:
Pierre Pronchery 2009-08-10 01:31:33 +00:00
parent 47ab15d16d
commit 29c9cb744c
10 changed files with 33 additions and 5 deletions

View File

@ -51,6 +51,8 @@ struct _PanelApplet
PanelAppletInitFunc init;
PanelAppletDestroyFunc destroy;
PanelAppletPosition position;
gboolean expand;
gboolean fill;
void * priv;
};

View File

@ -50,6 +50,8 @@ PanelApplet applet =
_clock_init,
_clock_destroy,
PANEL_APPLET_POSITION_LAST,
FALSE,
TRUE,
NULL
};

View File

@ -57,6 +57,8 @@ PanelApplet applet =
_cpu_init,
_cpu_destroy,
PANEL_APPLET_POSITION_END,
FALSE,
TRUE,
NULL
};

View File

@ -38,6 +38,8 @@ PanelApplet applet =
_desktop_init,
NULL,
PANEL_APPLET_POSITION_FIRST,
FALSE,
TRUE,
NULL
};

View File

@ -35,6 +35,8 @@ PanelApplet applet =
_lock_init,
NULL,
PANEL_APPLET_POSITION_START,
FALSE,
TRUE,
NULL
};

View File

@ -35,6 +35,8 @@ PanelApplet applet =
_logout_init,
NULL,
PANEL_APPLET_POSITION_START,
FALSE,
TRUE,
NULL
};

View File

@ -90,6 +90,8 @@ PanelApplet applet =
_main_init,
_main_destroy,
PANEL_APPLET_POSITION_FIRST,
FALSE,
TRUE,
NULL
};

View File

@ -52,6 +52,8 @@ PanelApplet applet =
_memory_init,
_memory_destroy,
PANEL_APPLET_POSITION_END,
FALSE,
TRUE,
NULL
};

View File

@ -119,6 +119,8 @@ PanelApplet applet =
_tasks_init,
_tasks_destroy,
PANEL_APPLET_POSITION_START,
TRUE,
TRUE,
NULL
};
@ -189,6 +191,7 @@ static void _task_set(Task * task, char const * name, GdkPixbuf * pixbuf)
/* tasks_init */
static GtkWidget * _tasks_init(PanelApplet * applet)
{
GtkWidget * ret;
Tasks * tasks;
if((tasks = malloc(sizeof(*tasks))) == NULL)
@ -206,7 +209,12 @@ static GtkWidget * _tasks_init(PanelApplet * applet)
tasks->display = NULL;
tasks->screen = NULL;
tasks->root = NULL;
return tasks->hbox;
ret = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ret),
GTK_POLICY_NEVER, GTK_POLICY_NEVER);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(ret),
tasks->hbox);
return ret;
}

View File

@ -128,6 +128,8 @@ static gboolean _on_idle(gpointer data)
Plugin * plugin;
PanelApplet * applet;
GtkWidget * widget;
gboolean exp;
gboolean fill;
for(i = 0; plugins[i] != NULL; i++)
if((plugin = plugin_new(LIBDIR, PACKAGE, "applets", plugins[i]))
@ -138,29 +140,31 @@ static gboolean _on_idle(gpointer data)
&& applet->init != NULL
&& (widget = applet->init(applet)) != NULL)
{
exp = applet->expand;
fill = applet->fill;
switch(applet->position)
{
case PANEL_APPLET_POSITION_END:
gtk_box_pack_end(GTK_BOX(panel->hbox),
widget, FALSE, TRUE, 2);
widget, exp, fill, 2);
break;
case PANEL_APPLET_POSITION_FIRST:
gtk_box_pack_start(GTK_BOX(panel->hbox),
widget, FALSE, TRUE, 2);
widget, exp, fill, 2);
gtk_box_reorder_child(GTK_BOX(
panel->hbox),
widget, 0);
break;
case PANEL_APPLET_POSITION_LAST:
gtk_box_pack_end(GTK_BOX(panel->hbox),
widget, FALSE, TRUE, 2);
widget, exp, fill, 2);
gtk_box_reorder_child(GTK_BOX(
panel->hbox),
widget, 0);
break;
case PANEL_APPLET_POSITION_START:
gtk_box_pack_start(GTK_BOX(panel->hbox),
widget, FALSE, TRUE, 2);
widget, exp, fill, 2);
break;
}
gtk_widget_show_all(widget);