fix .desktop file
[gconf-editor] / src / gconf-editor-application.c
1 /*
2  * Copyright (C) 2001, 2002 Anders Carlsson <andersca@gnu.org>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18
19 #include <config.h>
20 #include "gconf-editor-application.h"
21
22 #include "gconf-util.h"
23 #include "gconf-editor-window.h"
24 #include "gconf-tree-model.h"
25 #include "gconf-list-model.h"
26 #include <gtk/gtk.h>
27
28
29 static GSList *editor_windows = NULL;
30
31 static void
32 gconf_editor_application_window_destroyed (GtkObject *window)
33 {
34         editor_windows = g_slist_remove (editor_windows, window);
35
36         if (editor_windows == NULL)
37                 gtk_main_quit ();
38 }
39
40 GtkWidget *
41 gconf_editor_application_create_editor_window (int type)
42 {
43         GtkWidget *window;
44         GConfEditorWindow *gconfwindow;
45
46         window = g_object_new (GCONF_TYPE_EDITOR_WINDOW, "type", type, NULL);
47
48         gconfwindow = GCONF_EDITOR_WINDOW (window);
49
50         if (gconfwindow->client == NULL) {
51                 gconf_editor_application_window_destroyed (GTK_OBJECT (window));
52                 return NULL;
53         }
54
55         gconf_tree_model_set_client (GCONF_TREE_MODEL (gconfwindow->tree_model), gconfwindow->client);
56         gconf_list_model_set_client (GCONF_LIST_MODEL (gconfwindow->list_model), gconfwindow->client);
57
58         if (!gconf_util_can_edit_defaults ())
59                 gtk_action_set_sensitive (gtk_ui_manager_get_action (gconfwindow->ui_manager, "/GConfEditorMenu/FileMenu/NewDefaultsWindow"),
60                                           FALSE);
61
62         if (!gconf_util_can_edit_mandatory ())
63                 gtk_action_set_sensitive (gtk_ui_manager_get_action (gconfwindow->ui_manager, "/GConfEditorMenu/FileMenu/NewMandatoryWindow"),
64                                           FALSE);
65         
66         g_signal_connect (window, "destroy",
67                           G_CALLBACK (gconf_editor_application_window_destroyed), NULL);
68         
69         editor_windows = g_slist_prepend (editor_windows, window);
70
71         gconf_editor_window_expand_first (gconfwindow);
72
73         return window;
74 }
75