From: Dana Jansens Date: Sat, 26 Jul 2003 07:44:15 +0000 (+0000) Subject: restarting work on obconf X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=a354b0f5a93b711c0eb70d52ba8fe5b42ff4ae36;p=chaz%2Fopenbox restarting work on obconf --- diff --git a/Makefile.am b/Makefile.am index 3b6f19ff..f84dc6fe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,6 +5,7 @@ localedir = $(datadir)/locale rcdir = $(datadir)/openbox plugindir = $(libdir)/openbox/plugins desktopfilesdir = $(datadir)/gnome/wm-properties +pixmapdir = $(datadir)/pixmaps theme = operation @@ -34,8 +35,11 @@ plugin_LTLIBRARIES = \ plugins/menu/include_menu.la if OBCONF -plugin_LTLIBRARIES += \ - plugins/resistance/resistance-config.la +bin_PROGRAMS += \ + tools/obconf/obconf + +#plugin_LTLIBRARIES += \ +# plugins/resistance/resistance-config.la endif ## render ## @@ -328,6 +332,28 @@ plugins_menu_include_menu_la_SOURCES = \ plugins/menu/include_menu.c +## obconf ## + +tools_obconf_obconf_CPPFLAGS = \ + $(GTK_CFLAGS) \ + $(GDK_PIXBUF_CFLAGS) \ + $(XML_CFLAGS) \ + -DLOCALEDIR=\"$(localedir)\" \ + -DPLUGINDIR=\"$(plugindir)\" \ + -DRCDIR=\"$(rcdir)\" \ + -DPIXMAPDIR=\"$(pixmapdir)\" \ + -DG_LOG_DOMAIN=\"Obconf\" +tools_obconf_obconf_LDADD = \ + $(GTK_LIBS) \ + $(GDK_PIXBUF_LIBS) \ + $(LIBINTL) \ + render/libobrender.la \ + parser/libobparser.la +tools_obconf_obconf_SOURCES = \ + gettext.h \ + tools/obconf/main.c + + ## themes ## dist_theme_DATA = \ diff --git a/configure.ac b/configure.ac index fa8e1e76..f0f9b571 100644 --- a/configure.ac +++ b/configure.ac @@ -67,14 +67,14 @@ PKG_CHECK_MODULES(GTK, [gtk+-2.0], AC_SUBST(GTK_LIBS) use_gtk="yes" - PKG_CHECK_MODULES(GLADE, [libglade-2.0], + PKG_CHECK_MODULES(GDK_PIXBUF, [gdk-pixbuf-2.0], [ - AC_SUBST(GLADE_CFLAGS) - AC_SUBST(GLADE_LIBS) - use_glade="yes" + AC_SUBST(GDK_PIXBUF_CFLAGS) + AC_SUBST(GDK_PIXBUF_LIBS) + use_gdk_pixbuf="yes" ], [ - use_glade="no" + use_gdk_pixbuf="no" AC_MSG_WARN([disabling build of the configuration tool]) ] ) @@ -84,8 +84,8 @@ PKG_CHECK_MODULES(GTK, [gtk+-2.0], AC_MSG_WARN([disabling build of the configuration tool]) ] ) -#AM_CONDITIONAL(OBCONF, [test "$use_gtk" = "yes" && test "$use_glade" = "yes"]) -AM_CONDITIONAL(OBCONF, [false]) +AM_CONDITIONAL(OBCONF, + [test "$use_gtk" = "yes" && test "$use_gdk_pixbuf" = "yes"]) # Check for session management X11_SM diff --git a/tools/obconf/.cvsignore b/tools/obconf/.cvsignore index b35c97a5..278f5f1e 100644 --- a/tools/obconf/.cvsignore +++ b/tools/obconf/.cvsignore @@ -3,3 +3,4 @@ Makefile Makefile.in obconf +.dirstamp diff --git a/tools/obconf/Makefile b/tools/obconf/Makefile new file mode 100644 index 00000000..cfc46539 --- /dev/null +++ b/tools/obconf/Makefile @@ -0,0 +1,4 @@ +all clean install: + $(MAKE) -C ../.. -$(MAKEFLAGS) $@ + +.PHONY: all clean install diff --git a/tools/obconf/main.c b/tools/obconf/main.c index 645556c6..9abd8716 100644 --- a/tools/obconf/main.c +++ b/tools/obconf/main.c @@ -1,59 +1,69 @@ -#include "kernel/debug.h" #include "obconf.h" #include "plugins.h" #include "parser/parse.h" +#include "gettext.h" #include -#include +#include -/*#include -Display *ob_display; -int ob_screen; -Window ob_root;*/ +#define OB_ICON "openbox-icon" -GtkWindow *obconf_win; -GtkWindow *obconf_about = NULL; +static GtkWidget *mainwin; +static GdkPixbuf *ob_icon; -GtkTreeView *obconf_sections; -GtkListStore *obconf_sections_store; -static GtkCellRenderer *obconf_sections_renderer; -static GtkTreeViewColumn *obconf_sections_column; - -GtkNotebook *obconf_options; +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); + gtk_dialog_run(GTK_DIALOG(d)); + gtk_widget_destroy(d); +} -static xmlDocPtr doc; -static xmlNodePtr root; +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); + } +} int main(int argc, char **argv) { - GladeXML *xml; - + gtk_set_locale(); 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); + load_stock(); - plugins_load(); + 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"); + if (ob_icon) gtk_window_set_icon(GTK_WINDOW(mainwin), ob_icon); - gtk_widget_show(GTK_WIDGET(obconf_win)); + gtk_widget_show_all(mainwin); gtk_main(); return 0; @@ -72,21 +82,21 @@ void on_quit_activate(GtkMenuItem *item, gpointer d) void on_applybutton_clicked(GtkButton *but, gpointer d) { - ob_debug("apply\n"); + g_message("apply\n"); } void on_revertbutton_clicked(GtkButton *but, gpointer d) { - ob_debug("revert\n"); + g_message("revert\n"); } void on_helpbutton_clicked(GtkButton *but, gpointer d) { - ob_debug("help\n"); + g_message("help\n"); } void on_sectiontree_row_activated(GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *col, gpointer p) { - ob_debug("activated\n"); + g_message("activated\n"); }