Automatic translation update from Pootle
[lxde/lxpanel.git] / plugins / separator.c
CommitLineData
b021864b
AG
1/*
2 * Copyright (C) 2006-2008 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
3 * 2006-2008 Jim Huang <jserv.tw@gmail.com>
4 * 2009 Marty Jack <martyj19@comcast.net>
5 * 2010 Julien Lavergne <julien.lavergne@gmail.com>
6 * 2013 Henry Gebhardt <hsggebhardt@gmail.com>
7 * 2014 Andriy Grytsenko <andrej@rep.kiev.ua>
8 *
9 * This file is a part of LXPanel project.
5d344669
AL
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 */
25
10b7f93c 26#include "plugin.h"
a52c2257 27
239cb032 28#include <glib/gi18n.h>
a52c2257 29
2918994e 30/* Plugin constructor. */
a7bd16a4 31static GtkWidget *separator_constructor(LXPanel *panel, config_setting_t *settings)
a52c2257 32{
10b7f93c 33 GtkWidget *instance, *sep;
9dd114c4 34
2918994e 35 /* Allocate top level widget and set into Plugin widget pointer. */
10b7f93c 36 instance = gtk_event_box_new();
10b7f93c 37 gtk_widget_set_has_window(instance, FALSE);
4542c20d 38
2918994e 39 /* Allocate separator as a child of top level. */
10b7f93c
AG
40 sep = panel_separator_new(panel);
41 gtk_container_add(GTK_CONTAINER(instance), sep);
761af06c 42 gtk_widget_show(sep);
4542c20d 43
2918994e 44 /* Show the widget and return. */
10b7f93c 45 return instance;
a52c2257
HJYP
46}
47
2918994e 48/* Callback when panel configuration changes. */
a7bd16a4 49static void separator_reconfigure(LXPanel *panel, GtkWidget *instance)
a97d06a6 50{
2918994e 51 /* Determine if the orientation changed in a way that requires action. */
10b7f93c 52 GtkWidget * sep = gtk_bin_get_child(GTK_BIN(instance));
2918994e 53 if (GTK_IS_VSEPARATOR(sep))
54 {
cfde283a 55 if (panel_get_orientation(panel) == GTK_ORIENTATION_HORIZONTAL)
a97d06a6
HJYP
56 return;
57 }
2918994e 58 else
59 {
cfde283a 60 if (panel_get_orientation(panel) == GTK_ORIENTATION_VERTICAL)
a97d06a6
HJYP
61 return;
62 }
2918994e 63
64 /* If the orientation changed, recreate the separator. */
65 gtk_widget_destroy(sep);
10b7f93c 66 sep = panel_separator_new(panel);
a97d06a6 67 gtk_widget_show(sep);
10b7f93c 68 gtk_container_add(GTK_CONTAINER(instance), sep);
a97d06a6 69}
a52c2257 70
2918994e 71/* Plugin descriptor. */
10b7f93c 72LXPanelPluginInit lxpanel_static_plugin_separator = {
3c3e9c9e 73 .name = N_("Separator"),
3c3e9c9e
HG
74 .description = N_("Add a separator to the panel"),
75
10b7f93c
AG
76 .new_instance = separator_constructor,
77 .reconfigure = separator_reconfigure
a52c2257 78};