~ubuntu-branches/debian/sid/obconf/sid

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-

   main.c for ObConf, the configuration tool for Openbox
   Copyright (c) 2003        Ben Jansens
   Copyright (c) 2003        Tim Riley

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   See the COPYING file for a copy of the GNU General Public License.
*/

#include "main.h"
#include "handlers.h"

#include <gdk/gdkx.h>
#define SN_API_NOT_YET_FROZEN
#include <libsn/sn.h>
#undef SN_API_NOT_YET_FROZEN

static GtkWidget *mainwin;

GladeXML *glade;
xmlDocPtr doc;
xmlNodePtr root;

void obconf_error(gchar *msg)
{
    GtkWidget *d;

    d = gtk_message_dialog_new(mainwin ? GTK_WINDOW(mainwin) : NULL,
                               GTK_DIALOG_DESTROY_WITH_PARENT,
                               GTK_MESSAGE_ERROR,
                               GTK_BUTTONS_CLOSE,
                               "%s", msg);
    g_signal_connect_swapped(GTK_OBJECT(d), "response",
                             G_CALLBACK(gtk_widget_destroy),
                             GTK_OBJECT(d));
    gtk_widget_show(d);
}

int main(int argc, char **argv)
{
    SnDisplay *sn_d;
    SnLauncheeContext *sn_cx;
    gchar *p;

    parse_paths_startup();

    gtk_init(&argc, &argv);

    p = g_build_filename(GLADEDIR, "obconf.glade", NULL);
    glade = glade_xml_new(p, NULL, NULL);
    g_free(p);

    if (!glade) {
        obconf_error("Failed to load the obconf.glade interface file. You "
                     "have probably failed to install ObConf properly.");
        return 1;
    }

    xmlIndentTreeOutput = 1;
    if (!parse_load_rc(&doc, &root)) {
        obconf_error("Failed to load an rc.xml. You have probably failed to "
                     "install Openbox properly.");
        return 1;
    }

    glade_xml_signal_autoconnect(glade);

    {
        gchar *s = g_strdup_printf
            ("<span weight=\"bold\" size=\"xx-large\">ObConf %s</span>",
             PACKAGE_VERSION);
        gtk_label_set_markup(GTK_LABEL
                             (glade_xml_get_widget(glade, "title_label")), s);
        g_free(s);
    }

    setup_behavior_tab();
    setup_dock_tab();
    setup_focus_mouse(glade_xml_get_widget(glade, "focus_mouse"));
    setup_focus_raise(glade_xml_get_widget(glade, "focus_raise"));
    setup_focus_delay(glade_xml_get_widget(glade, "focus_delay"));
    setup_focus_new(glade_xml_get_widget(glade, "focus_new"));
    setup_place_mouse(glade_xml_get_widget(glade, "place_mouse"));
    setup_resist_window(glade_xml_get_widget(glade, "resist_window"));
    setup_resist_edge(glade_xml_get_widget(glade, "resist_edge"));
    setup_resize_contents(glade_xml_get_widget(glade, "resize_contents"));
    setup_dock_position(glade_xml_get_widget(glade, "dock_position"));
    setup_dock_float_x(glade_xml_get_widget(glade, "dock_float_x"));
    setup_dock_float_y(glade_xml_get_widget(glade, "dock_float_y"));
    setup_dock_stacking(glade_xml_get_widget(glade, "dock_stack_top"),
                        glade_xml_get_widget(glade, "dock_stack_normal"),
                        glade_xml_get_widget(glade, "dock_stack_bottom"));
    setup_dock_direction(glade_xml_get_widget(glade, "dock_direction"));
    setup_dock_hide(glade_xml_get_widget(glade, "dock_hide"));
    setup_dock_hide_delay(glade_xml_get_widget(glade, "dock_hide_delay"));
    setup_theme_names(glade_xml_get_widget(glade, "theme_names"));
    setup_theme_layout(glade_xml_get_widget(glade, "theme_layout"));
    setup_desktop_num(glade_xml_get_widget(glade, "desktop_num"));
    setup_desktop_names(glade_xml_get_widget(glade, "desktop_names"));

    mainwin = glade_xml_get_widget(glade, "main_window");

    sn_d = sn_display_new(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
                          NULL, NULL);

    sn_cx = sn_launchee_context_new_from_environment
        (sn_d, gdk_screen_get_number(gdk_display_get_default_screen
                                     (gdk_display_get_default())));

    if (sn_cx)
        sn_launchee_context_setup_window
            (sn_cx, GDK_WINDOW_XWINDOW(GDK_WINDOW(mainwin->window)));

    gtk_widget_show_all(mainwin);

    if (sn_cx)
        sn_launchee_context_complete(sn_cx);

    if (sn_cx)
        sn_launchee_context_unref(sn_cx);
    sn_display_unref(sn_d);

    gtk_main();

    parse_paths_shutdown();

    xmlFreeDoc(doc);
    return 0;
}