Migrate built-in plugin "launchbar" to libfm API and new plugins API.
[lxde/lxpanel.git] / src / plugins / separator.c
CommitLineData
5d344669 1/**
8c9c4b55 2 * Copyright (c) 2006-2014 LxDE Developers, see the file AUTHORS for details.
5d344669
AL
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
10b7f93c 19#include "plugin.h"
a52c2257 20
239cb032 21#include <glib/gi18n.h>
a52c2257 22
2918994e 23/* Plugin constructor. */
10b7f93c 24static GtkWidget *separator_constructor(Panel *panel, config_setting_t *settings)
a52c2257 25{
10b7f93c 26 GtkWidget *instance, *sep;
9dd114c4 27
2918994e 28 /* Allocate top level widget and set into Plugin widget pointer. */
10b7f93c 29 instance = gtk_event_box_new();
d5c46ffc 30#if GTK_CHECK_VERSION(2,18,0)
10b7f93c 31 gtk_widget_set_has_window(instance, FALSE);
d5c46ffc 32#else
10b7f93c 33 GTK_WIDGET_SET_FLAGS(instance, GTK_NO_WINDOW);
d5c46ffc 34#endif
10b7f93c
AG
35 gtk_widget_add_events(instance, GDK_BUTTON_PRESS_MASK);
36 gtk_container_set_border_width(GTK_CONTAINER(instance), 1);
4542c20d 37
2918994e 38 /* Allocate separator as a child of top level. */
10b7f93c
AG
39 sep = panel_separator_new(panel);
40 gtk_container_add(GTK_CONTAINER(instance), sep);
761af06c 41 gtk_widget_show(sep);
4542c20d 42
2918994e 43 /* Show the widget and return. */
10b7f93c 44 return instance;
a52c2257
HJYP
45}
46
2918994e 47/* Callback when panel configuration changes. */
10b7f93c 48static void separator_reconfigure(Panel *panel, GtkWidget *instance)
a97d06a6 49{
2918994e 50 /* Determine if the orientation changed in a way that requires action. */
10b7f93c 51 GtkWidget * sep = gtk_bin_get_child(GTK_BIN(instance));
2918994e 52 if (GTK_IS_VSEPARATOR(sep))
53 {
10b7f93c 54 if (panel_is_horizontal(panel))
a97d06a6
HJYP
55 return;
56 }
2918994e 57 else
58 {
10b7f93c 59 if (!panel_is_horizontal(panel))
a97d06a6
HJYP
60 return;
61 }
2918994e 62
63 /* If the orientation changed, recreate the separator. */
64 gtk_widget_destroy(sep);
10b7f93c 65 sep = panel_separator_new(panel);
a97d06a6 66 gtk_widget_show(sep);
10b7f93c 67 gtk_container_add(GTK_CONTAINER(instance), sep);
a97d06a6 68}
a52c2257 69
2918994e 70/* Plugin descriptor. */
10b7f93c 71LXPanelPluginInit lxpanel_static_plugin_separator = {
3c3e9c9e 72 .name = N_("Separator"),
3c3e9c9e
HG
73 .description = N_("Add a separator to the panel"),
74
10b7f93c
AG
75 .new_instance = separator_constructor,
76 .reconfigure = separator_reconfigure
a52c2257 77};