Adding upstream version 0.2.1.
[debian/lxappearance.git] / src / main.c
CommitLineData
08024023
DB
1/*
2 * Initial main.c file generated by Glade. Edit as required.
3 * Glade will not overwrite this file.
4 */
5
6#ifdef HAVE_CONFIG_H
7# include <config.h>
8#endif
9
10#include <gtk/gtk.h>
11#include <string.h>
12#include <unistd.h>
13
14#include <X11/X.h>
15#include <X11/Xatom.h>
16#include <X11/Xlib.h>
17#include <gdk/gdkx.h>
18
19#include "main-dlg-ui.h"
20#include "demo.h"
21#include "glade-support.h"
22
23char tmp_rc_file[] = "/tmp/gtkrc-2.0-XXXXXX";
24GtkWidget* main_dlg = NULL;
25
26gboolean under_lxde = FALSE; /* wether lxde-xsettings daemon is active */
27
28static void check_lxde()
29{
30 Atom atom = XInternAtom( GDK_DISPLAY(), "LXDE_SETTINGS", True );
31 if( atom != None )
32 {
33 XGrabServer( GDK_DISPLAY() );
34 if( XGetSelectionOwner( GDK_DISPLAY(), atom ) )
35 under_lxde = TRUE;
36 XUngrabServer( GDK_DISPLAY() );
37 }
38}
39
40int main (int argc, char *argv[])
41{
42#ifdef ENABLE_NLS
43 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
44 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
45 textdomain (GETTEXT_PACKAGE);
46#endif
47
48 if( argc >= 3 && strcmp( argv[1], "demo" ) == 0 )
49 {
50 char* files[] = { argv[3], NULL };
51 gtk_rc_set_default_files(files);
52
53 gtk_set_locale ();
54 gtk_init (&argc, &argv);
55
56 check_lxde();
57 if( under_lxde )
58 return 1;
59
60 show_demo( (GdkNativeWindow)atoi( argv[2] ) );
61 gtk_main();
62 return 0;
63 }
64
65 gtk_set_locale ();
66 gtk_init (&argc, &argv);
67
68 /* Dirty hack: check if lxde-xsettings daemon is active */
69 check_lxde();
70
71 if( ! under_lxde )
72 mkstemp( tmp_rc_file );
73
74 /* Dirty hack: "gtk-toolbar-style" is installed in class_init of GtkToolbar */
75 gtk_widget_destroy( gtk_toolbar_new() );
76
77 main_dlg = create_dlg ();
78 main_dlg_init( main_dlg );
79 gtk_window_set_icon_name( (GtkWindow*)main_dlg, GTK_STOCK_PREFERENCES );
80
81 gtk_main ();
82
83 if( ! under_lxde )
84 unlink( tmp_rc_file );
85
86 return 0;
87}
88