File: gconf-editor-application.c

package info (click to toggle)
gconf-editor 3.0.1-6
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 6,216 kB
  • sloc: sh: 11,060; xml: 7,126; ansic: 5,307; makefile: 209
file content (75 lines) | stat: -rw-r--r-- 2,356 bytes parent folder | download | duplicates (4)
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
/*
 * Copyright (C) 2001, 2002 Anders Carlsson <andersca@gnu.org>
 *
 * 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <config.h>
#include "gconf-editor-application.h"

#include "gconf-util.h"
#include "gconf-editor-window.h"
#include "gconf-tree-model.h"
#include "gconf-list-model.h"
#include <gtk/gtk.h>


static GSList *editor_windows = NULL;

static void
gconf_editor_application_window_destroyed (GtkWidget *window)
{
	editor_windows = g_slist_remove (editor_windows, window);

	if (editor_windows == NULL)
		gtk_main_quit ();
}

GtkWidget *
gconf_editor_application_create_editor_window (int type)
{
	GtkWidget *window;
	GConfEditorWindow *gconfwindow;

	window = g_object_new (GCONF_TYPE_EDITOR_WINDOW, "editor-type", type, NULL);

	gconfwindow = GCONF_EDITOR_WINDOW (window);

	if (gconfwindow->client == NULL) {
		gconf_editor_application_window_destroyed (window);
		return NULL;
	}

	gconf_tree_model_set_client (GCONF_TREE_MODEL (gconfwindow->tree_model), gconfwindow->client);
	gconf_list_model_set_client (GCONF_LIST_MODEL (gconfwindow->list_model), gconfwindow->client);

	if (!gconf_util_can_edit_defaults ())
		gtk_action_set_sensitive (gtk_ui_manager_get_action (gconfwindow->ui_manager, "/GConfEditorMenu/FileMenu/NewDefaultsWindow"),
					  FALSE);

	if (!gconf_util_can_edit_mandatory ())
		gtk_action_set_sensitive (gtk_ui_manager_get_action (gconfwindow->ui_manager, "/GConfEditorMenu/FileMenu/NewMandatoryWindow"),
					  FALSE);
	
	g_signal_connect (window, "destroy",
			  G_CALLBACK (gconf_editor_application_window_destroyed), NULL);
	
	editor_windows = g_slist_prepend (editor_windows, window);

	gconf_editor_window_expand_first (gconfwindow);

	return window;
}