[473884]: src / main.c Maximize Restore History

Download this file

main.c    780 lines (710 with data), 22.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
/*
rox-media (Media) - DeviceKit-disks utility for ROX
Copyright (C) 2009 Tony Houghton <h@realh.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include <gdu/gdu.h>
#include <gdk/gdk.h>
#include <gconf/gconf-client.h>
#include "appdir.h"
#include "dialog.h"
#include "i18n.h"
#include "icon_group.h"
#include "icon_source_emblem.h"
#include "icon_source_filename.h"
#include "icon_source_gicon.h"
#include "panel_icon.h"
typedef struct {
IconGroup *group;
GdkScreen *screen;
HPanelIcon *main_icon;
gboolean systray;
GduPool *pool;
//GList *added_devices;
} RoxMedia;
typedef struct _AddedDeviceData AddedDeviceData;
typedef struct _OpticalDriveData OpticalDriveData;
typedef enum {
EMBLEM_NONE,
EMBLEM_MOUNTED,
EMBLEM_MOUNTING
} EmblemStatus;
struct _AddedDeviceData {
RoxMedia *media;
/* NB presentable and dev are apparently invalid
* during "changed" and "removed" signals
*/
GduPresentable *presentable;
GduDevice *dev;
HPanelIcon *panel_icon;
gulong removed_tag, changed_tag;
OpticalDriveData *odd;
HIconSourceEmblem *icon_source;
gboolean mounting;
EmblemStatus emblem_status;
GtkWidget *menu;
gboolean open_when_mounted;
};
struct _OpticalDriveData {
AddedDeviceData *disc_add;
GduDevice *dev;
gulong removed_tag, changed_tag;
};
static gboolean starting_up = TRUE;
static void
close_menu(AddedDeviceData *add)
{
if (add->menu)
{
gtk_widget_destroy(add->menu);
add->menu = NULL;
}
}
static void
set_tooltip(AddedDeviceData *add)
{
char *devmount;
char *tooltip;
GduDevice *dev = add->dev;
const char *label = NULL;
char *pres_name = gdu_presentable_get_name(add->presentable);
if (gdu_device_is_mounted(dev))
{
devmount = g_strdup_printf(_("<b>%s</b> mounted at %s"),
gdu_device_get_device_file(dev),
gdu_device_get_mount_path(dev));
}
else
{
devmount = g_strdup_printf(_("<b>%s</b>"),
gdu_device_get_device_file(dev));
}
if (gdu_device_is_partition(dev))
label = gdu_device_partition_get_label(dev);
if (label && label[0])
tooltip = g_strdup_printf("%s\n'%s'\n%s", devmount, label, pres_name);
else
tooltip = g_strdup_printf("%s\n%s", devmount, pres_name);
g_free(devmount);
g_free(pres_name);
h_panel_icon_set_tooltip_markup(add->panel_icon, tooltip);
g_free(tooltip);
}
static void
disconnect_odd_handlers(OpticalDriveData *odd)
{
if (odd->removed_tag)
{
g_signal_handler_disconnect(odd->dev, odd->removed_tag);
odd->removed_tag = 0;
}
if (odd->changed_tag)
{
g_signal_handler_disconnect(odd->dev, odd->changed_tag);
odd->changed_tag = 0;
}
}
static void
device_removed(GduDevice *dev, AddedDeviceData *add)
{
OpticalDriveData *odd = add->odd;
if (add->removed_tag)
{
g_signal_handler_disconnect(dev, add->removed_tag);
add->removed_tag = 0;
}
if (add->changed_tag)
{
g_signal_handler_disconnect(dev, add->changed_tag);
add->changed_tag = 0;
}
if (odd)
{
disconnect_odd_handlers(odd);
if (odd->dev)
{
g_object_unref(odd->dev);
odd->dev = NULL;
}
g_free(odd);
}
close_menu(add);
//add->media->added_devices = g_list_remove(add->media->added_devices, add);
h_panel_icon_destroy(add->panel_icon);
/* This wil also destroy its HIconSource */
g_free(add);
}
static void
show_mount_status(AddedDeviceData *add)
{
static GdkPixbuf *mounted_emblem = NULL;
static GdkPixbuf *mounting_emblem = NULL;
GdkPixbuf **emblem;
const char *leafname;
EmblemStatus status;
if (add->mounting)
{
emblem = &mounting_emblem;
leafname = "mounting.png";
status = EMBLEM_MOUNTING;
}
else if (gdu_device_is_mounted(add->dev))
{
emblem = &mounted_emblem;
leafname = "mounted.png";
status = EMBLEM_MOUNTED;
}
else
{
emblem = NULL;
leafname = NULL;
status = EMBLEM_NONE;
}
if (status == add->emblem_status)
return;
add->emblem_status = status;
if (emblem)
{
if (!*emblem)
{
GError *error = NULL;
char *emblem_file = appdir_get_image(leafname);
*emblem = gdk_pixbuf_new_from_file(emblem_file, &error);
if (!*emblem)
{
g_warning(_("Unable to load emblem file '%s': %s"),
emblem_file, error->message);
g_error_free(error);
}
}
if (*emblem)
h_icon_source_emblem_set_emblem(add->icon_source, *emblem);
}
h_icon_source_emblem_set_show_emblem(add->icon_source,
status != EMBLEM_NONE);
}
static void
device_changed(GduDevice *dev, AddedDeviceData *add)
{
if (gdu_device_is_optical_disc(dev) && !gdu_device_is_media_available(dev))
{
device_removed(dev, add);
return;
}
close_menu(add);
show_mount_status(add);
}
static void
parent_removed(GduDevice *dev, OpticalDriveData *odd)
{
if (!gdu_device_is_media_available(dev))
{
AddedDeviceData *add = odd->disc_add;
disconnect_odd_handlers(odd);
/* I think dev gets unrefed automatically */
g_free(odd);
add->odd = NULL;
device_removed(add->dev, add);
}
}
static void
parent_changed(GduDevice *dev, OpticalDriveData *odd)
{
if (!gdu_device_is_media_available(dev))
{
device_removed(odd->disc_add->dev, odd->disc_add);
}
}
static void
mount_complete(GduDevice *device, char *mount_point,
GError *error, AddedDeviceData *add)
{
add->mounting = FALSE;
show_mount_status(add);
close_menu(add);
if (error)
{
dialog_error(icon_group_get_window(add->media->group), 0,
_("Unable to mount %s: %s"),
gdu_device_get_device_file(add->dev), error->message);
/* FIXME: Are we supposed to free this error? */
return;
}
if (add->open_when_mounted)
{
char *args[3];
GError *err = NULL;
add->open_when_mounted = FALSE;
args[0] = "rox";
args[1] = mount_point;
args[2] = NULL;
if (!g_spawn_async(NULL, args, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, &err))
{
dialog_error(icon_group_get_window(add->media->group), 0,
_("Unable to run rox to view mount point '%s': %s"),
mount_point, error->message);
g_error_free(error);
}
}
}
static void
unmount_complete(GduDevice *device, GError *error, AddedDeviceData *add)
{
if (error)
{
dialog_error(icon_group_get_window(add->media->group), 0,
_("Unable to mount %s: %s"),
gdu_device_get_device_file(add->dev), error->message);
/* FIXME: Are we supposed to free this error? */
}
add->mounting = FALSE;
show_mount_status(add);
close_menu(add);
}
static char **get_mount_options(AddedDeviceData *add, const char *ptype)
{
char *key = g_strdup_printf(
"/system/storage/default_options/%s/mount_options", ptype);
GError *error = NULL;
GSList *list = gconf_client_get_list(gconf_client_get_default(),
key, GCONF_VALUE_STRING, &error);
char **options;
guint n;
GSList *link;
if (error)
{
dialog_error(icon_group_get_window(add->media->group), 0,
_("GConf error looking up mount options for %s: %s"),
ptype, error->message);
g_error_free(error);
return NULL;
}
if (!list)
return NULL;
n = g_slist_length(list);
options = g_new(char *, n + 1);
for (n = 0, link = list; link; link = g_slist_next(link))
{
char *o = link->data;
/* uid and gid get set anyway */
if (g_str_has_prefix(o, "uid="))
{
// options[n++] = g_strdup_printf("uid=%d", getuid());
g_free(o);
}
else if (g_str_has_prefix(o, "gid="))
{
// options[n++] = g_strdup_printf("gid=%d", getgid());
g_free(o);
}
else if (!strcmp(o, "locale="))
{
options[n++] = g_strdup_printf("locale=%s",
setlocale(LC_ALL, NULL));
g_free(o);
}
else if (o[strlen(o) - 1] == '=')
{
dialog_warning(icon_group_get_window(add->media->group), 0,
_("Unknown mount option for %s: %s"), ptype, o);
g_free(o);
}
else
{
options[n++] = o;
}
}
options[n] = NULL;
g_slist_free(list);
return options;
}
static void
mount_clicked(AddedDeviceData *add, gpointer widget)
{
const char *ptype;
char **options = NULL;
ptype = gdu_device_id_get_type(add->dev);
if (ptype)
{
g_debug("Getting mount options for '%s'", ptype);
options = get_mount_options(add, ptype);
}
add->mounting = TRUE;
gdu_device_op_filesystem_mount(add->dev, options,
(GduDeviceFilesystemMountCompletedFunc) mount_complete,
add);
show_mount_status(add);
g_strfreev(options);
}
static void
unmount_clicked(AddedDeviceData *add, gpointer widget)
{
add->mounting = TRUE;
show_mount_status(add);
gdu_device_op_filesystem_unmount(add->dev,
(GduDeviceFilesystemUnmountCompletedFunc) unmount_complete, add);
}
static void
eject_clicked(AddedDeviceData *add, gpointer widget)
{
GduDevice *dev;
add->mounting = TRUE;
show_mount_status(add);
if (gdu_device_drive_get_is_media_ejectable(add->dev))
{
dev = add->dev;
}
else if (add->odd && gdu_device_drive_get_is_media_ejectable(add->odd->dev))
{
dev = add->odd->dev;
}
else
{
dialog_error(icon_group_get_window(add->media->group), 0,
_("Device %s somehow lost its ability to eject, "
"attempting just to unmount it."),
gdu_device_get_device_file(add->dev));
gdu_device_op_filesystem_unmount(add->dev,
(GduDeviceFilesystemUnmountCompletedFunc) unmount_complete,
add);
return;
}
gdu_device_op_drive_eject(dev,
(GduDeviceDriveEjectCompletedFunc) unmount_complete, add);
}
static void
menu_destroyed(AddedDeviceData *add, GtkWidget *menu)
{
add->menu = NULL;
}
static void
popup_device_menu(AddedDeviceData *add, guint button, guint32 activate_time)
{
gboolean mounted = gdu_device_is_mounted(add->dev);
GtkWidget *menu = gtk_menu_new();
GtkWidget *item = gtk_menu_item_new_with_label(
mounted ? _("Unmount") : _("Mount"));
g_signal_connect_swapped(item, "activate",
G_CALLBACK(mounted ? unmount_clicked : mount_clicked), add);
gtk_widget_set_sensitive(item, !add->mounting);
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
item = gtk_menu_item_new_with_label(_("Eject"));
if (gdu_device_drive_get_is_media_ejectable(add->dev) ||
(add->odd &&
gdu_device_drive_get_is_media_ejectable(add->odd->dev)))
{
gtk_widget_set_sensitive(item, TRUE);
g_signal_connect_swapped(item, "activate",
G_CALLBACK(eject_clicked), add);
}
else
{
gtk_widget_set_sensitive(item, FALSE);
}
gtk_widget_show(item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
g_signal_connect_swapped(menu, "destroy", G_CALLBACK(menu_destroyed), add);
add->menu = menu;
gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
h_panel_icon_get_menu_position_func(add->panel_icon),
add->panel_icon, button, activate_time);
}
static gboolean
device_click_handler(HPanelIcon *icon, GdkEventButton *event,
AddedDeviceData *add)
{
if (event->type == GDK_BUTTON_PRESS)
{
if (event->button == 1 && !add->mounting)
{
add->open_when_mounted = TRUE;
mount_clicked(add, icon);
return TRUE;
}
else if (event->button == 3)
{
popup_device_menu(add, event->button, event->time);
return TRUE;
}
}
return FALSE;
}
static void confirm_add_device(AddedDeviceData *add)
{
GIcon *gicon;
gicon = gdu_presentable_get_icon(add->presentable);
add->icon_source = h_icon_source_emblem_new(
H_ICON_SOURCE(h_icon_source_gicon_new(add->media->screen,
gicon)), NULL);
show_mount_status(add);
add->panel_icon = icon_group_add_icon(add->media->group,
H_ICON_SOURCE(add->icon_source));
g_signal_connect(add->panel_icon, "button-press-event",
G_CALLBACK(device_click_handler), add);
g_object_unref(gicon);
//add->media->added_devices = g_list_append(add->media->added_devices, add);
add->removed_tag = g_signal_connect(add->dev, "removed",
G_CALLBACK(device_removed), add);
add->changed_tag = g_signal_connect(add->dev, "changed",
G_CALLBACK(device_changed), add);
set_tooltip(add);
}
static gboolean
post_device_added(AddedDeviceData *add)
{
GList *presentables = gdu_pool_get_enclosed_presentables(
add->media->pool, add->presentable);
GList *link;
if (presentables)
{
for (link = presentables; link; link = g_list_next(link))
g_object_unref(link->data);
g_list_free(presentables);
g_object_unref(add->dev);
g_free(add);
}
else
{
confirm_add_device(add);
if (gdu_device_is_optical_disc(add->dev))
{
/* Don't seem to get "removed" signals on optical discs
* so use parent drives to keep track of them.
*/
OpticalDriveData *odd =
add->odd = g_new(OpticalDriveData, 1);
GduPresentable *tl_pres =
gdu_presentable_get_toplevel(add->presentable);
GduDevice *tl_dev = odd->dev = gdu_presentable_get_device(tl_pres);
odd->disc_add = add;
odd->removed_tag = g_signal_connect(tl_dev, "removed",
G_CALLBACK(parent_removed), odd);
odd->changed_tag = g_signal_connect(tl_dev, "changed",
G_CALLBACK(parent_changed), odd);
g_object_unref(tl_pres);
}
}
return FALSE;
}
static void
check_add_presentable(GduPool *pool, GduPresentable *presentable,
RoxMedia *media)
{
GduDevice *dev = gdu_presentable_get_device(presentable);
gboolean interesting = FALSE;
if (!dev)
{
return;
}
if (gdu_device_is_optical_disc(dev) && gdu_device_is_media_available(dev))
{
interesting = TRUE;
}
else if (gdu_device_is_partition(dev))
{
if (gdu_device_is_removable(dev))
{
interesting = TRUE;
}
else
{
/* Partitions aren't flagged removable, so check top level drive */
GduPresentable *top_level =
gdu_presentable_get_toplevel(presentable);
GduDevice *tl_dev = gdu_presentable_get_device(top_level);
interesting = gdu_device_is_removable(tl_dev);
g_object_unref(tl_dev);
g_object_unref(top_level);
}
}
if (interesting)
{
/* Might be an extended partition containing others, or an optical
* drive containing media (the media returns TRUE for is_drive :-(),
* but if it's only just been added pool might not be aware of its
* children yet so wait until idle. */
AddedDeviceData *add = g_new(AddedDeviceData, 1);
add->media = media;
add->presentable = presentable;
add->dev = dev;
add->panel_icon = NULL;
add->odd = NULL;
add->mounting = FALSE;
add->emblem_status = EMBLEM_NONE;
add->menu = NULL;
add->open_when_mounted = FALSE;
if (starting_up)
post_device_added(add);
else
g_idle_add((GSourceFunc) post_device_added, add);
}
else
{
g_object_unref(dev);
}
}
static void
popup_main_menu(RoxMedia *media, HPanelIcon *icon,
guint button, guint evtime)
{
GtkWidget *menu = gtk_menu_new();
GtkMenuShell *shell = GTK_MENU_SHELL(menu);
GtkWidget *item;
item = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
g_signal_connect(item, "activate", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show(item);
gtk_menu_shell_append(shell, item);
if (!media->systray)
gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(icon), NULL);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
h_panel_icon_get_menu_position_func(icon),
icon, button, evtime);
}
static gboolean
main_icon_click_handler(HPanelIcon *icon,
GdkEventButton *event, RoxMedia *media)
{
if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
{
popup_main_menu(media, icon, event->button, event->time);
return TRUE;
}
return FALSE;
}
static void
main_icon_rox_popup_handler(HPanelIcon *icon, RoxMedia *media)
{
popup_main_menu(media, icon, 0, gtk_get_current_event_time());
}
static void
main_icon_systray_popup_handler(HPanelIcon *icon,
guint button, guint evtime, RoxMedia *media)
{
popup_main_menu(media, icon, button, evtime);
}
static void
init_group(IconGroup *group, gboolean systray)
{
RoxMedia *media = g_new(RoxMedia, 1);
GList *presentables, *link;
GduPool *pool;
media->group = group;
media->main_icon = icon_group_add_icon(group,
H_ICON_SOURCE(h_icon_source_filename_new(appdir_get_app_icon())));
media->systray = systray;
if (systray)
{
if (!gtk_status_icon_get_geometry(GTK_STATUS_ICON(media->main_icon),
&media->screen, NULL, NULL))
{
media->screen = gdk_screen_get_default();
}
}
else
{
media->screen = gtk_widget_get_screen(GTK_WIDGET(media->main_icon));
if (!media->screen)
media->screen = gdk_screen_get_default();
}
//media->added_devices = NULL;
g_signal_connect(media->main_icon, "button-press-event",
G_CALLBACK(main_icon_click_handler), media);
g_signal_connect(media->main_icon, "popup-menu",
systray ? G_CALLBACK(main_icon_systray_popup_handler) :
G_CALLBACK(main_icon_rox_popup_handler),
media);
pool = media->pool = gdu_pool_new();
presentables = gdu_pool_get_presentables(pool);
for (link = presentables; link; link = g_list_next(link))
check_add_presentable(pool, GDU_PRESENTABLE(link->data), media);
g_list_free(presentables);
g_signal_connect(pool, "presentable-added",
G_CALLBACK(check_add_presentable), media);
icon_group_show(group);
}
static char *pidfile = NULL;
static void
remove_pidfile(void)
{
g_unlink(pidfile);
}
int
main(int argc, char **argv)
{
int panel_id = -1;
IconGroup *group;
GError *error = NULL;
GOptionEntry entries[] = {
{ "appdir", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME,
&appdir, NULL, NULL },
{ "panel-id", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_INT,
&panel_id, NULL, NULL },
{ "pidfile", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME,
&pidfile, NULL, NULL },
{ NULL }
};
GOptionContext *context;
FILE *fp;
gtk_init(&argc, &argv);
context = g_option_context_new(N_(" - removable media handler for ROX"));
g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
g_option_context_add_group(context, gtk_get_option_group(TRUE));
if (!g_option_context_parse (context, &argc, &argv, &error))
{
(void) dialog_error(NULL, 0,
_("Error parsing command line options: %s"), error->message);
exit(1);
}
if (!pidfile)
{
(void) dialog_error(NULL, 0, _("pidfile not specified. "
"Perhaps you tried to run rox-media's binary directly "
"instead of via its script."));
exit(1);
}
fp = fopen(pidfile, "w");
if (fp)
{
fprintf(fp, "%d", getpid());
fclose(fp);
atexit(remove_pidfile);
}
else
{
(void) dialog_error(NULL, 0, _("Unable to create pidfile %s: %s."),
pidfile, strerror(errno));
exit(1);
}
if (panel_id != -1)
group = icon_group_new_for_rox_panel(panel_id);
else
group = icon_group_new_for_systray();
init_group(group, panel_id == -1);
starting_up = FALSE;
/* Maybe if we split the showing of the plug and its children it will
* stop the ROX crashes?
*/
g_idle_add((GSourceFunc) icon_group_show_all, group);
gtk_main();
return 0;
}