source: trunk/third/gnome-core/applets/tasklist/tasklist_properties.c @ 16298

Revision 16298, 11.9 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r16297, which included commits to RCS files with non-trunk default branches.
Line 
1#include <config.h>
2#include "tasklist_applet.h"
3
4/* Callback for apply */
5static void
6cb_apply (GtkWidget *widget, gint page, gpointer data)
7{
8        Tasklist *tasklist = data;
9       
10        /* Copy the Property struct back to the Config struct */
11        memcpy (&tasklist->config, &tasklist->PropsConfig, sizeof (TasklistConfig));
12
13        /* Redraw everything */
14        tasklist_redo_vtasks (tasklist);
15        tasklist_change_size (tasklist, TRUE, -1);
16
17        /* setup tooltips */
18        if (tasklist->config.enable_tooltips)
19                gtk_tooltips_enable (tasklist->tooltips);
20        else
21                gtk_tooltips_disable (tasklist->tooltips);
22
23}
24
25/* Callback for radio buttons */
26static void
27cb_radio_button (GtkWidget *widget, gint *data)
28{
29        Tasklist *tasklist = gtk_object_get_user_data (GTK_OBJECT (widget));
30       
31        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
32                *data = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget),
33                                                              "number"));
34                gnome_property_box_changed (GNOME_PROPERTY_BOX (tasklist->prop));
35        }
36}
37
38/* Callback for spin buttons */
39static void
40cb_spin_button (GtkWidget *widget, gint *data)
41{
42        Tasklist *tasklist = gtk_object_get_user_data (GTK_OBJECT (widget));
43       
44        gnome_property_box_changed (GNOME_PROPERTY_BOX (tasklist->prop));
45       
46        *data = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
47}
48
49/* Callback for check buttons */
50static void
51cb_check_button (GtkWidget *widget, gboolean *data)
52{
53        Tasklist *tasklist = gtk_object_get_user_data (GTK_OBJECT (widget));
54       
55        gnome_property_box_changed (GNOME_PROPERTY_BOX (tasklist->prop));
56
57        *data = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
58}
59
60static void
61cb_check_button_disable (GtkWidget *widget, GtkWidget *todisable)
62{
63        gboolean active;
64        active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
65        gtk_widget_set_sensitive (todisable, !active);
66}
67
68 
69/* Create a spin button */
70static GtkWidget *
71create_spin_button (Tasklist *tasklist,
72                    gchar *name,
73                    gint *init_value,
74                    gfloat min_value,
75                    gfloat max_value,
76                    gfloat page_value)
77{
78        GtkObject *adj;
79        GtkWidget *spin;
80        GtkWidget *hbox;
81        GtkWidget *label;
82
83        adj = gtk_adjustment_new (*init_value,
84                                  min_value,
85                                  max_value,
86                                  1,
87                                  page_value,
88                                  page_value);
89       
90        hbox = gtk_hbox_new (TRUE, GNOME_PAD_SMALL);
91
92        spin = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1, 0);
93        gtk_object_set_user_data (GTK_OBJECT (spin), tasklist);
94        gtk_signal_connect (GTK_OBJECT (spin), "changed",
95                            GTK_SIGNAL_FUNC (cb_spin_button), init_value);
96                                               
97
98
99        label = gtk_label_new (name);
100        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
101
102        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
103        gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, TRUE, 0);
104
105        return hbox;
106}
107
108/* Create a radio button */
109static GtkWidget *
110create_radio_button (Tasklist *tasklist, gchar *name, GSList **group,
111                     gint number, gint *change_value)
112{
113        GtkWidget *radiobutton;
114       
115        radiobutton = gtk_radio_button_new_with_label (*group, name);
116        *group = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
117
118        if (number == *change_value)
119                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton), TRUE);
120       
121        gtk_signal_connect (GTK_OBJECT (radiobutton), "toggled",
122                            GTK_SIGNAL_FUNC (cb_radio_button), change_value);
123        gtk_object_set_data (GTK_OBJECT (radiobutton), "number",
124                             GINT_TO_POINTER (number));
125        gtk_object_set_user_data (GTK_OBJECT (radiobutton), tasklist);
126
127        return radiobutton;
128}
129
130/* Create a check button */
131static GtkWidget *
132create_check_button (Tasklist *tasklist, gchar *name, gboolean *change_value)
133{
134        GtkWidget *checkbutton;
135
136        checkbutton = gtk_check_button_new_with_label (name);
137        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), *change_value);
138        gtk_object_set_user_data (GTK_OBJECT (checkbutton), tasklist);
139        gtk_signal_connect (GTK_OBJECT (checkbutton), "toggled",
140                            GTK_SIGNAL_FUNC (cb_check_button), change_value);
141        return checkbutton;
142}
143
144/* Create the size page */
145static void
146create_size_page (Tasklist *tasklist)
147{
148        GtkWidget *hbox,/* *table,*/ *frame, *vbox, *topbox;
149        GSList *vertgroup = NULL, *horzgroup = NULL;
150        GtkWidget *autobutton, *w;
151       
152        topbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
153        gtk_container_border_width (GTK_CONTAINER (topbox), GNOME_PAD_SMALL);
154       
155        autobutton = create_check_button (
156                tasklist, _("Follow panel size"),
157                &tasklist->PropsConfig.follow_panel_size);
158        gtk_box_pack_start (GTK_BOX (topbox),
159                            autobutton,
160                            FALSE, TRUE, 0);
161
162        hbox = gtk_hbox_new (TRUE, GNOME_PAD_SMALL);
163        gtk_box_pack_start_defaults (GTK_BOX (topbox), hbox);
164
165        frame = gtk_frame_new (_("Horizontal"));
166
167        gtk_box_pack_start_defaults (GTK_BOX (hbox), frame);
168       
169        vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
170        gtk_container_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL);
171
172        gtk_box_pack_start (
173                GTK_BOX (vbox),
174                create_spin_button (
175                        tasklist, _("Tasklist width:"),
176                        &tasklist->PropsConfig.horz_width,
177                        48,
178                        8192,
179                        10),
180                FALSE, TRUE, 0);
181        w = create_spin_button (
182                tasklist, _("Rows of tasks:"),
183                &tasklist->PropsConfig.horz_rows,
184                1,
185                8,
186                1);
187        gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, TRUE, 0);
188        gtk_signal_connect (GTK_OBJECT (autobutton), "toggled",
189                            GTK_SIGNAL_FUNC (cb_check_button_disable),
190                            w);
191        cb_check_button_disable (autobutton, w);
192
193        gtk_box_pack_start (
194                GTK_BOX (vbox),
195                create_spin_button (
196                        tasklist, _("Default task size:"),
197                        &tasklist->PropsConfig.horz_taskwidth,
198                        48,
199                        350,
200                        10),
201                FALSE, TRUE, 0);
202
203
204        gtk_box_pack_start (GTK_BOX (vbox),
205                            create_radio_button (
206                                    tasklist, _("Tasklist width is fixed"),
207                                    &horzgroup, TRUE, &tasklist->PropsConfig.horz_fixed),
208                            FALSE, TRUE, 0);
209        gtk_box_pack_start (GTK_BOX (vbox),
210                            create_radio_button (
211                                    tasklist, _("Tasklist width is dynamic"),
212                                    &horzgroup, FALSE, &tasklist->PropsConfig.horz_fixed),
213                            FALSE, TRUE, 0);
214
215        gtk_box_pack_start (GTK_BOX (vbox),
216                            create_check_button (tasklist, _("Only use empty space"),
217                                                 &tasklist->PropsConfig.horz_never_push),
218                            FALSE, TRUE, 0);
219
220        gtk_container_add (GTK_CONTAINER (frame), vbox);
221       
222        frame = gtk_frame_new (_("Vertical"));
223        gtk_box_pack_start_defaults (GTK_BOX (hbox), frame);
224       
225        vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
226        gtk_container_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL);
227
228        gtk_box_pack_start (
229                GTK_BOX (vbox),
230                create_spin_button (tasklist, _("Tasklist height:"),
231                                    &tasklist->PropsConfig.vert_height,
232                                    48,
233                                    1024*8,
234                                    10),
235                FALSE, TRUE, 0);
236
237        w = create_spin_button (tasklist, _("Tasklist width:"),
238                                &tasklist->PropsConfig.vert_width,
239                                48,
240                                512,
241                                10);
242        gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, TRUE, 0);
243        gtk_signal_connect (GTK_OBJECT (autobutton), "toggled",
244                           GTK_SIGNAL_FUNC (cb_check_button_disable),
245                           w);
246        cb_check_button_disable (autobutton, w);
247
248        gtk_box_pack_start (GTK_BOX (vbox),
249                            create_radio_button (
250                                    tasklist,_("Tasklist height is fixed"),
251                                    &vertgroup, TRUE, &tasklist->PropsConfig.vert_fixed),
252                            FALSE, TRUE, 0);
253        gtk_box_pack_start (
254                GTK_BOX (vbox),
255                create_radio_button (
256                        tasklist, _("Tasklist height is dynamic"),
257                        &vertgroup, FALSE, &tasklist->PropsConfig.vert_fixed),
258                FALSE, TRUE, 0);
259
260
261        gtk_box_pack_start (GTK_BOX (vbox),
262                            create_check_button (tasklist, _("Only use empty space"),
263                                                 &tasklist->PropsConfig.vert_never_push),
264                            FALSE, TRUE, 0);
265
266        gtk_box_pack_start (GTK_BOX (vbox),
267                            create_check_button (tasklist,
268                                                 _("Tasklist width is that of longest title"),
269                                                 &tasklist->PropsConfig.vert_width_full),
270                            FALSE, TRUE, 0);
271       
272        gtk_container_add (GTK_CONTAINER (frame), vbox);
273
274        gnome_property_box_append_page (
275                GNOME_PROPERTY_BOX (tasklist->prop), topbox,
276                gtk_label_new (_("Size")));
277}
278
279static void
280create_display_page (Tasklist *tasklist)
281{
282        GtkWidget *vbox, *frame;
283        GtkWidget *miscbox, *taskbox;
284        /*GtkWidget *radio;*/
285        /*GSList *taskgroup = NULL;*/
286
287        vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
288       
289        frame = gtk_frame_new (_("Which tasks to show"));
290        gtk_container_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL);
291        gtk_box_pack_start_defaults (GTK_BOX (vbox), frame);
292
293        taskbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
294        gtk_container_border_width (GTK_CONTAINER (taskbox), GNOME_PAD_SMALL);
295        gtk_container_add (GTK_CONTAINER (frame), taskbox);
296       
297        gtk_box_pack_start (
298                GTK_BOX (taskbox),
299                create_check_button (
300                        tasklist, _("Show normal applications"),
301                        &tasklist->PropsConfig.show_normal),
302                FALSE, TRUE, 0);
303        gtk_box_pack_start (
304                GTK_BOX (taskbox),
305                create_check_button (
306                        tasklist, _("Show iconified (minimized) applications"),
307                        &tasklist->PropsConfig.show_minimized),
308                FALSE, TRUE, 0);
309                           
310        gtk_box_pack_start (
311                GTK_BOX (taskbox),
312                create_check_button (
313                        tasklist, _("Show normal applications on all desktops"),
314                        &tasklist->PropsConfig.all_desks_normal),
315                FALSE, TRUE, 0);
316        gtk_box_pack_start (
317                GTK_BOX (taskbox),
318                create_check_button (tasklist,
319                                     _("Show iconified (minimized) applications on all desktops"),
320                                     &tasklist->PropsConfig.all_desks_minimized),
321                FALSE, TRUE, 0);
322
323        frame = gtk_frame_new (_("Miscellaneous"));
324        gtk_container_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL);
325        gtk_box_pack_start_defaults (GTK_BOX (vbox), frame);
326       
327        miscbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
328        gtk_container_border_width (GTK_CONTAINER (miscbox), GNOME_PAD_SMALL);
329        gtk_container_add (GTK_CONTAINER (frame), miscbox);
330
331        gtk_box_pack_start (
332                GTK_BOX (miscbox),
333                create_check_button (
334                        tasklist, _("Show mini icons"),
335                        &tasklist->PropsConfig.show_mini_icons),
336                FALSE, TRUE, 0);
337        gtk_box_pack_start (
338                GTK_BOX (miscbox),
339                create_check_button (
340                        tasklist,
341                        _("Confirm before killing windows"),
342                        &tasklist->PropsConfig.confirm_before_kill),
343                FALSE, TRUE, 0);
344        gtk_box_pack_start (
345                GTK_BOX (miscbox),
346                create_check_button (
347                        tasklist,
348                        _("Move iconified tasks to current workspace when restoring"),
349                        &tasklist->PropsConfig.move_to_current),
350                FALSE, TRUE, 0);
351        gtk_box_pack_start (
352                GTK_BOX (miscbox),
353                create_check_button (
354                        tasklist,
355                        _("Display tooltips with full task names"),
356                        &tasklist->PropsConfig.enable_tooltips),
357                FALSE, TRUE, 0);
358
359        gtk_box_pack_start (
360                GTK_BOX (miscbox),
361                create_check_button (
362                        tasklist,
363                        _("Enable task grouping"),
364                        &tasklist->PropsConfig.enable_grouping),
365                FALSE, TRUE, 0);
366
367        gtk_box_pack_start (
368                GTK_BOX (miscbox),
369                create_spin_button (
370                        tasklist,
371                        _("Number of tasks before grouping occurs"),
372                        &tasklist->PropsConfig.grouping_min,
373                        1, 10, 3),
374                FALSE, TRUE, 0);
375
376        gtk_box_pack_start (
377                GTK_BOX (miscbox),
378                create_check_button (
379                        tasklist,
380                        _("Sink tasklist into panel"),
381                        &tasklist->PropsConfig.sunken),
382                FALSE, TRUE, 0);
383
384        gnome_property_box_append_page (GNOME_PROPERTY_BOX (tasklist->prop), vbox,
385                                        gtk_label_new (_("Display")));
386}
387
388static void
389phelp_cb (GtkWidget *w, gint tab, gpointer data)
390{
391        GnomeHelpMenuEntry help_entry = { "tasklist_applet",
392                                          "index.html#TASKLIST-APPLET-PROPERTIES" };
393        gnome_help_display(NULL, &help_entry);
394}
395
396/* Display property dialog */
397void
398tasklist_display_properties (Tasklist *tasklist)
399{
400        if (tasklist->prop != NULL)
401        {
402                gdk_window_show (tasklist->prop->window);
403                gdk_window_raise (tasklist->prop->window);
404                return;
405
406        }
407        /*
408         * Copy memory from the tasklist config
409         * to the tasklist properties config.
410         */
411        memcpy (&tasklist->PropsConfig, &tasklist->config, sizeof (TasklistConfig));
412
413        tasklist->prop = gnome_property_box_new ();
414        gtk_window_set_title (GTK_WINDOW (tasklist->prop), _("Tasklist properties"));
415        gtk_window_set_wmclass (GTK_WINDOW (tasklist->prop), "tasklist", "Tasklist");
416        gtk_signal_connect (GTK_OBJECT (tasklist->prop), "apply",
417                            GTK_SIGNAL_FUNC (cb_apply), tasklist);
418        gtk_signal_connect (GTK_OBJECT (tasklist->prop), "destroy",
419                            GTK_SIGNAL_FUNC (gtk_widget_destroyed),
420                            &tasklist->prop);
421        gtk_signal_connect (GTK_OBJECT (tasklist->prop), "help",
422                            GTK_SIGNAL_FUNC (phelp_cb), NULL);
423        create_display_page (tasklist);
424        create_size_page (tasklist);
425
426        gtk_widget_show_all (tasklist->prop);
427}
Note: See TracBrowser for help on using the repository browser.