1
/* session-properties.c - a non-CORBA version of the session-properties-capplet
3
Copyright 1999 Free Software Foundation, Inc.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2, or (at your option)
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20
Authors: Felix Bellaby */
24
#include <glib/gi18n.h>
26
#include "gsm-client-list.h"
29
#include "session-properties.h"
30
#include "session-properties-capplet.h"
32
static GtkWidget *remove_button;
33
GtkWidget *apply_button;
34
static GtkWidget *scrolled_window;
35
static GtkWidget *client_list;
36
static GtkWidget *client_editor;
38
static DirtyCallbackFunc parent_dirty_cb;
40
/* table widget callback prototypes */
41
static void remove_cb (GtkWidget *widget);
42
static void selection_changed (GtkTreeSelection *selection);
43
static void session_properties_dirty_cb (GtkWidget *widget);
48
GtkWidget *vbox, *hbox, *label;
50
remove_button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
51
gsm_atk_set_description (remove_button, _("Remove the currently selected client from the session."));
52
gtk_widget_set_sensitive (GTK_WIDGET (remove_button), FALSE);
53
g_signal_connect(remove_button, "clicked",
54
G_CALLBACK (remove_cb), NULL);
56
apply_button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
57
gsm_atk_set_description (apply_button, _("Apply changes to the current session"));
58
gtk_widget_set_sensitive (GTK_WIDGET (apply_button), FALSE);
59
g_signal_connect (G_OBJECT (apply_button), "clicked", apply, NULL);
62
client_list = gsm_client_list_new ();
63
gsm_atk_set_description (client_list, _("The list of programs in the session."));
64
gsm_client_list_live_session (GSM_CLIENT_LIST (client_list));
65
g_signal_connect(gtk_tree_view_get_selection (GTK_TREE_VIEW (client_list)),
66
"changed", G_CALLBACK (selection_changed),
68
g_signal_connect(client_list, "dirty",
69
G_CALLBACK (session_properties_dirty_cb), NULL);
71
client_editor = gsm_client_list_get_editor (GSM_CLIENT_LIST (client_list));
73
/* scrolled window - disabled until the client_list "initialized" signal */
74
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
75
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
76
GTK_POLICY_NEVER, GTK_POLICY_NEVER);
77
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
79
gtk_container_add (GTK_CONTAINER (scrolled_window), client_list);
81
vbox = gtk_vbox_new (FALSE, 6);
82
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
84
hbox = gtk_hbox_new (FALSE, 6);
85
gtk_box_pack_start (GTK_BOX (hbox), client_editor, FALSE, FALSE, 0);
86
gtk_box_pack_start (GTK_BOX (hbox), remove_button, FALSE, FALSE, 0);
87
gtk_box_pack_start (GTK_BOX (hbox), apply_button, FALSE, FALSE, 0);
89
label = gtk_label_new_with_mnemonic (_("Currently running _programs:"));
90
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
91
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
93
gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
95
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
97
gtk_label_set_mnemonic_widget (GTK_LABEL (label), client_list);
103
session_properties_create_page (DirtyCallbackFunc dcf)
107
parent_dirty_cb = dcf;
109
page = create_table ();
111
gtk_widget_show_all (page);
112
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
113
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
118
/* CAPPLET CALLBACKS */
120
session_properties_apply (void)
122
gsm_client_list_commit_changes (GSM_CLIENT_LIST (client_list));
125
/* Remove the selected clients. */
127
remove_cb (GtkWidget *widget)
129
gsm_client_list_remove_selection (GSM_CLIENT_LIST (client_list));
132
/* This is called when a client is selected. */
134
selection_changed (GtkTreeSelection *selection)
136
gtk_widget_set_sensitive (GTK_WIDGET (remove_button),
137
gtk_tree_selection_get_selected (selection, NULL, NULL));
140
/* This is called when an change is made in the client list. */
142
session_properties_dirty_cb (GtkWidget *widget)