~ubuntu-branches/ubuntu/oneiric/xpad/oneiric

« back to all changes in this revision

Viewing changes to src/xpad-app.c

  • Committer: Bazaar Package Importer
  • Author(s): Bart Martens
  • Date: 2007-12-10 22:52:37 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071210225237-llvwje5iwbbi5adw
Tags: 2.13-1
* New upstream release.
* debian/patches/01_workspaces.diff: Removed.
* debian/menu: Updated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * Copyright (c) 2004-2005 Michael Terry
 
2
 * Copyright (c) 2004-2007 Michael Terry
3
3
 * 
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
74
74
static FILE *output;
75
75
static gboolean xpad_translucent = FALSE;
76
76
static XpadPadGroup *pad_group;
 
77
static gint pads_loaded_on_start = 0;
77
78
 
78
79
static gboolean  process_local_args         (gint *argc, gchar **argv[]);
79
80
static gboolean  process_remote_args        (gint *argc, gchar **argv[], gboolean have_gtk);
82
83
static gchar    *make_config_dir            (void);
83
84
static void      register_stock_icons       (void);
84
85
static gint      xpad_app_load_pads         (void);
85
 
static void      xpad_app_quit_if_no_pads   (XpadPadGroup *group);
 
86
static gboolean  xpad_app_quit_if_no_pads   (XpadPadGroup *group);
 
87
static gboolean  xpad_app_first_idle_check  (XpadPadGroup *group);
86
88
static gboolean  xpad_app_pass_args         (void);
87
89
static gboolean  xpad_app_open_proc_file    (void);
88
90
 
165
167
        xpad_session_manager_init ();
166
168
        
167
169
        /* load all pads */
168
 
        if (xpad_app_load_pads () == 0 && !option_new) {
 
170
        pads_loaded_on_start = xpad_app_load_pads ();
 
171
        if (pads_loaded_on_start == 0 && !option_new) {
169
172
                if (!option_nonew) {
170
173
                        GtkWidget *pad = xpad_pad_new (pad_group);
171
174
                        gtk_widget_show (pad);
172
175
                }
173
176
        }
174
177
        
175
 
        xpad_app_quit_if_no_pads (pad_group);
 
178
        g_idle_add ((GSourceFunc)xpad_app_first_idle_check, pad_group);
176
179
        
177
180
        if (first_time)
178
181
                show_help ();
381
384
}
382
385
 
383
386
 
384
 
static void
 
387
static gboolean
385
388
xpad_app_quit_if_no_pads (XpadPadGroup *group)
386
389
{
387
390
        if (!xpad_tray_is_open ())
388
391
        {
389
 
                GSList *list, *i;
390
 
                list = xpad_pad_group_get_pads (group);
391
 
                for (i = list; i; i = i->next)
392
 
                {
393
 
                        if (GTK_WIDGET_VISIBLE(GTK_WIDGET(i->data)))
394
 
                                break;
395
 
                }
396
 
                if (!i)
 
392
                gint num_pads = xpad_pad_group_num_visible_pads (group);
 
393
                if (num_pads == 0)
397
394
                {
398
395
                        if (gtk_main_level () > 0)
399
396
                                gtk_main_quit ();
400
397
                        else
401
398
                                exit (0);
402
399
                }
403
 
                g_slist_free (list);
404
 
        }
405
 
}
 
400
        }
 
401
        
 
402
        return FALSE;
 
403
}
 
404
 
 
405
static gboolean
 
406
xpad_app_first_idle_check (XpadPadGroup *group)
 
407
{
 
408
        /* We do this check at the first idle rather than immediately during
 
409
           start because we want to give the tray time to become embedded. */
 
410
        if (!xpad_tray_is_open () && pads_loaded_on_start > 0 &&
 
411
            xpad_pad_group_num_visible_pads (group) == 0)
 
412
        {
 
413
                /* So we loaded xpad, there's no tray, and there's only hidden
 
414
                   pads...  Probably previously had tray open but we failed
 
415
                   this time.  Show all pads as a last resort.  This shouldn't
 
416
                   happen in normal operation. */
 
417
                xpad_pad_group_show_all (group);
 
418
        }
 
419
        
 
420
        /* All future idle checks should be just for zero visible pads */
 
421
        g_idle_add ((GSourceFunc)xpad_app_quit_if_no_pads, group);
 
422
        
 
423
        return TRUE;
 
424
}
 
425
 
406
426
 
407
427
static void
408
428
xpad_app_pad_added (XpadPadGroup *group, XpadPad *pad)
443
463
                if (!strncmp (name, "info-", 5) &&
444
464
                    name[strlen (name) - 1] != '~')
445
465
                {
446
 
                        GtkWidget *pad = xpad_pad_new_with_info (pad_group, name);
447
 
                        if (!option_hide_old)
 
466
                        gboolean show = TRUE;
 
467
                        GtkWidget *pad = xpad_pad_new_with_info (pad_group, name, &show);
 
468
                        if (show && !option_hide_old)
448
469
                                gtk_widget_show (pad);
449
470
                        
450
471
                        opened ++;