From 237cc7278bb57033dad93420d02552e6a910ae82 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 7 Sep 2003 23:43:45 +0000 Subject: [PATCH] obconf is moving into its own tree --- tools/obconf/.cvsignore | 6 - tools/obconf/Makefile | 4 - tools/obconf/about.c | 18 -- tools/obconf/main.c | 250 -------------------------- 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 -- 9 files changed, 898 deletions(-) delete mode 100644 tools/obconf/.cvsignore delete mode 100644 tools/obconf/Makefile delete mode 100644 tools/obconf/about.c delete mode 100644 tools/obconf/main.c delete mode 100644 tools/obconf/obconf.glade delete mode 100644 tools/obconf/obconf.gladep delete mode 100644 tools/obconf/obconf.h delete mode 100644 tools/obconf/plugins.c delete mode 100644 tools/obconf/plugins.h diff --git a/tools/obconf/.cvsignore b/tools/obconf/.cvsignore deleted file mode 100644 index 278f5f1..0000000 --- a/tools/obconf/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -obconf -.dirstamp diff --git a/tools/obconf/Makefile b/tools/obconf/Makefile deleted file mode 100644 index cfc4653..0000000 --- a/tools/obconf/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -all clean install: - $(MAKE) -C ../.. -$(MAKEFLAGS) $@ - -.PHONY: all clean install diff --git a/tools/obconf/about.c b/tools/obconf/about.c deleted file mode 100644 index 34de63f..0000000 --- a/tools/obconf/about.c +++ /dev/null @@ -1,18 +0,0 @@ -#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 deleted file mode 100644 index f4af5c5..0000000 --- a/tools/obconf/main.c +++ /dev/null @@ -1,250 +0,0 @@ -/*#include "obconf.h" - #include "plugins.h"*/ -#include "parser/parse.h" -#include "gettext.h" - -#include -#include - -#define OB_ICON "openbox-icon" - -static GtkWidget *mainwin; -static GtkWidget *mainlist; -static GtkListStore *mainstore; -static GtkWidget *mainworkarea; -static GdkPixbuf *ob_icon; - -enum { - NAME_COLUMN, - N_COLUMNS -}; - -gboolean on_mainwindow_delete_event(GtkWidget *w, GdkEvent *e, gpointer d); -void on_quit_activate(GtkMenuItem *item, gpointer d); -void on_applybutton_clicked(GtkButton *but, gpointer d); -void on_revertbutton_clicked(GtkButton *but, gpointer d); -void on_selection_changed(GtkTreeSelection *selection, gpointer data); - -static void obconf_error(GError *e) -{ - GtkWidget *d; - - d = gtk_message_dialog_new(mainwin ? GTK_WINDOW(mainwin) : NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "%s", e->message); - g_signal_connect_swapped(GTK_OBJECT(d), "response", - G_CALLBACK(gtk_widget_destroy), - GTK_OBJECT(d)); - gtk_widget_show(d); -} - -static void load_stock () -{ - GtkIconFactory *factory; - GError *e = NULL; - - gtk_icon_factory_add_default (factory = gtk_icon_factory_new ()); - - ob_icon = gdk_pixbuf_new_from_file (PIXMAPDIR G_DIR_SEPARATOR_S - "openbox.png", &e); - if (!ob_icon) { - gchar *msg = g_strdup_printf - (_("Failed to load the Openbox icon, Openbox is probably not " - "installed correctly. The error given was '%s'."), - e->message); - g_free (e->message); - e->message = msg; - obconf_error (e); - } else { - GtkIconSet *set; - - set = gtk_icon_set_new_from_pixbuf (ob_icon); - gtk_icon_factory_add (factory, OB_ICON, set); - gtk_icon_set_unref (set); - } -} - -GtkWidget* build_menu(GtkAccelGroup *accel) -{ - GtkWidget *menu; - GtkWidget *submenu; - GtkWidget *item; - - menu = gtk_menu_bar_new(); - - /* File menu */ - - submenu = gtk_menu_new(); - gtk_menu_set_accel_group(GTK_MENU(submenu), accel); - - item = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, accel); - g_signal_connect(item, "activate", G_CALLBACK(on_quit_activate), NULL); - gtk_menu_append(GTK_MENU(submenu), item); - - item = gtk_menu_item_new_with_mnemonic("_File"); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); - gtk_menu_bar_append(GTK_MENU_BAR(menu), item); - - /* About menu */ - - submenu = gtk_menu_new(); - gtk_menu_set_accel_group(GTK_MENU(submenu), accel); - - item = gtk_menu_item_new_with_mnemonic("_About"); - gtk_menu_append(GTK_MENU(submenu), item); - - item = gtk_menu_item_new_with_mnemonic("_Help"); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); - gtk_menu_bar_append(GTK_MENU_BAR(menu), item); - - gtk_widget_show_all(menu); - - return menu; -} - -GtkWidget* build_list(GtkListStore **model) -{ - GtkWidget *list; - GtkListStore *store; - GtkCellRenderer *ren; - GtkTreeViewColumn *col; - GtkTreeSelection *sel; - - store = gtk_list_store_new(N_COLUMNS, - G_TYPE_STRING); - - list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); - - sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(list)); - gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); - g_signal_connect(sel, "changed", G_CALLBACK(on_selection_changed), NULL); - - ren = gtk_cell_renderer_text_new(); - col = gtk_tree_view_column_new_with_attributes("Name", - ren, - "text", - NAME_COLUMN, - NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); - - *model = store; - return list; -} - -int main(int argc, char **argv) -{ - GtkWidget *menu; - GtkWidget *vbox; - GtkWidget *hpane; - GtkAccelGroup *accel; - GtkWidget *sep; - GtkWidget *bbox; - GtkWidget *but; - GtkWidget *bar; - - gtk_set_locale(); - gtk_init(&argc, &argv); - - mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(mainwin), "Obconf"); - gtk_window_set_wmclass(GTK_WINDOW(mainwin), "obconf", "Obconf"); - gtk_window_set_role(GTK_WINDOW(mainwin), "main window"); - - g_signal_connect(mainwin, "delete-event", - G_CALLBACK(on_mainwindow_delete_event), NULL); - - accel = gtk_accel_group_new(); - gtk_window_add_accel_group(GTK_WINDOW(mainwin), accel); - - vbox = gtk_vbox_new(FALSE, 5); - gtk_container_add(GTK_CONTAINER(mainwin), vbox); - - /* Menu */ - - menu = build_menu(accel); - gtk_box_pack_start(GTK_BOX(vbox), menu, FALSE, FALSE, 0); - - hpane = gtk_hpaned_new(); - gtk_box_pack_start(GTK_BOX(vbox), hpane, TRUE, TRUE, 0); - - /* List */ - - mainlist = build_list(&mainstore); - gtk_container_add(GTK_CONTAINER(hpane), mainlist); - - /* Main work area */ - - mainworkarea = gtk_layout_new(NULL, NULL); - gtk_container_add(GTK_CONTAINER(hpane), mainworkarea); - - /* Separator */ - - sep = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); - - /* Button box */ - - bbox = gtk_hbutton_box_new(); - gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 6); - gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - /* Revert Button */ - - but = gtk_button_new_with_mnemonic("_Revert"); - gtk_box_pack_start(GTK_BOX(bbox), but, FALSE, FALSE, 0); - - /* Apply Button */ - - but = gtk_button_new_with_mnemonic("_Apply"); - gtk_box_pack_start(GTK_BOX(bbox), but, FALSE, FALSE, 0); - - /* Status bar */ - - bar = gtk_statusbar_new(); - gtk_box_pack_start(GTK_BOX(vbox), bar, FALSE, FALSE, 0); - - gtk_widget_show_all(mainwin); - - load_stock(); - if (ob_icon) gtk_window_set_icon(GTK_WINDOW(mainwin), ob_icon); - - 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_selection_changed(GtkTreeSelection *sel, gpointer data) -{ - GtkTreeIter iter; - GtkTreeModel *model; - - if (gtk_tree_selection_get_selected(sel, &model, &iter)) { - g_message("activated"); - } else { - g_message("none activated"); - } -} diff --git a/tools/obconf/obconf.glade b/tools/obconf/obconf.glade deleted file mode 100644 index 205706b..0000000 --- a/tools/obconf/obconf.glade +++ /dev/null @@ -1,427 +0,0 @@ - - - - - - - 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 deleted file mode 100644 index 5ef3ad0..0000000 --- a/tools/obconf/obconf.gladep +++ /dev/null @@ -1,8 +0,0 @@ - - - - - ObConf - obconf - FALSE - diff --git a/tools/obconf/obconf.h b/tools/obconf/obconf.h deleted file mode 100644 index 5d7a2e6..0000000 --- a/tools/obconf/obconf.h +++ /dev/null @@ -1,12 +0,0 @@ -#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 deleted file mode 100644 index f838b96..0000000 --- a/tools/obconf/plugins.c +++ /dev/null @@ -1,157 +0,0 @@ -#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 deleted file mode 100644 index 485a8c2..0000000 --- a/tools/obconf/plugins.h +++ /dev/null @@ -1,16 +0,0 @@ -#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 -- 1.9.1