Add plugin configuration page.
[lxde/lxpanel.git] / src / plugins / deskno.c
CommitLineData
a52c2257
HJYP
1// reused dclock.c and variables from pager.c
2// 11/23/04 by cmeury
3
4#include <sys/types.h>
5#include <stdio.h>
6#include <stdlib.h>
e7cb732b 7#include <glib/gi18n.h>
a52c2257
HJYP
8
9#include "panel.h"
10#include "misc.h"
11#include "plugin.h"
12
13// #define DEBUG
14#include "dbg.h"
15
16typedef struct {
17 GtkWidget *main;
18 GtkWidget *namew;
19 GtkTooltips *tip;
20} deskno;
21
22static void
23clicked( GtkWidget *widget, gpointer data)
24{
25 int desknum = get_net_current_desktop();
26 int desks = get_net_number_of_desktops();
27 int newdesk;
28
29 ENTER;
30 if(desknum == (desks - 1))
31 newdesk = 0;
32 else
33 newdesk = desknum + 1;
34 g_assert(data != NULL);
35 Xclimsg(GDK_ROOT_WINDOW(), a_NET_CURRENT_DESKTOP, newdesk, 0, 0, 0, 0);
36 RET();
37}
38
39
40
41static gint
42name_update(GtkWidget *widget, deskno *dc)
43{
44 char buffer [15];
45 int n;
46 int desknum = get_net_current_desktop() + 1;
47
48 ENTER;
49 n = sprintf(buffer, "<b>%d</b>", desknum);
50 gtk_label_set_markup (GTK_LABEL(dc->namew), buffer) ;
51 RET(TRUE);
52}
53
54
55static int
56deskno_constructor(plugin *p)
57{
58 deskno *dc;
59 GtkWidget *button;
60
61 ENTER;
62 dc = g_new0(deskno, 1);
63 g_return_val_if_fail(dc != NULL, 0);
64 p->priv = dc;
65
66 dc->main = gtk_event_box_new();
67 dc->tip = gtk_tooltips_new();
68 button = gtk_button_new();
69 gtk_button_set_relief(GTK_BUTTON(button),GTK_RELIEF_NONE);
70 g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (clicked), (gpointer) dc);
71 dc->namew = gtk_label_new("ww");
72 gtk_container_add(GTK_CONTAINER(button), dc->namew);
73 gtk_container_add(GTK_CONTAINER(p->pwid), button);
74 gtk_widget_show_all(p->pwid);
75 name_update(button, dc);
76 g_signal_connect (G_OBJECT (fbev), "current_desktop", G_CALLBACK (name_update), (gpointer) dc);
77 RET(1);
78
79
80}
81
82
83static void
84deskno_destructor(plugin *p)
85{
86 deskno *dc = (deskno *)p->priv;
87
88 ENTER;
89 dc = (deskno *) p->priv;
90 g_signal_handlers_disconnect_by_func(G_OBJECT (fbev), name_update, dc);
91 g_free(dc);
92 RET();
93}
94
95plugin_class deskno_plugin_class = {
96 fname: NULL,
97 count: 0,
98
99 type : "deskno",
ce522551 100 name : N_("Desktop No / Workspace Name"),
a52c2257 101 version: "0.6",
e7cb732b 102 description : N_("Display workspace number, by cmeury@users.sf.net"),
a52c2257
HJYP
103
104 constructor : deskno_constructor,
105 destructor : deskno_destructor,
106};