diff --git a/data/config/default.in b/data/config/default.in index 4adbb27..ea8d922 100644 --- a/data/config/default.in +++ b/data/config/default.in @@ -82,6 +82,7 @@ # First parameter is 'type'. It's mandatory and must come first # Legal values are plugin names. Names of builtin plugins are: # separator - visual separator +# vbox - put sub-elements (other plugins) vertically # wincmd - 'show desktop' button # taskbar - lists all opened windows (tasks) # launchbar - bar with launch button diff --git a/plugins/Makefile b/plugins/Makefile index 2990136..90ee07d 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -23,6 +23,7 @@ SUBDIRS := battery \ systray \ taskbar \ tclock \ + vbox \ volume \ wincmd \ user diff --git a/plugins/vbox/Makefile b/plugins/vbox/Makefile new file mode 100644 index 0000000..6f4214e --- /dev/null +++ b/plugins/vbox/Makefile @@ -0,0 +1,10 @@ +## miniconf makefiles ## 1.1 ## + +TOPDIR := ../.. + +vbox_src = vbox.c +vbox_cflags = -DPLUGIN $(GTK2_CFLAGS) +vbox_libs = $(GTK2_LIBS) +vbox_type = lib + +include $(TOPDIR)/.config/rules.mk diff --git a/plugins/vbox/vbox.c b/plugins/vbox/vbox.c new file mode 100644 index 0000000..330e59c --- /dev/null +++ b/plugins/vbox/vbox.c @@ -0,0 +1,113 @@ +#include +#include + +#include + +#include "panel.h" +#include "misc.h" +#include "plugin.h" +#include "gtkbgbox.h" + +//#define DEBUGPRN +#include "dbg.h" + + +typedef struct { + plugin_instance plugin; + panel *panel2; + +} vbox_priv; + +static void +vbox_destructor(plugin_instance *p) +{ + vbox_priv *vb; + + ENTER; + + vb = (vbox_priv *) p; + free(vb->panel2); + + RET(); +} + + +// based on panel.c BEGIN // +static void +panel_parse_plugin(xconf *xc, panel *p) +{ + plugin_instance *plug = NULL; + gchar *type = NULL; + + ENTER; + xconf_get_str(xconf_find(xc, "type", 0), &type); + if (!type || !(plug = plugin_load(type))) { + ERR( "fbpanel: can't load %s plugin\n", type); + return; + } + plug->panel = p; + XCG(xc, "expand", &plug->expand, enum, bool_enum); + XCG(xc, "padding", &plug->padding, int); + XCG(xc, "border", &plug->border, int); + plug->xc = xconf_find(xc, "config", 0); + + if (!plugin_start(plug)) { + ERR( "fbpanel: can't start plugin %s\n", type); + exit(1); + } + p->plugins = g_list_append(p->plugins, plug); +} +// based on panel.c END // + + +static int +vbox_constructor(plugin_instance *p) +{ + vbox_priv *vb; + + ENTER; + vb = (vbox_priv *) p; + + vb->panel2 = malloc(sizeof(panel)); + memcpy(vb->panel2, p->panel, sizeof(panel)); + + + if (p->panel->orientation == GTK_ORIENTATION_HORIZONTAL) { + vb->panel2->box = gtk_vbox_new(TRUE, 1); + } else { + vb->panel2->box = gtk_hbox_new(TRUE, 1); + } + gtk_container_set_border_width (GTK_CONTAINER (vb->panel2->box), 0); + gtk_box_set_homogeneous(GTK_BOX(vb->panel2->box), FALSE); + gtk_widget_show(vb->panel2->box); + + //gtk_bgbox_set_background(p->pwid, BG_STYLE, 0, 0); + gtk_container_set_border_width (GTK_CONTAINER (p->pwid), 0); + gtk_container_add(GTK_CONTAINER(p->pwid), vb->panel2->box); + + + xconf *nxc; + GSList *pl; + for (pl = p->xc->sons; pl ; pl = g_slist_next(pl)) + { + nxc = pl->data; + if (!strcmp(nxc->name, "Plugin")) + panel_parse_plugin(nxc, vb->panel2); + } + + RET(1); +} + +static plugin_class class = { + .fname = NULL, + .count = 0, + .type = "vbox", + .name = "Vbox", + .version = "1.0", + .description = "Testowy plugin rrp", + .priv_size = sizeof(vbox_priv), + + .constructor = vbox_constructor, + .destructor = vbox_destructor, +}; +static plugin_class *class_ptr = (plugin_class *) &class;