Port to GConf, away from libcapplet.
2001-12-08 Richard Hestilow <hestilow@ximian.com> * Port to GConf, away from libcapplet.
This commit is contained in:
parent
381e53db7a
commit
5146b73151
3 changed files with 85 additions and 50 deletions
|
@ -1,3 +1,7 @@
|
|||
2001-12-08 Richard Hestilow <hestilow@ximian.com>
|
||||
|
||||
* Port to GConf, away from libcapplet.
|
||||
|
||||
2001-09-29 Richard Hestilow <hestilow@ximian.com>
|
||||
|
||||
* wm-properties-capplet.c: Applied patch from drk@sgi.com
|
||||
|
|
|
@ -10,8 +10,11 @@
|
|||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <libgnome/libgnome.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#include "wm-properties.h"
|
||||
|
||||
#define CONFIG_PREFIX "/desktop/gnome/applications/window_manager"
|
||||
|
||||
/* Current list of window managers */
|
||||
GList *window_managers = NULL;
|
||||
|
||||
|
@ -187,6 +190,7 @@ wm_list_read_dir (gchar *directory, gboolean is_user)
|
|||
wm = g_new (WindowManager, 1);
|
||||
|
||||
wm->dentry = gnome_desktop_item_new_from_file (tmp_list->data, GNOME_DESKTOP_ITEM_TYPE_APPLICATION, NULL);
|
||||
gnome_desktop_item_set_entry_type (wm->dentry, GNOME_DESKTOP_ITEM_TYPE_APPLICATION);
|
||||
|
||||
if (!wm->dentry) {
|
||||
g_free (wm);
|
||||
|
@ -242,7 +246,8 @@ wm_list_init (void)
|
|||
{
|
||||
gchar *tempdir;
|
||||
gchar *name;
|
||||
|
||||
GConfClient *client;
|
||||
|
||||
tempdir = gnome_unconditional_datadir_file ("gnome/wm-properties/");
|
||||
wm_list_read_dir (tempdir, FALSE);
|
||||
g_free (tempdir);
|
||||
|
@ -251,14 +256,15 @@ wm_list_init (void)
|
|||
wm_list_read_dir (tempdir, TRUE);
|
||||
g_free (tempdir);
|
||||
|
||||
name = gnome_config_get_string ("wm-properties/Config/Config/Current");
|
||||
client = gconf_client_get_default ();
|
||||
name = gconf_client_get_string (client, CONFIG_PREFIX "/current", NULL);
|
||||
if (name) {
|
||||
current_wm = wm_list_find (window_managers, name);
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
if (!current_wm) {
|
||||
name = gnome_config_get_string ("default.wm/Default/WM");
|
||||
name = gconf_client_get_string (client, CONFIG_PREFIX "/default", NULL);
|
||||
|
||||
if (name) {
|
||||
current_wm = wm_list_find_exec (window_managers, name);
|
||||
|
@ -287,6 +293,8 @@ wm_list_init (void)
|
|||
|
||||
if(current_wm)
|
||||
current_wm_save = wm_list_find (window_managers_save, gnome_desktop_item_get_string (current_wm->dentry, GNOME_DESKTOP_ITEM_NAME));
|
||||
|
||||
g_object_unref (G_OBJECT (client));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -345,8 +353,14 @@ wm_list_save (void)
|
|||
/* Save the current window manager
|
||||
*/
|
||||
if(current_wm)
|
||||
gnome_config_set_string ("wm-properties/Config/Config/Current",
|
||||
gnome_desktop_item_get_string (current_wm->dentry, GNOME_DESKTOP_ITEM_NAME));
|
||||
{
|
||||
GConfClient *client = gconf_client_get_default ();
|
||||
gconf_client_set_string (client, CONFIG_PREFIX "/current",
|
||||
gnome_desktop_item_get_string (current_wm->dentry, GNOME_DESKTOP_ITEM_EXEC),
|
||||
NULL);
|
||||
g_object_unref (G_OBJECT (client));
|
||||
}
|
||||
|
||||
gnome_config_sync ();
|
||||
}
|
||||
|
||||
|
@ -434,6 +448,7 @@ wm_read_from_xml (xmlNodePtr wm_node)
|
|||
wm->dentry = gnome_desktop_item_new_from_file
|
||||
(xmlGetProp (wm_node, "desktop-entry"),
|
||||
GNOME_DESKTOP_ITEM_TYPE_APPLICATION, NULL);
|
||||
gnome_desktop_item_set_entry_type (wm->dentry, GNOME_DESKTOP_ITEM_TYPE_APPLICATION);
|
||||
|
||||
for (node = wm_node->children; node; node = node->next) {
|
||||
if (!strcmp (node->name, "config-exec"))
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <ctype.h>
|
||||
#include <libxml/parser.h>
|
||||
#include "wm-properties.h"
|
||||
#include "capplet-widget.h"
|
||||
#include "gnome.h"
|
||||
|
||||
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||
|
@ -130,6 +129,13 @@ gboolean restart_pending = FALSE;
|
|||
*/
|
||||
gboolean in_fill = FALSE;
|
||||
|
||||
static gint cap_session_init = 0;
|
||||
static struct poptOption cap_options[] = {
|
||||
{"init-session-settings", '\0', POPT_ARG_NONE, &cap_session_init, 0,
|
||||
N_("Initialize session settings"), NULL},
|
||||
{NULL, '\0', 0, NULL, 0}
|
||||
};
|
||||
|
||||
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||
|
||||
static void
|
||||
|
@ -150,6 +156,34 @@ store_archive_data (void)
|
|||
|
||||
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||
|
||||
static void
|
||||
response_cb (GtkDialog *dialog, gint response_id, gpointer data)
|
||||
{
|
||||
int old_state = state;
|
||||
|
||||
switch (response_id)
|
||||
{
|
||||
case GTK_RESPONSE_NONE:
|
||||
case GTK_RESPONSE_CLOSE:
|
||||
gtk_main_quit ();
|
||||
break;
|
||||
case GTK_RESPONSE_APPLY:
|
||||
state = STATE_TRY;
|
||||
restart(FALSE);
|
||||
wm_list_set_current (selected_wm);
|
||||
wm_list_save ();
|
||||
update_session ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
state_changed (void)
|
||||
{
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (capplet), GTK_RESPONSE_APPLY,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
left_aligned_button (gchar *label)
|
||||
{
|
||||
|
@ -615,6 +649,7 @@ restart (gboolean force)
|
|||
GnomeDesktopItem *twm_dentry = gnome_desktop_item_new ();
|
||||
WindowManager twm_fallback = {twm_dentry, "twm", "twm", 0, 0, 1, 0};
|
||||
|
||||
gnome_desktop_item_set_entry_type (twm_dentry, GNOME_DESKTOP_ITEM_TYPE_APPLICATION);
|
||||
gnome_desktop_item_set_string (twm_dentry,
|
||||
GNOME_DESKTOP_ITEM_NAME, "twm");
|
||||
gnome_desktop_item_set_string (twm_dentry,
|
||||
|
@ -964,7 +999,7 @@ edit_dialog (void)
|
|||
if (selected_wm->is_user && (result == 0)) {
|
||||
get_dialog_contents (dialog, selected_wm);
|
||||
update_gui();
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (capplet), TRUE);
|
||||
state_changed ();
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog->dialog);
|
||||
|
@ -985,6 +1020,7 @@ add_dialog (void)
|
|||
if (result == 0) {
|
||||
wm = g_new0 (WindowManager, 1);
|
||||
wm->dentry = gnome_desktop_item_new ();
|
||||
gnome_desktop_item_set_entry_type (wm->dentry, GNOME_DESKTOP_ITEM_TYPE_APPLICATION);
|
||||
get_dialog_contents (dialog, wm);
|
||||
|
||||
wm->is_user = TRUE;
|
||||
|
@ -993,8 +1029,8 @@ add_dialog (void)
|
|||
|
||||
selected_wm = wm;
|
||||
update_gui();
|
||||
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (capplet), TRUE);
|
||||
|
||||
state_changed ();
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog->dialog);
|
||||
|
@ -1017,7 +1053,7 @@ select_row (GtkCList *the_clist,
|
|||
|
||||
if (wm != selected_wm) {
|
||||
selected_wm = wm;
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (capplet), TRUE);
|
||||
state_changed ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1040,7 +1076,7 @@ delete (void)
|
|||
wm_list_delete (selected_wm);
|
||||
selected_wm = current_wm;
|
||||
update_gui();
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (capplet), TRUE);
|
||||
state_changed ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1072,7 +1108,14 @@ wm_setup (void)
|
|||
GtkWidget *scrolled_window;
|
||||
GtkWidget *label;
|
||||
|
||||
capplet = capplet_widget_new ();
|
||||
capplet = gtk_dialog_new_with_buttons (_("Window Manager Selector"),
|
||||
NULL,
|
||||
-1,
|
||||
GTK_STOCK_HELP, GTK_RESPONSE_HELP,
|
||||
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
|
||||
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
||||
NULL);
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (capplet), GTK_RESPONSE_APPLY, FALSE);
|
||||
gtk_widget_set_usize (capplet, 360, 200);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
|
@ -1130,7 +1173,8 @@ wm_setup (void)
|
|||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
|
||||
gtk_box_pack_end (GTK_BOX (vbox), bottom, FALSE, FALSE, 0);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (capplet), vbox);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (capplet)->vbox), vbox,
|
||||
TRUE, TRUE, 0);
|
||||
|
||||
gtk_widget_show_all (capplet);
|
||||
|
||||
|
@ -1169,21 +1213,14 @@ static void do_set_xml (void)
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
gint init_results;
|
||||
|
||||
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
argv0 = g_strdup (argv[0]);
|
||||
init_results = gnome_capplet_init("wm-properties", VERSION,
|
||||
argc, argv, NULL, 0, NULL);
|
||||
|
||||
if (init_results < 0) {
|
||||
g_warning (_("an initialization error occurred while "
|
||||
"starting 'wm-properties-capplet'.\n"
|
||||
"aborting...\n"));
|
||||
exit (1);
|
||||
}
|
||||
gnome_program_init ("wm-properties", VERSION,
|
||||
LIBGNOMEUI_MODULE, argc, argv,
|
||||
GNOME_PARAM_POPT_TABLE, &cap_options,
|
||||
NULL);
|
||||
|
||||
/* Read in the list of window managers, and the current
|
||||
* window manager
|
||||
|
@ -1191,41 +1228,20 @@ main (int argc, char **argv)
|
|||
wm_list_init();
|
||||
selected_wm = wm_list_get_current();
|
||||
|
||||
if (init_results == 0) {
|
||||
if (!cap_session_init)
|
||||
{
|
||||
init_session();
|
||||
wm_setup();
|
||||
gtk_signal_connect(GTK_OBJECT(capplet), "destroy",
|
||||
GTK_SIGNAL_FUNC(destroy_callback), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (capplet), "help",
|
||||
GTK_SIGNAL_FUNC (help_callback), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (capplet), "try",
|
||||
GTK_SIGNAL_FUNC (try_callback), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (capplet), "revert",
|
||||
GTK_SIGNAL_FUNC (revert_callback), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (capplet), "cancel",
|
||||
GTK_SIGNAL_FUNC (cancel_callback), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (capplet), "ok",
|
||||
GTK_SIGNAL_FUNC (ok_callback), NULL);
|
||||
g_signal_connect (G_OBJECT (capplet), "response",
|
||||
response_cb, NULL);
|
||||
|
||||
capplet_gtk_main ();
|
||||
gtk_main ();
|
||||
|
||||
if (restart_pending) {
|
||||
quit_pending = TRUE;
|
||||
gtk_main();
|
||||
}
|
||||
|
||||
if (state == STATE_OK) {
|
||||
wm_list_save ();
|
||||
update_session ();
|
||||
}
|
||||
|
||||
}
|
||||
else if (init_results == 3) {
|
||||
do_get_xml ();
|
||||
}
|
||||
else if (init_results == 4) {
|
||||
do_set_xml ();
|
||||
}
|
||||
else {
|
||||
if (selected_wm &&
|
||||
!selected_wm->session_managed &&
|
||||
|
|
Loading…
Add table
Reference in a new issue