[18373] | 1 | /* -*- mode: c; style: linux -*- */ |
---|
| 2 | |
---|
| 3 | /* capplet-dir-view.c |
---|
| 4 | * Copyright (C) 2000, 2001 Ximian, Inc. |
---|
| 5 | * |
---|
| 6 | * Written by Bradford Hovinen <hovinen@ximian.com> |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or modify |
---|
| 9 | * it under the terms of the GNU General Public License as published by |
---|
| 10 | * the Free Software Foundation; either version 2, or (at your option) |
---|
| 11 | * any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
| 21 | * 02111-1307, USA. |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | #ifdef HAVE_CONFIG_H |
---|
| 25 | # include <config.h> |
---|
| 26 | #endif |
---|
| 27 | |
---|
| 28 | #include <gdk-pixbuf/gdk-pixbuf.h> |
---|
| 29 | #include <libgnomeui/gnome-window-icon.h> |
---|
| 30 | #include <glade/glade.h> |
---|
| 31 | |
---|
| 32 | #include "capplet-dir-view.h" |
---|
| 33 | |
---|
| 34 | extern CappletDirViewImpl capplet_dir_view_list; |
---|
| 35 | #if 0 |
---|
| 36 | extern CappletDirViewImpl capplet_dir_view_tree; |
---|
| 37 | #endif |
---|
| 38 | |
---|
| 39 | CappletDirViewImpl *capplet_dir_view_impl[] = { |
---|
| 40 | NULL, |
---|
| 41 | &capplet_dir_view_list, |
---|
| 42 | #if 0 |
---|
| 43 | &capplet_dir_view_tree, |
---|
| 44 | #endif |
---|
| 45 | }; |
---|
| 46 | |
---|
| 47 | static GObjectClass *parent_class; |
---|
| 48 | |
---|
| 49 | enum { |
---|
| 50 | PROP_0, |
---|
| 51 | PROP_CAPPLET_DIR, |
---|
| 52 | PROP_LAYOUT |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | static GList *window_list; |
---|
| 56 | static gboolean authed; |
---|
| 57 | |
---|
| 58 | static void capplet_dir_view_init (CappletDirView *capplet_dir_view, |
---|
| 59 | CappletDirViewClass *class); |
---|
| 60 | static void capplet_dir_view_class_init (CappletDirViewClass *class); |
---|
| 61 | |
---|
| 62 | static void capplet_dir_view_set_prop (GObject *object, |
---|
| 63 | guint prop_id, |
---|
| 64 | const GValue *value, |
---|
| 65 | GParamSpec *pspec); |
---|
| 66 | static void capplet_dir_view_get_prop (GObject *object, |
---|
| 67 | guint prop_id, |
---|
| 68 | GValue *value, |
---|
| 69 | GParamSpec *pspec); |
---|
| 70 | |
---|
| 71 | static void capplet_dir_view_finalize (GObject *object); |
---|
| 72 | |
---|
| 73 | static void close_cb (BonoboUIComponent *uic, |
---|
| 74 | gpointer data, |
---|
| 75 | const char *cname); |
---|
| 76 | static void help_menu_cb (BonoboUIComponent *uic, |
---|
| 77 | gpointer data, |
---|
| 78 | const char *cname); |
---|
| 79 | static void about_menu_cb (BonoboUIComponent *uic, |
---|
| 80 | gpointer data, |
---|
| 81 | const char *cname); |
---|
| 82 | |
---|
| 83 | GType |
---|
| 84 | capplet_dir_view_get_type (void) |
---|
| 85 | { |
---|
| 86 | static GtkType capplet_dir_view_type = 0; |
---|
| 87 | |
---|
| 88 | if (!capplet_dir_view_type) { |
---|
| 89 | static const GTypeInfo capplet_dir_view_info = { |
---|
| 90 | sizeof (CappletDirViewClass), |
---|
| 91 | NULL, /* base_init */ |
---|
| 92 | NULL, /* base_finalize */ |
---|
| 93 | (GClassInitFunc) capplet_dir_view_class_init, |
---|
| 94 | NULL, /* class_finalize */ |
---|
| 95 | NULL, /* class_data */ |
---|
| 96 | sizeof (CappletDirView), |
---|
| 97 | 0 /* n_preallocs */, |
---|
| 98 | (GInstanceInitFunc) capplet_dir_view_init |
---|
| 99 | }; |
---|
| 100 | |
---|
| 101 | capplet_dir_view_type = |
---|
| 102 | g_type_register_static (G_TYPE_OBJECT, |
---|
| 103 | "CappletDirView", |
---|
| 104 | &capplet_dir_view_info, |
---|
| 105 | 0); |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | return capplet_dir_view_type; |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | static BonoboUIVerb capplet_dir_view_verbs[] = { |
---|
| 112 | BONOBO_UI_VERB ("FileClose", close_cb), |
---|
| 113 | BONOBO_UI_VERB ("HelpContent", help_menu_cb), |
---|
| 114 | BONOBO_UI_VERB ("HelpAbout", about_menu_cb), |
---|
| 115 | BONOBO_UI_VERB_END |
---|
| 116 | }; |
---|
| 117 | |
---|
| 118 | static void |
---|
| 119 | capplet_dir_view_init (CappletDirView *view, CappletDirViewClass *class) |
---|
| 120 | { |
---|
| 121 | BonoboUIContainer *ui_container; |
---|
| 122 | BonoboUIComponent *ui_component; |
---|
| 123 | |
---|
| 124 | window_list = g_list_prepend (window_list, view); |
---|
| 125 | |
---|
| 126 | view->app = BONOBO_WINDOW (bonobo_window_new ("gnomecc", "")); |
---|
| 127 | ui_container = bonobo_window_get_ui_container (view->app); |
---|
| 128 | |
---|
| 129 | gtk_window_set_default_size (GTK_WINDOW (view->app), 620, 430); |
---|
| 130 | gnome_window_icon_set_from_file (GTK_WINDOW (view->app), |
---|
| 131 | PIXMAP_DIR "/control-center2.png"); |
---|
| 132 | |
---|
| 133 | ui_component = bonobo_ui_component_new ("gnomecc"); |
---|
| 134 | bonobo_ui_component_set_container (ui_component, bonobo_object_corba_objref (BONOBO_OBJECT (ui_container)), NULL); |
---|
| 135 | bonobo_ui_util_set_ui (ui_component, |
---|
| 136 | GNOMECC_DATA_DIR, "gnomecc-ui.xml", "gnomecc", NULL); |
---|
| 137 | |
---|
| 138 | g_signal_connect_swapped (G_OBJECT (view->app), "destroy", |
---|
| 139 | (GCallback) g_object_unref, view); |
---|
| 140 | |
---|
| 141 | bonobo_ui_component_add_verb_list_with_data (ui_component, capplet_dir_view_verbs, view); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | static void |
---|
| 145 | capplet_dir_view_class_init (CappletDirViewClass *klass) |
---|
| 146 | { |
---|
| 147 | GObjectClass *object_class; |
---|
| 148 | |
---|
| 149 | object_class = G_OBJECT_CLASS (klass); |
---|
| 150 | |
---|
| 151 | object_class->finalize = capplet_dir_view_finalize; |
---|
| 152 | object_class->set_property = capplet_dir_view_set_prop; |
---|
| 153 | object_class->get_property = capplet_dir_view_get_prop; |
---|
| 154 | |
---|
| 155 | g_object_class_install_property |
---|
| 156 | (object_class, PROP_LAYOUT, |
---|
| 157 | g_param_spec_int ("layout", |
---|
| 158 | _("Layout"), |
---|
| 159 | _("Layout to use for this view of the capplets"), |
---|
| 160 | 0, sizeof (capplet_dir_view_impl) / sizeof (CappletDirViewImpl *), 0, |
---|
| 161 | G_PARAM_WRITABLE)); |
---|
| 162 | g_object_class_install_property |
---|
| 163 | (object_class, PROP_CAPPLET_DIR, |
---|
| 164 | g_param_spec_pointer ("capplet-dir", |
---|
| 165 | _("Capplet directory object"), |
---|
| 166 | _("Capplet directory that this view is viewing"), |
---|
| 167 | G_PARAM_WRITABLE)); |
---|
| 168 | |
---|
| 169 | parent_class = G_OBJECT_CLASS (g_type_class_ref (G_TYPE_OBJECT)); |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | static void |
---|
| 173 | capplet_dir_view_set_prop (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) |
---|
| 174 | { |
---|
| 175 | CappletDirView *view; |
---|
| 176 | CappletDirViewLayout layout; |
---|
| 177 | |
---|
| 178 | view = CAPPLET_DIR_VIEW (object); |
---|
| 179 | |
---|
| 180 | switch (prop_id) { |
---|
| 181 | case PROP_CAPPLET_DIR: |
---|
| 182 | capplet_dir_view_load_dir (view, g_value_get_pointer (value)); |
---|
| 183 | break; |
---|
| 184 | |
---|
| 185 | case PROP_LAYOUT: |
---|
| 186 | #ifdef USE_HTML |
---|
| 187 | layout = CLAMP (g_value_get_int (value), 0, LAYOUT_HTML); |
---|
| 188 | #else |
---|
| 189 | layout = CLAMP (g_value_get_int (value), 0, LAYOUT_ICON_LIST); |
---|
| 190 | #endif |
---|
| 191 | |
---|
| 192 | if (layout == view->layout) |
---|
| 193 | break; |
---|
| 194 | |
---|
| 195 | g_assert (!view->changing_layout); |
---|
| 196 | view->changing_layout = TRUE; |
---|
| 197 | |
---|
| 198 | if (view->impl && view->impl->clean) |
---|
| 199 | view->impl->clean (view); |
---|
| 200 | |
---|
| 201 | view->layout =layout; |
---|
| 202 | view->impl = capplet_dir_view_impl[layout]; |
---|
| 203 | |
---|
| 204 | if (view->impl && view->impl->create) { |
---|
| 205 | view->view = view->impl->create (view); |
---|
| 206 | |
---|
| 207 | bonobo_window_set_contents (view->app, view->view); |
---|
| 208 | |
---|
| 209 | if (view->capplet_dir && view->impl->populate) |
---|
| 210 | view->impl->populate (view); |
---|
| 211 | |
---|
| 212 | gtk_widget_show (view->view); |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | view->changing_layout = FALSE; |
---|
| 216 | break; |
---|
| 217 | |
---|
| 218 | default: |
---|
| 219 | g_warning ("Bad argument set"); |
---|
| 220 | break; |
---|
| 221 | } |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | static void |
---|
| 225 | capplet_dir_view_get_prop (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) |
---|
| 226 | { |
---|
| 227 | CappletDirView *view; |
---|
| 228 | |
---|
| 229 | view = CAPPLET_DIR_VIEW (object); |
---|
| 230 | |
---|
| 231 | switch (prop_id) { |
---|
| 232 | case PROP_CAPPLET_DIR: |
---|
| 233 | g_value_set_pointer (value, view->capplet_dir); |
---|
| 234 | break; |
---|
| 235 | |
---|
| 236 | case PROP_LAYOUT: |
---|
| 237 | g_value_set_uint (value, view->layout); |
---|
| 238 | break; |
---|
| 239 | |
---|
| 240 | default: |
---|
| 241 | g_warning ("Bad argument get"); |
---|
| 242 | break; |
---|
| 243 | } |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | static void |
---|
| 247 | capplet_dir_view_finalize (GObject *object) |
---|
| 248 | { |
---|
| 249 | CappletDirView *view; |
---|
| 250 | |
---|
| 251 | g_return_if_fail (object != NULL); |
---|
| 252 | g_return_if_fail (IS_CAPPLET_DIR_VIEW (object)); |
---|
| 253 | |
---|
| 254 | view = CAPPLET_DIR_VIEW (object); |
---|
| 255 | |
---|
| 256 | view->capplet_dir->view = NULL; |
---|
| 257 | |
---|
| 258 | window_list = g_list_remove (window_list, view); |
---|
| 259 | |
---|
| 260 | if (g_list_length (window_list) == 0) |
---|
| 261 | gtk_main_quit (); |
---|
| 262 | |
---|
| 263 | G_OBJECT_CLASS (parent_class)->finalize (object); |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | void |
---|
| 267 | capplet_dir_view_update_authenticated (CappletDirView *view, gpointer null) |
---|
| 268 | { |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | CappletDirView * |
---|
| 272 | capplet_dir_view_new (void) |
---|
| 273 | { |
---|
| 274 | GObject *view; |
---|
| 275 | |
---|
| 276 | view = g_object_new (capplet_dir_view_get_type (), |
---|
| 277 | "layout", LAYOUT_ICON_LIST, |
---|
| 278 | NULL); |
---|
| 279 | |
---|
| 280 | capplet_dir_view_update_authenticated |
---|
| 281 | (CAPPLET_DIR_VIEW (view), NULL); |
---|
| 282 | |
---|
| 283 | return CAPPLET_DIR_VIEW (view); |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | void |
---|
| 287 | capplet_dir_views_set_authenticated (gboolean amiauthedornot) |
---|
| 288 | { |
---|
| 289 | authed = amiauthedornot; |
---|
| 290 | g_list_foreach (window_list, (GFunc)capplet_dir_view_update_authenticated, NULL); |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | static void |
---|
| 294 | close_cb (BonoboUIComponent *uic, gpointer data, const char *cname) |
---|
| 295 | { |
---|
| 296 | CappletDirView *view = CAPPLET_DIR_VIEW (data); |
---|
| 297 | gtk_widget_destroy (GTK_WIDGET (CAPPLET_DIR_VIEW_W (view))); |
---|
| 298 | } |
---|
| 299 | |
---|
| 300 | static void |
---|
| 301 | help_menu_cb (BonoboUIComponent *uic, gpointer data, const char *cname) |
---|
| 302 | { |
---|
| 303 | GError *error = NULL; |
---|
| 304 | |
---|
| 305 | gnome_help_display_desktop (NULL, |
---|
| 306 | "user-guide", |
---|
[20937] | 307 | "user-guide.xml", |
---|
[18373] | 308 | NULL, &error); |
---|
| 309 | if (error) { |
---|
| 310 | GtkWidget *dialog; |
---|
| 311 | dialog = gtk_message_dialog_new (NULL, |
---|
| 312 | GTK_DIALOG_MODAL, |
---|
| 313 | GTK_MESSAGE_ERROR, |
---|
| 314 | GTK_BUTTONS_CLOSE, |
---|
| 315 | ("There was an error displaying help: \n%s"), |
---|
| 316 | error->message); |
---|
| 317 | |
---|
| 318 | g_signal_connect (G_OBJECT (dialog), "response", |
---|
| 319 | G_CALLBACK (gtk_widget_destroy), |
---|
| 320 | NULL); |
---|
| 321 | |
---|
| 322 | gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); |
---|
| 323 | gtk_widget_show (dialog); |
---|
| 324 | g_error_free (error); |
---|
| 325 | } |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | static void |
---|
| 329 | about_menu_cb (BonoboUIComponent *uic, gpointer data, const char *cname) |
---|
| 330 | { |
---|
| 331 | static GtkWidget *about = NULL; |
---|
| 332 | static gchar *authors[] = { |
---|
| 333 | "Jacob Berkman <jacob@ximian.com>", |
---|
| 334 | "Jonathan Blandford <jrb@redhat.com>", |
---|
| 335 | "Chema Celorio <chema@ximian.com>", |
---|
| 336 | "Rachel Hestilow <hestilow@ximian.com>", |
---|
| 337 | "Bradford Hovinen <hovinen@ximian.com>", |
---|
| 338 | "Lauris Kaplinski <lauris@ximian.com>", |
---|
| 339 | "Seth Nickell <snickell@stanford.edu>", |
---|
| 340 | "Jakub Steiner <jimmac@ximian.com>", |
---|
| 341 | NULL |
---|
| 342 | }; |
---|
| 343 | |
---|
| 344 | static gchar *documenters[] = { |
---|
| 345 | NULL |
---|
| 346 | }; |
---|
| 347 | |
---|
| 348 | gchar *translator_credits = _("translator_credits"); |
---|
| 349 | |
---|
| 350 | if (about != NULL) { |
---|
| 351 | gdk_window_show (about->window); |
---|
| 352 | gdk_window_raise (about->window); |
---|
| 353 | return; |
---|
| 354 | } |
---|
| 355 | |
---|
| 356 | about = gnome_about_new |
---|
| 357 | (_("GNOME Control Center"), VERSION, |
---|
| 358 | "Copyright (C) 2000, 2001 Ximian, Inc.\n" |
---|
| 359 | "Copyright (C) 1999 Red Hat Software, Inc.", |
---|
| 360 | _("Desktop properties manager."), |
---|
| 361 | (const gchar **) authors, |
---|
| 362 | (const gchar **) documenters, |
---|
| 363 | strcmp (translator_credits, "translator_credits") != 0 ? translator_credits : NULL, |
---|
| 364 | NULL); |
---|
| 365 | |
---|
| 366 | g_signal_connect (G_OBJECT (about), "destroy", |
---|
| 367 | (GCallback) gtk_widget_destroyed, |
---|
| 368 | &about); |
---|
| 369 | |
---|
| 370 | gtk_widget_show (about); |
---|
| 371 | } |
---|
| 372 | |
---|
| 373 | #if 0 |
---|
| 374 | |
---|
| 375 | static void |
---|
| 376 | menu_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout) |
---|
| 377 | { |
---|
| 378 | if (!GTK_CHECK_MENU_ITEM (w)->active || view->changing_layout) |
---|
| 379 | return; |
---|
| 380 | |
---|
| 381 | gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL); |
---|
| 382 | } |
---|
| 383 | |
---|
| 384 | #endif |
---|
| 385 | |
---|
| 386 | #ifdef USE_HTML |
---|
| 387 | static void |
---|
| 388 | html_menu_cb (GtkWidget *w, CappletDirView *view) |
---|
| 389 | { |
---|
| 390 | menu_cb (w, view, LAYOUT_HTML); |
---|
| 391 | } |
---|
| 392 | #endif |
---|
| 393 | |
---|
| 394 | #if 0 |
---|
| 395 | |
---|
| 396 | static void |
---|
| 397 | icon_menu_cb (GtkWidget *w, CappletDirView *view) |
---|
| 398 | { |
---|
| 399 | menu_cb (w, view, LAYOUT_ICON_LIST); |
---|
| 400 | } |
---|
| 401 | |
---|
| 402 | static void |
---|
| 403 | tree_menu_cb (GtkWidget *w, CappletDirView *view) |
---|
| 404 | { |
---|
| 405 | menu_cb (w, view, LAYOUT_TREE); |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | static void |
---|
| 409 | button_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout) |
---|
| 410 | { |
---|
| 411 | if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)) || view->changing_layout) |
---|
| 412 | return; |
---|
| 413 | |
---|
| 414 | gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL); |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | #endif |
---|
| 418 | |
---|
| 419 | #ifdef USE_HTML |
---|
| 420 | static void |
---|
| 421 | html_toggle_cb (GtkWidget *w, CappletDirView *view) |
---|
| 422 | { |
---|
| 423 | button_cb (w, view, LAYOUT_HTML); |
---|
| 424 | } |
---|
| 425 | #endif |
---|
| 426 | |
---|
| 427 | #if 0 |
---|
| 428 | |
---|
| 429 | static void |
---|
| 430 | list_toggle_cb (GtkWidget *w, CappletDirView *view) |
---|
| 431 | { |
---|
| 432 | button_cb (w, view, LAYOUT_ICON_LIST); |
---|
| 433 | } |
---|
| 434 | |
---|
| 435 | static void |
---|
| 436 | tree_toggle_cb (GtkWidget *w, CappletDirView *view) |
---|
| 437 | { |
---|
| 438 | button_cb (w, view, LAYOUT_TREE); |
---|
| 439 | } |
---|
| 440 | |
---|
| 441 | #if 0 |
---|
| 442 | static void |
---|
| 443 | prefs_menu_cb (GtkWidget *widget, CappletDirView *view) |
---|
| 444 | { |
---|
| 445 | gnomecc_preferences_get_config_dialog (prefs); |
---|
| 446 | } |
---|
| 447 | #endif |
---|
| 448 | |
---|
| 449 | static void |
---|
| 450 | back_button_cb (GtkWidget *widget, CappletDirView *view) |
---|
| 451 | { |
---|
| 452 | if (CAPPLET_DIR_ENTRY (view->capplet_dir)->dir) |
---|
| 453 | capplet_dir_view_load_dir |
---|
| 454 | (view, CAPPLET_DIR_ENTRY (view->capplet_dir)->dir); |
---|
| 455 | } |
---|
| 456 | |
---|
| 457 | static void |
---|
| 458 | rootm_button_cb (GtkWidget *w, CappletDirView *view) |
---|
| 459 | { |
---|
| 460 | gdk_beep (); |
---|
| 461 | } |
---|
| 462 | |
---|
| 463 | #endif |
---|
| 464 | |
---|
| 465 | static void |
---|
| 466 | option_menu_activate (GtkWidget *w, CappletDirEntry *entry) |
---|
| 467 | { |
---|
| 468 | CappletDirView *view; |
---|
| 469 | |
---|
| 470 | view = g_object_get_data (G_OBJECT (w), "user_data"); |
---|
| 471 | if (!IS_CAPPLET_DIR_VIEW (view)) |
---|
| 472 | return; |
---|
| 473 | |
---|
| 474 | capplet_dir_entry_activate (entry, view); |
---|
| 475 | } |
---|
| 476 | |
---|
| 477 | void |
---|
| 478 | capplet_dir_view_load_dir (CappletDirView *view, CappletDir *dir) |
---|
| 479 | { |
---|
| 480 | GtkWidget *menu, *menuitem, *w, *hbox; |
---|
| 481 | CappletDirEntry *entry; |
---|
| 482 | int parents = 0; |
---|
| 483 | gchar *title; |
---|
| 484 | |
---|
| 485 | g_return_if_fail (view != NULL); |
---|
| 486 | g_return_if_fail (IS_CAPPLET_DIR_VIEW (view)); |
---|
| 487 | |
---|
| 488 | view->capplet_dir = dir; |
---|
| 489 | |
---|
| 490 | if (view->impl && view->impl->clear) |
---|
| 491 | view->impl->clear (view); |
---|
| 492 | |
---|
| 493 | if (!dir || view->layout == LAYOUT_NONE) return; |
---|
| 494 | |
---|
| 495 | if (view->impl && view->impl->populate) |
---|
| 496 | view->impl->populate (view); |
---|
| 497 | |
---|
| 498 | title = g_strdup_printf (_("Gnome Control Center : %s"), dir->entry.label); |
---|
| 499 | gtk_window_set_title (GTK_WINDOW (view->app), title); |
---|
| 500 | g_free (title); |
---|
| 501 | |
---|
| 502 | menu = gtk_menu_new (); |
---|
| 503 | |
---|
| 504 | for (entry = CAPPLET_DIR_ENTRY (dir); entry; entry = CAPPLET_DIR_ENTRY (entry->dir), parents++) { |
---|
[20937] | 505 | GdkPixbuf *pbs; |
---|
[18373] | 506 | |
---|
| 507 | menuitem = gtk_menu_item_new (); |
---|
| 508 | hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); |
---|
| 509 | |
---|
| 510 | #if 0 |
---|
| 511 | w = gnome_pixmap_new_from_file_at_size (entry->icon, 16, 16); |
---|
| 512 | #else |
---|
[20937] | 513 | pbs = gdk_pixbuf_scale_simple (entry->icon, 16, 16, GDK_INTERP_HYPER); |
---|
| 514 | w = gtk_image_new_from_pixbuf (pbs); |
---|
[18373] | 515 | g_object_unref (pbs); |
---|
| 516 | #endif |
---|
| 517 | gtk_box_pack_start (GTK_BOX (hbox), w, |
---|
| 518 | FALSE, FALSE, 0); |
---|
| 519 | |
---|
| 520 | w = gtk_label_new (entry->label); |
---|
| 521 | gtk_box_pack_start (GTK_BOX (hbox), w, |
---|
| 522 | FALSE, FALSE, 0); |
---|
| 523 | |
---|
| 524 | gtk_container_add (GTK_CONTAINER (menuitem), hbox); |
---|
| 525 | |
---|
| 526 | if (entry != CAPPLET_DIR_ENTRY (dir)) { |
---|
| 527 | g_object_set_data (G_OBJECT (menuitem), "user_data", view); |
---|
| 528 | g_signal_connect (G_OBJECT (menuitem), "activate", |
---|
| 529 | (GCallback) option_menu_activate, |
---|
| 530 | entry); |
---|
| 531 | } |
---|
| 532 | |
---|
| 533 | gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem); |
---|
| 534 | } |
---|
| 535 | gtk_widget_show_all (menu); |
---|
| 536 | } |
---|
| 537 | |
---|
| 538 | void |
---|
| 539 | capplet_dir_view_show (CappletDirView *view) |
---|
| 540 | { |
---|
| 541 | g_return_if_fail (view != NULL); |
---|
| 542 | g_return_if_fail (IS_CAPPLET_DIR_VIEW (view)); |
---|
| 543 | |
---|
| 544 | gtk_widget_show (GTK_WIDGET (CAPPLET_DIR_VIEW_W (view))); |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | static CappletDirView * |
---|
| 548 | get_capplet_dir_view (CappletDir *dir, CappletDirView *launcher) |
---|
| 549 | { |
---|
| 550 | if (launcher) |
---|
| 551 | return launcher; |
---|
| 552 | else |
---|
| 553 | return CAPPLET_DIR_VIEW (capplet_dir_view_new ()); |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | void |
---|
| 557 | gnomecc_init (void) |
---|
| 558 | { |
---|
| 559 | capplet_dir_init (get_capplet_dir_view); |
---|
| 560 | } |
---|