Replace old "pager" plugin with "wnckpager".
[lxde/lxpanel.git] / src / plugins / pager.c
1 /* pager.c -- pager module of lxpanel project
2 *
3 * Copyright (C) 2009 Dongxu Li <song6song@sourceforge.net>
4 *
5 * This file is part of lxpanel.
6 *
7 * lxpanel is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * lxpanel is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with sawfish; see the file COPYING. If not, write to
19 * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301 USA.
21 */
22
23 #include <gtk/gtk.h>
24
25 #include <glib/gi18n.h>
26 #ifndef WNCK_I_KNOW_THIS_IS_UNSTABLE
27 #define WNCK_I_KNOW_THIS_IS_UNSTABLE
28 #endif
29 #include <libwnck/libwnck.h>
30
31 #include "panel.h"
32 #include "misc.h"
33 #include "private.h"
34
35 #include "dbg.h"
36
37 typedef struct _pager {
38 Plugin* plugin;
39 GtkWidget *box;
40 } pager;
41
42
43 static int
44 pager_constructor(Plugin *plug, char **fp)
45 {
46 pager *pg;
47
48 ENTER;
49 pg = g_new0(pager, 1);
50 g_return_val_if_fail(pg != NULL, 0);
51 plug->priv = pg;
52 pg->plugin = plug;
53
54 plug->pwid = gtk_event_box_new();
55 GTK_WIDGET_SET_FLAGS( plug->pwid, GTK_NO_WINDOW );
56
57 pg->box = wnck_pager_new(NULL);
58 g_return_val_if_fail(pg->box != NULL, 0);
59 //set orientation
60 wnck_pager_set_orientation (WNCK_PAGER (pg->box),pg->plugin->panel->orientation);
61 wnck_pager_set_n_rows (WNCK_PAGER (pg->box), 1); //pager->rows);
62 wnck_pager_set_display_mode (WNCK_PAGER (pg->box),WNCK_PAGER_DISPLAY_CONTENT);
63 //pager->show_names ? WNCK_PAGER_DISPLAY_NAME : WNCK_PAGER_DISPLAY_CONTENT);
64
65 //gtk_container_set_border_width (GTK_CONTAINER (pg->box), 2);
66 gtk_widget_show(pg->box);
67
68 gtk_container_set_border_width (GTK_CONTAINER (plug->pwid), 1);
69 gtk_container_add(GTK_CONTAINER(plug->pwid), pg->box);
70
71 RET(1);
72 }
73
74 static void
75 pager_destructor(Plugin *p)
76 {
77 pager *pg = (pager *)p->priv;
78
79 ENTER;
80 gtk_widget_destroy(p->pwid);
81 g_free(pg);
82 RET();
83 }
84
85 static void pager_panel_configuration_changed(Plugin * p)
86 {
87 pager *pg = (pager *)p->priv;
88
89 wnck_pager_set_orientation (WNCK_PAGER (pg->box),pg->plugin->panel->orientation);
90 wnck_pager_set_n_rows (WNCK_PAGER (pg->box), pg->plugin->panel->height / 48 + 1);
91 }
92
93 PluginClass pager_plugin_class = {
94
95 PLUGINCLASS_VERSIONING,
96
97 .type = "pager",
98 .name = N_("Desktop Pager"),
99 .version = "1.0",
100 .description = N_("Simple pager plugin"),
101
102 .constructor = pager_constructor,
103 .destructor = pager_destructor,
104 .config = NULL,
105 .save = NULL,
106 .panel_configuration_changed = pager_panel_configuration_changed
107 };