From d1e355de2c6aae38cea3cdc0e0b902ea2b194e86 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 24 May 2003 21:47:06 +0000 Subject: this is a big one! im putting stats in here just cuz! 59 files changed, 1691 insertions(+), 607 deletions(-) Adding the beginings of ObConf. Adding a resistance-config plugin for ObConf. Creating an obparser library that obrender can use, the kernel can use, plugins can use, and ObConf and its plugins can use. (its just code for using libXml2) --- tools/.cvsignore | 2 + tools/Makefile.am | 5 + tools/obconf/.cvsignore | 5 + tools/obconf/Makefile.am | 26 +++ tools/obconf/about.c | 18 ++ tools/obconf/main.c | 91 ++++++++++ tools/obconf/obconf.glade | 427 +++++++++++++++++++++++++++++++++++++++++++++ tools/obconf/obconf.gladep | 8 + tools/obconf/obconf.h | 12 ++ tools/obconf/plugins.c | 157 +++++++++++++++++ tools/obconf/plugins.h | 16 ++ 11 files changed, 767 insertions(+) create mode 100644 tools/.cvsignore create mode 100644 tools/Makefile.am create mode 100644 tools/obconf/.cvsignore create mode 100644 tools/obconf/Makefile.am create mode 100644 tools/obconf/about.c create mode 100644 tools/obconf/main.c create mode 100644 tools/obconf/obconf.glade create mode 100644 tools/obconf/obconf.gladep create mode 100644 tools/obconf/obconf.h create mode 100644 tools/obconf/plugins.c create mode 100644 tools/obconf/plugins.h (limited to 'tools') diff --git a/tools/.cvsignore b/tools/.cvsignore new file mode 100644 index 00000000..282522db --- /dev/null +++ b/tools/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/tools/Makefile.am b/tools/Makefile.am new file mode 100644 index 00000000..86eaea70 --- /dev/null +++ b/tools/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS = + +if OBCONF +SUBDIRS += obconf +endif diff --git a/tools/obconf/.cvsignore b/tools/obconf/.cvsignore new file mode 100644 index 00000000..b35c97a5 --- /dev/null +++ b/tools/obconf/.cvsignore @@ -0,0 +1,5 @@ +.deps +.libs +Makefile +Makefile.in +obconf diff --git a/tools/obconf/Makefile.am b/tools/obconf/Makefile.am new file mode 100644 index 00000000..a83049f3 --- /dev/null +++ b/tools/obconf/Makefile.am @@ -0,0 +1,26 @@ +localedir=$(datadir)/locale +plugindir=$(libdir)/openbox/plugins +rcdir=$(datadir)/openbox + +CPPFLAGS=$(GTK_CFLAGS) $(GLADE_CFLAGS) $(GMODULE_CFLAGS) $(XML_CFLAGS) \ + @CPPFLAGS@ \ + -DLOCALEDIR=\"$(localedir)\" \ + -DRCDIR=\"$(rcdir)\" \ + -DPLUGINDIR=\"$(plugindir)\" \ + -DG_LOG_DOMAIN=\"ObConf\" + +INCLUDES=-I../.. +LIBS=$(GTK_LIBS) $(GLADE_LIBS) $(GMODULE_LIBS) $(XML_LIBS) @LIBS@ @LIBINTL@ + +bin_PROGRAMS=obconf + +obconf_LDADD=-lobparser -L../../parser +obconf_LDFLAGS=-export-dynamic +obconf_SOURCES=main.c about.c plugins.c + +noinst_HEADERS=obconf.h plugins.h + +MAINTAINERCLEANFILES=Makefile.in + +distclean-local: + $(RM) *\~ *.orig *.rej .\#* diff --git a/tools/obconf/about.c b/tools/obconf/about.c new file mode 100644 index 00000000..34de63f9 --- /dev/null +++ b/tools/obconf/about.c @@ -0,0 +1,18 @@ +#include "obconf.h" + +void on_about_activate(GtkMenuItem *item, gpointer d) +{ + gtk_widget_show(GTK_WIDGET(obconf_about)); +} + +gboolean on_aboutdialog_delete_event(GtkWidget *w, GdkEvent *e, gpointer d) +{ + gtk_widget_hide(GTK_WIDGET(obconf_about)); + return TRUE; +} + +void on_about_closebutton_clicked(GtkButton *but, gpointer d) +{ + gtk_widget_hide(GTK_WIDGET(obconf_about)); +} + diff --git a/tools/obconf/main.c b/tools/obconf/main.c new file mode 100644 index 00000000..f0eb7306 --- /dev/null +++ b/tools/obconf/main.c @@ -0,0 +1,91 @@ +#include "obconf.h" +#include "plugins.h" +#include "parser/parse.h" + +#include +#include + +/*#include +Display *ob_display; +int ob_screen; +Window ob_root;*/ + +GtkWindow *obconf_win; +GtkWindow *obconf_about = NULL; + +GtkTreeView *obconf_sections; +GtkListStore *obconf_sections_store; +static GtkCellRenderer *obconf_sections_renderer; +static GtkTreeViewColumn *obconf_sections_column; + +GtkNotebook *obconf_options; + +static xmlDocPtr doc; +static xmlNodePtr root; + +int main(int argc, char **argv) +{ + GladeXML *xml; + + gtk_init(&argc, &argv); + + xml = glade_xml_new("obconf.glade", NULL, NULL); + glade_xml_signal_autoconnect(xml); + + obconf_win = GTK_WINDOW(glade_xml_get_widget(xml, "mainwindow")); + gtk_window_set_role(obconf_win, "main"); + obconf_about = GTK_WINDOW(glade_xml_get_widget(xml, "aboutdialog")); + gtk_window_set_role(obconf_about, "about"); + gtk_window_set_transient_for(obconf_about, obconf_win); + obconf_sections = GTK_TREE_VIEW(glade_xml_get_widget(xml, "sectiontree")); + obconf_options = GTK_NOTEBOOK(glade_xml_get_widget(xml,"optionsnotebook")); + + obconf_sections_store = gtk_list_store_new(1, G_TYPE_STRING); + gtk_tree_view_set_model(obconf_sections, + GTK_TREE_MODEL(obconf_sections_store)); + obconf_sections_renderer = gtk_cell_renderer_text_new(); + obconf_sections_column = gtk_tree_view_column_new_with_attributes + ("Section", obconf_sections_renderer, "text", 0, NULL); + gtk_tree_view_append_column (obconf_sections, obconf_sections_column); + + parse_load_rc(&doc, &root); + + plugins_load(); + + gtk_widget_show(GTK_WIDGET(obconf_win)); + + gtk_main(); + return 0; +} + +gboolean on_mainwindow_delete_event(GtkWidget *w, GdkEvent *e, gpointer d) +{ + gtk_main_quit(); + return FALSE; +} + +void on_quit_activate(GtkMenuItem *item, gpointer d) +{ + gtk_main_quit(); +} + +void on_applybutton_clicked(GtkButton *but, gpointer d) +{ + g_message("apply"); +} + +void on_revertbutton_clicked(GtkButton *but, gpointer d) +{ + g_message("revert"); +} + +void on_helpbutton_clicked(GtkButton *but, gpointer d) +{ + g_message("help"); +} + +void on_sectiontree_row_activated(GtkTreeView *tree, GtkTreePath *path, + GtkTreeViewColumn *col, gpointer p) +{ + g_message("activated"); +} diff --git a/tools/obconf/obconf.glade b/tools/obconf/obconf.glade new file mode 100644 index 00000000..205706bb --- /dev/null +++ b/tools/obconf/obconf.glade @@ -0,0 +1,427 @@ + + + + + + + ObConf + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + True + + + + + True + False + 0 + + + + True + + + + True + _File + True + + + + + + + True + gtk-quit + True + + + + + + + + + + + True + _Help + True + + + + + + + True + _About + True + + + + + + + + + + 0 + False + False + + + + + + 6 + True + True + 121 + + + + True + False + 0 + + + + True + Sections + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + False + True + + + + + + 0 + True + True + + + + + True + False + + + + + + True + False + 0 + + + + True + Options + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + False + False + GTK_POS_TOP + False + False + + + + + + + + + + + 0 + True + True + + + + + True + True + + + + + 0 + True + True + + + + + + True + + + 0 + False + True + + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_START + 0 + + + + True + True + True + gtk-help + True + GTK_RELIEF_NORMAL + + + + + + 6 + True + True + + + + + + True + GTK_BUTTONBOX_END + 6 + + + + True + True + True + GTK_RELIEF_NORMAL + + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-cancel + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Revert + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + True + gtk-apply + True + GTK_RELIEF_NORMAL + + + + + + 6 + True + True + GTK_PACK_END + + + + + 6 + False + True + + + + + + + + About ObConf + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + -7 + + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + ObConf + +ObConf is a configuration tool for the +Openbox Window Manager. + + + + +ObConf is (c) 2003 Ben Jansens + False + True + GTK_JUSTIFY_CENTER + True + False + 0.5 + 0.5 + 0 + 0 + + + 0 + True + True + + + + + + + diff --git a/tools/obconf/obconf.gladep b/tools/obconf/obconf.gladep new file mode 100644 index 00000000..5ef3ad07 --- /dev/null +++ b/tools/obconf/obconf.gladep @@ -0,0 +1,8 @@ + + + + + ObConf + obconf + FALSE + diff --git a/tools/obconf/obconf.h b/tools/obconf/obconf.h new file mode 100644 index 00000000..5d7a2e67 --- /dev/null +++ b/tools/obconf/obconf.h @@ -0,0 +1,12 @@ +#ifndef __obconf_h +#define __obconf_h + +#include + +extern GtkWindow *obconf_win; +extern GtkWindow *obconf_about; +extern GtkTreeView *obconf_sections; +extern GtkListStore *obconf_sections_store; +extern GtkNotebook *obconf_options; + +#endif diff --git a/tools/obconf/plugins.c b/tools/obconf/plugins.c new file mode 100644 index 00000000..f838b962 --- /dev/null +++ b/tools/obconf/plugins.c @@ -0,0 +1,157 @@ +#include "obconf.h" +#include "plugins/obconf_interface.h" + +#include +#include +#include +#include + +typedef struct ConfigPlugin { + GModule *module; + char *fname; + char *name; + char *plugin_name; + + PluginStartupFunc start; + PluginShutdownFunc stop; + PluginInterfaceVersionFunc interface; + PluginNameFunc getname; + PluginPluginNameFunc getpname; + PluginIconFunc icon; + PluginToplevelWidgetFunc toplevel; + PluginEditedFunc edited; + PluginLoadFunc load; + PluginSaveFunc save; +} ConfigPlugin; + +GSList *plugins_list = NULL; + +static gpointer load_sym(GModule *module, char *name, char *symbol, + gboolean allow_fail) +{ + gpointer var; + if (!g_module_symbol(module, symbol, &var)) { + if (!allow_fail) + g_warning("Failed to load symbol '%s' from plugin '%s'", + symbol, name); + var = NULL; + } + return var; +} + +static void add_plugin(ConfigPlugin *p) +{ + GtkTreeIter it; + + gtk_list_store_append(obconf_sections_store, &it); + gtk_list_store_set(obconf_sections_store, &it, 0, p->name, -1); + gtk_notebook_append_page(obconf_options, p->toplevel(), NULL); +} + +void load_dir(char *path) +{ + char *fpath; + DIR *dir; + struct dirent *dirp; + ConfigPlugin *p; + GModule *mod; + GSList *it; + char *suffix; + + suffix = g_strconcat("-config.", G_MODULE_SUFFIX, NULL); + + if (!(dir = opendir(path))) + return; + while ((dirp = readdir(dir))) { + if (g_strrstr(dirp->d_name, suffix)) { + /* look for duplicates */ + for (it = plugins_list; it; it = it->next) + if (!strcmp(((ConfigPlugin*)it->data)->fname, dirp->d_name)) + break; + if (!it) { + fpath = g_build_filename(path, dirp->d_name, NULL); + + if ((mod = g_module_open(fpath, 0))) { + p = g_new(ConfigPlugin, 1); + p->module = mod; + p->fname = g_strdup(dirp->d_name); + + p->interface = (PluginInterfaceVersionFunc) + load_sym(p->module, p->fname, + "plugin_interface_version", + FALSE); + p->start = (PluginStartupFunc) + load_sym(p->module, p->fname, "plugin_startup", FALSE); + p->stop = (PluginShutdownFunc) + load_sym(p->module, p->fname, "plugin_shutdown",FALSE); + p->getname = (PluginNameFunc) + load_sym(p->module, p->fname, "plugin_name", FALSE); + p->getpname = (PluginNameFunc) + load_sym(p->module, p->fname, "plugin_plugin_name", + FALSE); + p->icon = (PluginIconFunc) + load_sym(p->module, p->fname, "plugin_icon", FALSE); + p->toplevel = (PluginToplevelWidgetFunc) + load_sym(p->module, p->fname, "plugin_toplevel_widget", + FALSE); + p->edited = (PluginEditedFunc) + load_sym(p->module, p->fname, "plugin_edited", FALSE); + p->load = (PluginLoadFunc) + load_sym(p->module, p->fname, "plugin_load", FALSE); + p->save = (PluginSaveFunc) + load_sym(p->module, p->fname, "plugin_save", FALSE); + + if (!(p->start && + p->stop && + p->interface && + p->name && + p->icon && + p->toplevel && + p->edited && + p->load && + p->save)) { + g_module_close(p->module); + g_free(p->fname); + g_free(p); + } else { + p->start(); + p->name = p->getname(); + p->plugin_name = p->getpname(); + plugins_list = g_slist_append(plugins_list, p); + + add_plugin(p); /* add to the gui */ + } + } + g_free(fpath); + } + } + } + + g_free(suffix); +} + +void plugins_load() +{ + char *path; + + path = g_build_filename(g_get_home_dir(), ".openbox", "plugins", NULL); + load_dir(path); + g_free(path); + + load_dir(PLUGINDIR); +} + +gboolean plugins_edited(ConfigPlugin *p) +{ + return p->edited(); +} + +void plugins_load_settings(ConfigPlugin *p, xmlDocPtr doc, xmlNodePtr root) +{ + p->load(doc, root); +} + +void plugins_save_settings(ConfigPlugin *p, xmlDocPtr doc, xmlNodePtr root) +{ + p->save(doc, root); +} diff --git a/tools/obconf/plugins.h b/tools/obconf/plugins.h new file mode 100644 index 00000000..485a8c2f --- /dev/null +++ b/tools/obconf/plugins.h @@ -0,0 +1,16 @@ +#ifndef __plugins_h +#define __plugins_h + +#include + +typedef struct ConfigPlugin ConfigPlugin; + +extern GSList *plugins_list; + +void plugins_load(); + +gboolean plugins_edited(ConfigPlugin *p); +void plugins_load_settings(ConfigPlugin *p, xmlDocPtr doc, xmlNodePtr root); +void plugins_save_settings(ConfigPlugin *p, xmlDocPtr doc, xmlNodePtr root); + +#endif -- cgit v1.2.3