Applied linker optimizations: prevent gaps between symbols due to
[lxde/lxpanel.git] / src / plugins / separator.c
CommitLineData
5d344669
AL
1/**
2 * Copyright (c) 2006 LxDE Developers, see the file AUTHORS for details.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
a52c2257
HJYP
19#include "panel.h"
20#include "misc.h"
21#include "plugin.h"
22
239cb032 23#include <glib/gi18n.h>
a52c2257
HJYP
24
25//#define DEBUG
26#include "dbg.h"
27
28
29static int
db449f6e 30separator_constructor(plugin *p, char **fp)
a52c2257
HJYP
31{
32 GtkWidget *sep, *eb;
33 line s;
ae44728f 34
a52c2257
HJYP
35 ENTER;
36 s.len = 256;
db449f6e
HJYP
37 if( fp )
38 {
39 while (lxpanel_get_line(fp, &s) != LINE_BLOCK_END) {
40 ERR( "separator: illegal in this context %s\n", s.str);
41 RET(0);
42 }
a52c2257
HJYP
43 }
44 eb = gtk_event_box_new();
45 gtk_container_set_border_width(GTK_CONTAINER(eb), 1);
46 gtk_widget_show(eb);
47 /*
48 g_signal_connect(G_OBJECT(eb), "expose_event",
49 G_CALLBACK(gtk_widget_queue_draw), NULL);
a97d06a6 50 */
a52c2257
HJYP
51 sep = p->panel->my_separator_new();
52 gtk_widget_show(sep);
53 gtk_container_add (GTK_CONTAINER (eb), sep);
54 gtk_container_add(GTK_CONTAINER(p->pwid), eb);
a97d06a6 55 p->priv = eb; /* just to alloc smth */
a52c2257
HJYP
56
57 RET(1);
58}
59
60static void
61separator_destructor(plugin *p)
62{
ae44728f 63 ENTER;
5a343ad5 64 GtkWidget* eb = GTK_WIDGET((GtkEventBox*)p->priv);
a97d06a6 65 gtk_widget_destroy( eb );
a52c2257
HJYP
66 RET();
67}
68
a97d06a6
HJYP
69static void orientation_changed( plugin* p )
70{
5a343ad5 71 GtkWidget* eb = GTK_WIDGET((GtkEventBox*)p->priv);
a97d06a6
HJYP
72 GtkWidget* sep = gtk_bin_get_child( GTK_BIN(eb) );
73 if( GTK_IS_VSEPARATOR(sep) ) {
74 if( p->panel->orientation == GTK_ORIENTATION_HORIZONTAL )
75 return;
76 }
77 else {
78 if( p->panel->orientation == GTK_ORIENTATION_VERTICAL )
79 return;
80 }
81 gtk_widget_destroy( sep );
82 sep = p->panel->my_separator_new();
83 gtk_widget_show(sep);
84 gtk_container_add (GTK_CONTAINER (eb), sep);
85}
a52c2257
HJYP
86
87plugin_class separator_plugin_class = {
88 fname: NULL,
89 count: 0,
90
91 type : "separator",
239cb032 92 name : N_("Separator"),
a52c2257 93 version: "1.0",
239cb032 94 description : N_("Add a separator to the panel"),
a52c2257
HJYP
95
96 constructor : separator_constructor,
97 destructor : separator_destructor,
9c97f69e 98 config : NULL,
a97d06a6
HJYP
99 save : NULL,
100 orientation : orientation_changed
a52c2257 101};