aboutsummaryrefslogtreecommitdiff
path: root/src/applet-main.c
blob: 5f5461a9f28458013e2dc5403f012c71e485d5cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

#include <panel-applet.h>

#include "indicator-audio.h"
#include "indicator-messages.h"
#include "indicator-network.h"
#include "indicator-power.h"
#include "indicator-system.h"

static gboolean     applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data);


/*************
 * main
 * ***********/

PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_IndicatorApplet_Factory",
               PANEL_TYPE_APPLET,
               "indicator-applet", "0",
               applet_fill_cb, NULL);

typedef GtkWidget * (*menuitem_func) (void);

menuitem_func indicators[] = {
	indicator_audio_menuitem,
	indicator_messages_menuitem,
	indicator_network_menuitem,
	indicator_power_menuitem,
	indicator_system_menuitem,
	NULL
};

/*************
 * init function
 * ***********/

static gboolean
applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data)
{
	int i;
	GtkWidget * menubar = gtk_menu_bar_new();
	gtk_widget_set_name (menubar, "indicator-applet-menubar");
	gtk_container_add(GTK_CONTAINER(applet), menubar);
	gtk_widget_show(menubar);

	for (i = 0; indicators[i] != NULL; i++) {
		GtkWidget * item = indicators[i]();
		if (item == NULL) continue;
		gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
		gtk_widget_show(item);
	}

	gtk_widget_show(GTK_WIDGET(applet));
	return TRUE;
}