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 int global_class_del (lua_State *L) { TRY_START check_args(L,1); std::string name = check_path(L,1); class_del(L,class_get(name)); return 0; TRY_END }
static int global_class_get (lua_State *L) { TRY_START check_args(L,1); std::string name = check_path(L,1); push_gritcls(L,class_get(name)); return 1; TRY_END }
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); }
/* * test_class_get * make test call to class_get which should return * a pointer to the class passed in and increase * the reference count to that kobject */ static int test_class_get() { int rc; struct class *tmp = NULL; /* get reference count before test call */ tmp = class_get(&test_class); if (tmp == &test_class) { printk("tbase: Success get class\n"); rc = 0; } else { printk("tbase: Failure get class\n"); rc = 1; } class_put(&test_class); return rc; }
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); }