~ubuntu-branches/ubuntu/maverick/gnome-session/maverick

« back to all changes in this revision

Viewing changes to gnome-session/session-properties.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette
  • Date: 2009-04-14 19:24:09 UTC
  • mto: (1.3.1 upstream) (2.1.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 112.
  • Revision ID: james.westby@ubuntu.com-20090414192409-koxw9bt1lf1zr01z
ImportĀ upstreamĀ versionĀ 2.26.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* session-properties.c - a non-CORBA version of the session-properties-capplet
2
 
 
3
 
   Copyright 1999 Free Software Foundation, Inc.
4
 
 
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)
8
 
   any later version.
9
 
 
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.
14
 
 
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
18
 
   02111-1307, USA. 
19
 
 
20
 
   Authors: Felix Bellaby */
21
 
 
22
 
#include <config.h>
23
 
 
24
 
#include <glib/gi18n.h>
25
 
 
26
 
#include "gsm-client-list.h"
27
 
#include "gsm-atk.h"
28
 
 
29
 
#include "session-properties.h"
30
 
#include "session-properties-capplet.h"
31
 
 
32
 
static GtkWidget *remove_button;
33
 
GtkWidget *apply_button;
34
 
static GtkWidget *scrolled_window;
35
 
static GtkWidget *client_list;
36
 
static GtkWidget *client_editor;
37
 
 
38
 
static DirtyCallbackFunc parent_dirty_cb;
39
 
 
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);
44
 
 
45
 
static GtkWidget*
46
 
create_table (void)
47
 
{
48
 
  GtkWidget *vbox, *hbox,  *label;
49
 
 
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);
55
 
 
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);
60
 
 
61
 
  /* client list */
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),
67
 
                   client_list);
68
 
  g_signal_connect(client_list, "dirty",
69
 
                     G_CALLBACK (session_properties_dirty_cb), NULL);
70
 
 
71
 
  client_editor = gsm_client_list_get_editor (GSM_CLIENT_LIST (client_list));
72
 
 
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),
78
 
                                       GTK_SHADOW_IN);
79
 
  gtk_container_add (GTK_CONTAINER (scrolled_window), client_list);
80
 
 
81
 
  vbox = gtk_vbox_new (FALSE, 6);
82
 
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
83
 
 
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);
88
 
  
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);
92
 
  
93
 
  gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
94
 
 
95
 
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
96
 
 
97
 
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), client_list);
98
 
 
99
 
  return vbox;
100
 
}
101
 
 
102
 
GtkWidget *
103
 
session_properties_create_page (DirtyCallbackFunc dcf)
104
 
{
105
 
  GtkWidget *page;
106
 
 
107
 
  parent_dirty_cb = dcf;
108
 
 
109
 
  page = create_table ();
110
 
 
111
 
  gtk_widget_show_all (page);
112
 
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
113
 
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
114
 
 
115
 
  return page;
116
 
}
117
 
 
118
 
/* CAPPLET CALLBACKS */
119
 
void
120
 
session_properties_apply (void)
121
 
{
122
 
  gsm_client_list_commit_changes (GSM_CLIENT_LIST (client_list));
123
 
}
124
 
 
125
 
/* Remove the selected clients. */
126
 
static void
127
 
remove_cb (GtkWidget *widget)
128
 
{
129
 
  gsm_client_list_remove_selection (GSM_CLIENT_LIST (client_list));
130
 
}
131
 
 
132
 
/* This is called when a client is selected.  */
133
 
static void
134
 
selection_changed (GtkTreeSelection *selection)
135
 
{
136
 
  gtk_widget_set_sensitive (GTK_WIDGET (remove_button),
137
 
                            gtk_tree_selection_get_selected (selection, NULL, NULL));
138
 
}
139
 
 
140
 
/* This is called when an change is made in the client list.  */
141
 
static void
142
 
session_properties_dirty_cb (GtkWidget *widget)
143
 
{
144
 
  parent_dirty_cb ();
145
 
}