static void fetch_gravatar_done(GPid pid, gint status, gpointer data) { user_priv *c G_GNUC_UNUSED = data; plugin_instance *p G_GNUC_UNUSED = data; gchar *image = NULL, *icon = NULL; ENTER; DBG("status %d\n", status); g_spawn_close_pid(c->pid); c->pid = 0; c->sid = 0; if (status) RET(); DBG("rebuild menu\n"); XCG(p->xc, "icon", &icon, strdup); XCG(p->xc, "image", &image, strdup); XCS(p->xc, "image", image, value); xconf_del(xconf_find(p->xc, "icon", 0), FALSE); PLUGIN_CLASS(k)->destructor(p); PLUGIN_CLASS(k)->constructor(p); if (image) { XCS(p->xc, "image", image, value); g_free(image); } if (icon) { XCS(p->xc, "icon", icon, value); g_free(icon); } RET(); }
static int net_constructor(plugin_instance *p) { net_priv *c; if (!(k = class_get("chart"))) RET(0); if (!PLUGIN_CLASS(k)->constructor(p)) RET(0); c = (net_priv *) p; c->iface = "eth0"; c->max_rx = 120; c->max_tx = 12; c->colors[0] = "violet"; c->colors[1] = "blue"; XCG(p->xc, "interface", &c->iface, str); XCG(p->xc, "RxLimit", &c->max_rx, int); XCG(p->xc, "TxLimit", &c->max_tx, int); XCG(p->xc, "TxColor", &c->colors[0], str); XCG(p->xc, "RxColor", &c->colors[1], str); init_net_stats(c); c->max = c->max_rx + c->max_tx; k->set_rows(&c->chart, 2, c->colors); gtk_widget_set_tooltip_markup(((plugin_instance *)c)->pwid, "<b>Net</b>"); net_get_load(c); c->timer = g_timeout_add(CHECK_PERIOD * 1000, (GSourceFunc) net_get_load, (gpointer) c); RET(1); }
static int volume_constructor(plugin_instance *p) { volume_priv *c = (volume_priv *) p; if ((c->fd = open ("/dev/mixer", O_RDWR, 0)) < 0) { ERR("volume: can't open /dev/mixer\n"); RET(1); } if (!(k = class_get("meter"))) RET(0); if (!PLUGIN_CLASS(k)->constructor(p)) RET(0); k->set_icons(&c->meter, names); c->update_id = g_timeout_add(1000, (GSourceFunc) volume_update_gui, c); c->vol = 200; c->chan = SOUND_MIXER_VOLUME; volume_update_gui(c); g_signal_connect(G_OBJECT(p->pwid), "scroll-event", G_CALLBACK(icon_scrolled), (gpointer) c); g_signal_connect(G_OBJECT(p->pwid), "button_press_event", G_CALLBACK(icon_clicked), (gpointer)c); g_signal_connect(G_OBJECT(p->pwid), "enter-notify-event", G_CALLBACK(crossed), (gpointer)c); g_signal_connect(G_OBJECT(p->pwid), "leave-notify-event", G_CALLBACK(crossed), (gpointer)c); RET(1); }
static void battery_destructor(plugin_instance *p) { battery_priv *c = (battery_priv *) p; ENTER; if (c->timer) g_source_remove(c->timer); PLUGIN_CLASS(k)->destructor(p); class_put("meter"); RET(); }
static void net_destructor(plugin_instance *p) { net_priv *c = (net_priv *) p; ENTER; if (c->timer) g_source_remove(c->timer); PLUGIN_CLASS(k)->destructor(p); class_put("chart"); RET(); }
static void volume_destructor(plugin_instance *p) { volume_priv *c = (volume_priv *) p; ENTER; g_source_remove(c->update_id); if (c->slider_window) gtk_widget_destroy(c->slider_window); PLUGIN_CLASS(k)->destructor(p); class_put("meter"); RET(); }
static void user_destructor(plugin_instance *p) { user_priv *c G_GNUC_UNUSED = (user_priv *) p; ENTER; PLUGIN_CLASS(k)->destructor(p); if (c->pid) kill(c->pid, SIGKILL); if (c->sid) g_source_remove(c->sid); class_put("menu"); RET(); }
static int battery_constructor(plugin_instance *p) { battery_priv *c; ENTER; if (!(k = class_get("meter"))) RET(0); if (!PLUGIN_CLASS(k)->constructor(p)) RET(0); c = (battery_priv *) p; c->timer = g_timeout_add(2000, (GSourceFunc) battery_update, c); battery_update(c); RET(1); }
static void process_client_msg ( XClientMessageEvent* ev ) { int cmd = ev->data.b[0]; switch( cmd ) { #ifndef DISABLE_MENU case LXPANEL_CMD_SYS_MENU: { GSList* l; for( l = all_panels; l; l = l->next ) { LXPanel* p = (LXPanel*)l->data; GList *plugins, *pl; if (p->priv->box == NULL) continue; plugins = gtk_container_get_children(GTK_CONTAINER(p->priv->box)); for (pl = plugins; pl; pl = pl->next) { const LXPanelPluginInit *init = PLUGIN_CLASS(pl->data); if (init->show_system_menu) /* queue to show system menu */ init->show_system_menu(pl->data); } g_list_free(plugins); } break; } #endif case LXPANEL_CMD_RUN: gtk_run(); break; case LXPANEL_CMD_CONFIG: { LXPanel * p = ((all_panels != NULL) ? all_panels->data : NULL); if (p != NULL) panel_configure(p, 0); } break; case LXPANEL_CMD_RESTART: restart(); break; case LXPANEL_CMD_EXIT: gtk_main_quit(); break; } }
static int user_constructor(plugin_instance *p) { user_priv *c G_GNUC_UNUSED = (user_priv *) p; gchar *image = NULL; gchar *icon = NULL; gchar *gravatar = NULL; ENTER; if (!(k = class_get("menu"))) RET(0); XCG(p->xc, "image", &image, str); XCG(p->xc, "icon", &icon, str); if (!(image || icon)) XCS(p->xc, "icon", "avatar-default", value); if (!PLUGIN_CLASS(k)->constructor(p)) RET(0); XCG(p->xc, "gravataremail", &gravatar, str); DBG("gravatar email '%s'\n", gravatar); if (gravatar) g_timeout_add(300, fetch_gravatar, p); gtk_widget_set_tooltip_markup(p->pwid, "<b>User</b>"); RET(1); }