]> Dogcows Code - chaz/openbox/blob - tools/obconf/main.c
restarting work on obconf
[chaz/openbox] / tools / obconf / main.c
1 #include "obconf.h"
2 #include "plugins.h"
3 #include "parser/parse.h"
4 #include "gettext.h"
5
6 #include <gtk/gtk.h>
7 #include <gdk-pixbuf/gdk-pixbuf.h>
8
9 #define OB_ICON "openbox-icon"
10
11 static GtkWidget *mainwin;
12 static GdkPixbuf *ob_icon;
13
14 static void obconf_error(GError *e)
15 {
16 GtkWidget *d;
17
18 d = gtk_message_dialog_new(mainwin ? GTK_WINDOW(mainwin) : NULL,
19 GTK_DIALOG_DESTROY_WITH_PARENT,
20 GTK_MESSAGE_ERROR,
21 GTK_BUTTONS_CLOSE,
22 "%s", e->message);
23 gtk_dialog_run(GTK_DIALOG(d));
24 gtk_widget_destroy(d);
25 }
26
27 static void load_stock ()
28 {
29 GtkIconFactory *factory;
30 GError *e = NULL;
31
32 gtk_icon_factory_add_default (factory = gtk_icon_factory_new ());
33
34 ob_icon = gdk_pixbuf_new_from_file (PIXMAPDIR G_DIR_SEPARATOR_S
35 "openbox.png", &e);
36 if (!ob_icon) {
37 gchar *msg = g_strdup_printf
38 (_("Failed to load the Openbox icon, Openbox is probably not "
39 "installed correctly. The error given was '%s'."),
40 e->message);
41 g_free (e->message);
42 e->message = msg;
43 obconf_error (e);
44 } else {
45 GtkIconSet *set;
46
47 set = gtk_icon_set_new_from_pixbuf (ob_icon);
48 gtk_icon_factory_add (factory, OB_ICON, set);
49 gtk_icon_set_unref (set);
50 }
51 }
52
53 int main(int argc, char **argv)
54 {
55 gtk_set_locale();
56 gtk_init(&argc, &argv);
57
58 load_stock();
59
60 mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
61 gtk_window_set_title(GTK_WINDOW(mainwin), "Obconf");
62 gtk_window_set_wmclass(GTK_WINDOW(mainwin), "obconf", "Obconf");
63 gtk_window_set_role(GTK_WINDOW(mainwin), "main window");
64 if (ob_icon) gtk_window_set_icon(GTK_WINDOW(mainwin), ob_icon);
65
66 gtk_widget_show_all(mainwin);
67
68 gtk_main();
69 return 0;
70 }
71
72 gboolean on_mainwindow_delete_event(GtkWidget *w, GdkEvent *e, gpointer d)
73 {
74 gtk_main_quit();
75 return FALSE;
76 }
77
78 void on_quit_activate(GtkMenuItem *item, gpointer d)
79 {
80 gtk_main_quit();
81 }
82
83 void on_applybutton_clicked(GtkButton *but, gpointer d)
84 {
85 g_message("apply\n");
86 }
87
88 void on_revertbutton_clicked(GtkButton *but, gpointer d)
89 {
90 g_message("revert\n");
91 }
92
93 void on_helpbutton_clicked(GtkButton *but, gpointer d)
94 {
95 g_message("help\n");
96 }
97
98 void on_sectiontree_row_activated(GtkTreeView *tree, GtkTreePath *path,
99 GtkTreeViewColumn *col, gpointer p)
100 {
101 g_message("activated\n");
102 }
This page took 0.040645 seconds and 4 git commands to generate.