Adding upstream version 0.3+svn20091101.
[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
13f1ec51 26gboolean under_lxsession = FALSE; /* wether lxsession-xsettings daemon is active */
08024023 27
13f1ec51
DB
28Atom lxsession_atom = 0;
29
30static void check_lxsession()
08024023 31{
13f1ec51
DB
32 lxsession_atom = XInternAtom( GDK_DISPLAY(), "_LXSESSION", True );
33 if( lxsession_atom != None )
08024023
DB
34 {
35 XGrabServer( GDK_DISPLAY() );
13f1ec51
DB
36 if( XGetSelectionOwner( GDK_DISPLAY(), lxsession_atom ) )
37 under_lxsession = TRUE;
08024023
DB
38 XUngrabServer( GDK_DISPLAY() );
39 }
40}
41
42int main (int argc, char *argv[])
43{
44#ifdef ENABLE_NLS
45 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
46 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
47 textdomain (GETTEXT_PACKAGE);
48#endif
49
50 if( argc >= 3 && strcmp( argv[1], "demo" ) == 0 )
51 {
52 char* files[] = { argv[3], NULL };
53 gtk_rc_set_default_files(files);
54
55 gtk_set_locale ();
56 gtk_init (&argc, &argv);
57
13f1ec51
DB
58 check_lxsession();
59 if( under_lxsession )
08024023
DB
60 return 1;
61
62 show_demo( (GdkNativeWindow)atoi( argv[2] ) );
63 gtk_main();
64 return 0;
65 }
66
67 gtk_set_locale ();
68 gtk_init (&argc, &argv);
69
13f1ec51
DB
70 /* Dirty hack: check if we are under lxsession */
71 check_lxsession();
08024023 72
13f1ec51 73 if( ! under_lxsession )
08024023
DB
74 mkstemp( tmp_rc_file );
75
76 /* Dirty hack: "gtk-toolbar-style" is installed in class_init of GtkToolbar */
77 gtk_widget_destroy( gtk_toolbar_new() );
78
79 main_dlg = create_dlg ();
80 main_dlg_init( main_dlg );
81 gtk_window_set_icon_name( (GtkWindow*)main_dlg, GTK_STOCK_PREFERENCES );
82
83 gtk_main ();
84
13f1ec51 85 if( ! under_lxsession )
08024023
DB
86 unlink( tmp_rc_file );
87
88 return 0;
89}
90