Remove device icon which is not real device.
[lxde/lxpanel.git] / src / plugins / separator.c
CommitLineData
a52c2257
HJYP
1#include "panel.h"
2#include "misc.h"
3#include "plugin.h"
4
239cb032 5#include <glib/gi18n.h>
a52c2257
HJYP
6
7//#define DEBUG
8#include "dbg.h"
9
10
11static int
db449f6e 12separator_constructor(plugin *p, char **fp)
a52c2257
HJYP
13{
14 GtkWidget *sep, *eb;
15 line s;
ae44728f 16
a52c2257
HJYP
17 ENTER;
18 s.len = 256;
db449f6e
HJYP
19 if( fp )
20 {
21 while (lxpanel_get_line(fp, &s) != LINE_BLOCK_END) {
22 ERR( "separator: illegal in this context %s\n", s.str);
23 RET(0);
24 }
a52c2257
HJYP
25 }
26 eb = gtk_event_box_new();
27 gtk_container_set_border_width(GTK_CONTAINER(eb), 1);
28 gtk_widget_show(eb);
29 /*
30 g_signal_connect(G_OBJECT(eb), "expose_event",
31 G_CALLBACK(gtk_widget_queue_draw), NULL);
a97d06a6 32 */
a52c2257
HJYP
33 sep = p->panel->my_separator_new();
34 gtk_widget_show(sep);
35 gtk_container_add (GTK_CONTAINER (eb), sep);
36 gtk_container_add(GTK_CONTAINER(p->pwid), eb);
a97d06a6 37 p->priv = eb; /* just to alloc smth */
a52c2257
HJYP
38
39 RET(1);
40}
41
42static void
43separator_destructor(plugin *p)
44{
ae44728f 45 ENTER;
5a343ad5 46 GtkWidget* eb = GTK_WIDGET((GtkEventBox*)p->priv);
a97d06a6 47 gtk_widget_destroy( eb );
a52c2257
HJYP
48 RET();
49}
50
a97d06a6
HJYP
51static void orientation_changed( plugin* p )
52{
5a343ad5 53 GtkWidget* eb = GTK_WIDGET((GtkEventBox*)p->priv);
a97d06a6
HJYP
54 GtkWidget* sep = gtk_bin_get_child( GTK_BIN(eb) );
55 if( GTK_IS_VSEPARATOR(sep) ) {
56 if( p->panel->orientation == GTK_ORIENTATION_HORIZONTAL )
57 return;
58 }
59 else {
60 if( p->panel->orientation == GTK_ORIENTATION_VERTICAL )
61 return;
62 }
63 gtk_widget_destroy( sep );
64 sep = p->panel->my_separator_new();
65 gtk_widget_show(sep);
66 gtk_container_add (GTK_CONTAINER (eb), sep);
67}
a52c2257
HJYP
68
69plugin_class separator_plugin_class = {
70 fname: NULL,
71 count: 0,
72
73 type : "separator",
239cb032 74 name : N_("Separator"),
a52c2257 75 version: "1.0",
239cb032 76 description : N_("Add a separator to the panel"),
a52c2257
HJYP
77
78 constructor : separator_constructor,
79 destructor : separator_destructor,
9c97f69e 80 config : NULL,
a97d06a6
HJYP
81 save : NULL,
82 orientation : orientation_changed
a52c2257 83};