removed orphaned mkinstalldirs from distribution
[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 24
a52c2257
HJYP
25#include "dbg.h"
26
a52c2257 27static int
22242ed4 28separator_constructor(Plugin *p, char **fp)
a52c2257
HJYP
29{
30 GtkWidget *sep, *eb;
31 line s;
ae44728f 32
a52c2257 33 s.len = 256;
db449f6e
HJYP
34 if( fp )
35 {
36 while (lxpanel_get_line(fp, &s) != LINE_BLOCK_END) {
37 ERR( "separator: illegal in this context %s\n", s.str);
38 RET(0);
39 }
a52c2257 40 }
9dd114c4 41
e16480f8 42 p->pwid = eb = gtk_event_box_new();
4542c20d 43 GTK_WIDGET_SET_FLAGS( eb, GTK_NO_WINDOW );
366cf5fe 44 gtk_widget_add_events( p->pwid, GDK_BUTTON_PRESS_MASK );
9dd114c4 45 g_signal_connect( p->pwid, "button-press-event", G_CALLBACK(plugin_button_press_event), p );
4542c20d 46
a52c2257
HJYP
47 gtk_container_set_border_width(GTK_CONTAINER(eb), 1);
48 gtk_widget_show(eb);
4542c20d 49
a52c2257
HJYP
50 sep = p->panel->my_separator_new();
51 gtk_widget_show(sep);
52 gtk_container_add (GTK_CONTAINER (eb), sep);
a52c2257 53
9dd114c4 54 return 1;
a52c2257
HJYP
55}
56
57static void
22242ed4 58separator_destructor(Plugin *p)
a52c2257 59{
a52c2257
HJYP
60}
61
22242ed4 62static void orientation_changed( Plugin* p )
a97d06a6 63{
9dd114c4 64 GtkWidget* eb = GTK_WIDGET((GtkEventBox*)p->pwid);
a97d06a6
HJYP
65 GtkWidget* sep = gtk_bin_get_child( GTK_BIN(eb) );
66 if( GTK_IS_VSEPARATOR(sep) ) {
67 if( p->panel->orientation == GTK_ORIENTATION_HORIZONTAL )
68 return;
69 }
70 else {
71 if( p->panel->orientation == GTK_ORIENTATION_VERTICAL )
72 return;
73 }
74 gtk_widget_destroy( sep );
75 sep = p->panel->my_separator_new();
76 gtk_widget_show(sep);
77 gtk_container_add (GTK_CONTAINER (eb), sep);
78}
a52c2257 79
22242ed4 80PluginClass separator_plugin_class = {
a52c2257
HJYP
81
82 type : "separator",
239cb032 83 name : N_("Separator"),
a52c2257 84 version: "1.0",
239cb032 85 description : N_("Add a separator to the panel"),
a52c2257
HJYP
86
87 constructor : separator_constructor,
88 destructor : separator_destructor,
9c97f69e 89 config : NULL,
a97d06a6
HJYP
90 save : NULL,
91 orientation : orientation_changed
a52c2257 92};