View | Details | Raw Unified | Return to bug 230478
Collapse All | Expand All

(-)a/libslab/bookmark-agent.c (-88 / +102 lines)
Lines 121-129 static void set_rank (BookmarkAgent *, const gchar *, gint); Link Here
121
121
122
static void load_xbel_store          (BookmarkAgent *);
122
static void load_xbel_store          (BookmarkAgent *);
123
static void load_places_store        (BookmarkAgent *);
123
static void load_places_store        (BookmarkAgent *);
124
static void load_recent_store        (BookmarkAgent *);
125
static void update_user_spec_path    (BookmarkAgent *);
124
static void update_user_spec_path    (BookmarkAgent *);
126
static void update_recent_store_path (BookmarkAgent *);
127
static void save_xbel_store          (BookmarkAgent *);
125
static void save_xbel_store          (BookmarkAgent *);
128
static void create_app_item          (BookmarkAgent *, const gchar *);
126
static void create_app_item          (BookmarkAgent *, const gchar *);
129
static void create_doc_item          (BookmarkAgent *, const gchar *);
127
static void create_doc_item          (BookmarkAgent *, const gchar *);
Lines 321-326 bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris) Link Here
321
	save_store (this);
319
	save_store (this);
322
}
320
}
323
321
322
static GList *
323
make_items_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store)
324
{
325
	BookmarkAgentPrivate *priv = PRIVATE (this);
326
	gchar **uris;
327
	gint i;
328
	GList *items_ordered;
329
330
	if (!store)
331
		return NULL;
332
333
	uris = g_bookmark_file_get_uris (store, NULL);
334
	items_ordered = NULL;
335
336
	for (i = 0; uris && uris [i]; ++i) {
337
		gboolean include;
338
339
		if (priv->type == BOOKMARK_STORE_RECENT_APPS)
340
			include = g_bookmark_file_has_group (store, uris [i], "recently-used-apps", NULL);
341
		else
342
			include = ! g_bookmark_file_get_is_private (store, uris [i], NULL);
343
344
		if (include) {
345
			BookmarkItem *item;
346
347
			item = g_new0 (BookmarkItem, 1);
348
349
			item->uri       = g_strdup (uris [i]);
350
			item->mime_type = g_bookmark_file_get_mime_type (store, uris [i], NULL);
351
			item->mtime     = g_bookmark_file_get_modified  (store, uris [i], NULL);
352
353
			items_ordered = g_list_prepend (items_ordered, item);
354
		}
355
	}
356
357
	items_ordered = g_list_sort (items_ordered, recent_item_mru_comp_func);
358
359
	g_strfreev (uris);
360
361
	return items_ordered;
362
}
363
364
void
365
bookmark_agent_update_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store)
366
{
367
	BookmarkAgentPrivate *priv;
368
	GList *items_ordered;
369
	GList  *node;
370
371
	g_return_if_fail (IS_BOOKMARK_AGENT (this));
372
373
	priv = PRIVATE (this);
374
375
	libslab_checkpoint ("bookmark_agent_update_from_bookmark_file(): start updating");
376
377
	items_ordered = make_items_from_bookmark_file (this, store);
378
379
	g_bookmark_file_free (priv->store);
380
	priv->store = g_bookmark_file_new ();
381
382
	for (node = items_ordered; node; node = node->next) {
383
		BookmarkItem *item;
384
385
		item = (BookmarkItem *) node->data;
386
387
		g_bookmark_file_set_mime_type (priv->store, item->uri, item->mime_type);
388
		g_bookmark_file_set_modified  (priv->store, item->uri, item->mtime);
389
390
		bookmark_item_free (item);
391
	}
392
393
	g_list_free (items_ordered);
394
395
	libslab_checkpoint ("bookmark_agent_update_from_bookmark_file(): updating internal items");
396
	update_items (this);
397
398
	libslab_checkpoint ("bookmark_agent_update_from_bookmark_file(): end updating");
399
}
400
324
void
401
void
325
bookmark_item_free (BookmarkItem *item)
402
bookmark_item_free (BookmarkItem *item)
326
{
403
{
Lines 465-477 bookmark_agent_new (BookmarkStoreType type) Link Here
465
			priv->store_path = g_build_filename (g_get_home_dir (), ".recently-used", NULL);
542
			priv->store_path = g_build_filename (g_get_home_dir (), ".recently-used", NULL);
466
#endif
543
#endif
467
544
468
			gnome_vfs_monitor_add (
469
				& priv->store_monitor, priv->store_path,
470
				GNOME_VFS_MONITOR_FILE, store_monitor_cb, this);
471
472
			priv->update_path = update_recent_store_path;
473
			priv->load_store  = load_recent_store;
474
475
			break;
545
			break;
476
546
477
		case BOOKMARK_STORE_SYSTEM:
547
		case BOOKMARK_STORE_SYSTEM:
Lines 572-579 update_agent (BookmarkAgent *this) Link Here
572
{
642
{
573
	BookmarkAgentPrivate *priv = PRIVATE (this);
643
	BookmarkAgentPrivate *priv = PRIVATE (this);
574
644
575
	priv->update_path (this);
645
	if (priv->update_path)
576
	priv->load_store  (this);
646
		priv->update_path (this);
647
648
	if (priv->load_store)
649
		priv->load_store (this);
577
650
578
	update_items (this);
651
	update_items (this);
579
}
652
}
Lines 665-671 update_items (BookmarkAgent *this) Link Here
665
			g_bookmark_file_get_icon (priv->store, uris_ordered [i], & priv->items [i]->icon, NULL, NULL);
738
			g_bookmark_file_get_icon (priv->store, uris_ordered [i], & priv->items [i]->icon, NULL, NULL);
666
		}
739
		}
667
740
668
		g_object_notify (G_OBJECT (this), BOOKMARK_AGENT_ITEMS_PROP);
741
		/* Since the bookmark store for recently-used items is updated by the caller of BookmarkAgent,
742
		 * we don't emit notifications in that case.  The caller will know when to update itself.
743
		 */
744
		if (!TYPE_IS_RECENT (priv->type))
745
			g_object_notify (G_OBJECT (this), BOOKMARK_AGENT_ITEMS_PROP);
669
	}
746
	}
670
747
671
	if (store_corrupted)
748
	if (store_corrupted)
Lines 766-774 load_xbel_store (BookmarkAgent *this) Link Here
766
	GError *error = NULL;
843
	GError *error = NULL;
767
844
768
	gint i;
845
	gint i;
846
	gboolean success;
769
847
848
	if (!priv->store_path)
849
		success = FALSE;
850
	else {
851
		libslab_checkpoint ("load_xbel_store(): start loading %s", priv->store_path);
852
		success = g_bookmark_file_load_from_file (priv->store, priv->store_path, & error);
853
		libslab_checkpoint ("load_xbel_store(): end loading %s", priv->store_path);
854
	}
770
855
771
	if (! (priv->store_path && g_bookmark_file_load_from_file (priv->store, priv->store_path, & error))) {
856
	if (!success) {
772
		g_bookmark_file_free (priv->store);
857
		g_bookmark_file_free (priv->store);
773
		priv->store = g_bookmark_file_new ();
858
		priv->store = g_bookmark_file_new ();
774
859
Lines 779-788 load_xbel_store (BookmarkAgent *this) Link Here
779
		return;
864
		return;
780
	}
865
	}
781
866
867
	libslab_checkpoint ("load_xbel_store(): start creating items from %s", priv->store_path);
868
782
	uris = g_bookmark_file_get_uris (priv->store, NULL);
869
	uris = g_bookmark_file_get_uris (priv->store, NULL);
783
870
784
	for (i = 0; uris && uris [i]; ++i)
871
	for (i = 0; uris && uris [i]; ++i)
785
		priv->create_item (this, uris [i]);
872
		priv->create_item (this, uris [i]);
873
874
	libslab_checkpoint ("load_xbel_store(): end creating items from %s", priv->store_path);
786
}
875
}
787
876
788
static void
877
static void
Lines 847-908 load_places_store (BookmarkAgent *this) Link Here
847
	g_strfreev (bookmarks);
936
	g_strfreev (bookmarks);
848
}
937
}
849
938
850
static void
851
load_recent_store (BookmarkAgent *this)
852
{
853
	BookmarkAgentPrivate *priv = PRIVATE (this);
854
855
	GBookmarkFile *store;
856
857
	gchar **uris          = NULL;
858
	GList  *items_ordered = NULL;
859
860
	BookmarkItem *item;
861
862
	gboolean include;
863
864
	gint    i;
865
	GList  *node;
866
867
868
	store = g_bookmark_file_new ();
869
	g_bookmark_file_load_from_file (store, priv->store_path, NULL);
870
871
	uris = g_bookmark_file_get_uris (store, NULL);
872
873
	for (i = 0; uris && uris [i]; ++i) {
874
		if (priv->type == BOOKMARK_STORE_RECENT_APPS)
875
			include = g_bookmark_file_has_group (store, uris [i], "recently-used-apps", NULL);
876
		else
877
			include = ! g_bookmark_file_get_is_private (store, uris [i], NULL);
878
879
		if (include) {
880
			item = g_new0 (BookmarkItem, 1);
881
882
			item->uri       = g_strdup (uris [i]);
883
			item->mime_type = g_bookmark_file_get_mime_type (store, uris [i], NULL);
884
			item->mtime     = g_bookmark_file_get_modified  (store, uris [i], NULL);
885
886
			items_ordered = g_list_insert_sorted (items_ordered, item, recent_item_mru_comp_func);
887
		}
888
	}
889
890
	g_strfreev (uris);
891
	g_bookmark_file_free (store);
892
893
	g_bookmark_file_free (priv->store);
894
	priv->store = g_bookmark_file_new ();
895
896
	for (node = items_ordered; node; node = node->next) {
897
		item = (BookmarkItem *) node->data;
898
899
		g_bookmark_file_set_mime_type (priv->store, item->uri, item->mime_type);
900
		g_bookmark_file_set_modified  (priv->store, item->uri, item->mtime);
901
902
		bookmark_item_free (item);
903
	}
904
}
905
906
static gchar *
939
static gchar *
907
find_package_data_file (const gchar *filename)
940
find_package_data_file (const gchar *filename)
908
{
941
{
Lines 984-1008 update_user_spec_path (BookmarkAgent *this) Link Here
984
}
1017
}
985
1018
986
static void
1019
static void
987
update_recent_store_path (BookmarkAgent *this)
988
{
989
	BookmarkAgentPrivate *priv = PRIVATE (this);
990
991
	BookmarkStoreStatus status;
992
993
994
	if (g_file_test (priv->store_path, G_FILE_TEST_EXISTS))
995
		status = BOOKMARK_STORE_USER;
996
	else
997
		status = BOOKMARK_STORE_USER;
998
999
	if (priv->status != status) {
1000
		priv->status = status;
1001
		g_object_notify (G_OBJECT (this), BOOKMARK_AGENT_STORE_STATUS_PROP);
1002
	}
1003
}
1004
1005
static void
1006
save_xbel_store (BookmarkAgent *this)
1020
save_xbel_store (BookmarkAgent *this)
1007
{
1021
{
1008
	BookmarkAgentPrivate *priv = PRIVATE (this);
1022
	BookmarkAgentPrivate *priv = PRIVATE (this);
(-)a/libslab/bookmark-agent.h (+2 lines)
Lines 80-85 void bookmark_agent_move_item (BookmarkAgent *this, const gchar *u Link Here
80
void           bookmark_agent_remove_item   (BookmarkAgent *this, const gchar *uri);
80
void           bookmark_agent_remove_item   (BookmarkAgent *this, const gchar *uri);
81
void           bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris);
81
void           bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris);
82
82
83
void bookmark_agent_update_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store);
84
83
void           bookmark_item_free           (BookmarkItem *item);
85
void           bookmark_item_free           (BookmarkItem *item);
84
86
85
G_END_DECLS
87
G_END_DECLS
(-)a/libslab/document-tile.c (-6 / +10 lines)
Lines 94-101 typedef struct Link Here
94
	gulong               notify_signal_id;
94
	gulong               notify_signal_id;
95
} DocumentTilePrivate;
95
} DocumentTilePrivate;
96
96
97
static GnomeThumbnailFactory *thumbnail_factory = NULL;
98
99
#define DOCUMENT_TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DOCUMENT_TILE_TYPE, DocumentTilePrivate))
97
#define DOCUMENT_TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DOCUMENT_TILE_TYPE, DocumentTilePrivate))
100
98
101
static void document_tile_class_init (DocumentTileClass *this_class)
99
static void document_tile_class_init (DocumentTileClass *this_class)
Lines 137-142 document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified) Link Here
137
	
135
	
138
	gchar *filename;
136
	gchar *filename;
139
	gchar *tooltip_text;
137
	gchar *tooltip_text;
138
139
	libslab_checkpoint ("document_tile_new(): start");
140
  
140
  
141
	uri = g_strdup (in_uri);
141
	uri = g_strdup (in_uri);
142
142
Lines 293-300 document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified) Link Here
293
293
294
	gtk_widget_show_all (GTK_WIDGET (TILE (this)->context_menu));
294
	gtk_widget_show_all (GTK_WIDGET (TILE (this)->context_menu));
295
295
296
	load_image (this);
297
298
	accessible = gtk_widget_get_accessible (GTK_WIDGET (this));
296
	accessible = gtk_widget_get_accessible (GTK_WIDGET (this));
299
	if (basename)
297
	if (basename)
300
	  atk_object_set_name (accessible, basename);
298
	  atk_object_set_name (accessible, basename);
Lines 304-309 document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified) Link Here
304
	g_free (basename);
302
	g_free (basename);
305
	g_free (time_str);
303
	g_free (time_str);
306
304
305
	libslab_checkpoint ("document_tile_new(): end");
306
307
	return GTK_WIDGET (this);
307
	return GTK_WIDGET (this);
308
}
308
}
309
309
Lines 417-422 load_image (DocumentTile *tile) Link Here
417
417
418
	gchar *icon_id = NULL;
418
	gchar *icon_id = NULL;
419
	gboolean free_icon_id = TRUE;
419
	gboolean free_icon_id = TRUE;
420
	GnomeThumbnailFactory *thumbnail_factory;
421
422
	libslab_checkpoint ("document-tile.c: load_image(): start for %s", TILE (tile)->uri);
420
423
421
	if (! priv->mime_type || ! strstr (TILE (tile)->uri, "file://")) {
424
	if (! priv->mime_type || ! strstr (TILE (tile)->uri, "file://")) {
422
		icon_id = "gnome-fs-regular";
425
		icon_id = "gnome-fs-regular";
Lines 425-432 load_image (DocumentTile *tile) Link Here
425
		goto exit;
428
		goto exit;
426
	}
429
	}
427
430
428
	if (! thumbnail_factory)
431
	thumbnail_factory = libslab_thumbnail_factory_get ();
429
		thumbnail_factory = gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL);
430
432
431
	thumb_path = gnome_thumbnail_factory_lookup (thumbnail_factory, TILE (tile)->uri, priv->modified);
433
	thumb_path = gnome_thumbnail_factory_lookup (thumbnail_factory, TILE (tile)->uri, priv->modified);
432
434
Lines 467-472 exit: Link Here
467
469
468
	if (free_icon_id && icon_id)
470
	if (free_icon_id && icon_id)
469
		g_free (icon_id);
471
		g_free (icon_id);
472
473
	libslab_checkpoint ("document-tile.c: load_image(): end");
470
}
474
}
471
475
472
/* Next function taken from e-data-server-util.c in evolution-data-server */
476
/* Next function taken from e-data-server-util.c in evolution-data-server */
(-)a/libslab/libslab-utils.c (+126 lines)
Lines 5-16 Link Here
5
#endif
5
#endif
6
6
7
#include <string.h>
7
#include <string.h>
8
#include <stdio.h>
9
#include <unistd.h>
10
#include <time.h>
11
#include <sys/stat.h>
12
#include <sys/resource.h>
13
#include <sys/time.h>
8
#include <gconf/gconf-value.h>
14
#include <gconf/gconf-value.h>
9
#include <libgnome/gnome-url.h>
15
#include <libgnome/gnome-url.h>
10
16
11
#define DESKTOP_ITEM_TERMINAL_EMULATOR_FLAG "TerminalEmulator"
17
#define DESKTOP_ITEM_TERMINAL_EMULATOR_FLAG "TerminalEmulator"
12
#define ALTERNATE_DOCPATH_KEY               "DocPath"
18
#define ALTERNATE_DOCPATH_KEY               "DocPath"
13
19
20
static FILE *checkpoint_file;
21
14
gboolean
22
gboolean
15
libslab_gtk_image_set_by_id (GtkImage *image, const gchar *id)
23
libslab_gtk_image_set_by_id (GtkImage *image, const gchar *id)
16
{
24
{
Lines 562-564 libslab_spawn_command (const gchar *cmd) Link Here
562
570
563
	g_strfreev (argv);
571
	g_strfreev (argv);
564
}
572
}
573
574
static guint thumbnail_factory_idle_id;
575
static GnomeThumbnailFactory *thumbnail_factory;
576
577
static void
578
create_thumbnail_factory (void)
579
{
580
	libslab_checkpoint ("create_thumbnail_factory(): start");
581
582
	g_assert (thumbnail_factory == NULL);
583
	thumbnail_factory = gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL);
584
585
	libslab_checkpoint ("create_thumbnail_factory(): end");
586
}
587
588
static gboolean
589
init_thumbnail_factory_idle_cb (gpointer data)
590
{
591
	create_thumbnail_factory ();
592
	thumbnail_factory_idle_id = 0;
593
	return FALSE;
594
}
595
596
void
597
libslab_thumbnail_factory_preinit (void)
598
{
599
	thumbnail_factory_idle_id = g_idle_add (init_thumbnail_factory_idle_cb, NULL);
600
}
601
602
GnomeThumbnailFactory *
603
libslab_thumbnail_factory_get (void)
604
{
605
	if (thumbnail_factory_idle_id != 0) {
606
		g_source_remove (thumbnail_factory_idle_id);
607
		thumbnail_factory_idle_id = 0;
608
609
		create_thumbnail_factory ();
610
	}
611
612
	g_assert (thumbnail_factory != NULL);
613
	return thumbnail_factory;
614
}
615
616
void
617
libslab_checkpoint_init (const char *checkpoint_config_file_basename,
618
			 const char *checkpoint_file_basename)
619
{
620
	char *filename;
621
	struct stat st;
622
	int result;
623
	time_t t;
624
	struct tm tm;
625
	char *checkpoint_full_basename;
626
627
	g_return_if_fail (checkpoint_config_file_basename != NULL);
628
	g_return_if_fail (checkpoint_file_basename != NULL);
629
630
	filename = g_build_filename (g_get_home_dir (), checkpoint_config_file_basename, NULL);
631
632
	result = stat (filename, &st);
633
	g_free (filename);
634
635
	if (result != 0)
636
		return;
637
638
	t = time (NULL);
639
	tm = *localtime (&t);
640
641
	checkpoint_full_basename = g_strdup_printf ("%s-%04d-%02d-%02d-%02d-%02d-%02d.checkpoint",
642
						    checkpoint_file_basename,
643
						    tm.tm_year + 1900,
644
						    tm.tm_mon + 1,
645
						    tm.tm_mday,
646
						    tm.tm_hour,
647
						    tm.tm_min,
648
						    tm.tm_sec);
649
650
	filename = g_build_filename (g_get_home_dir (), checkpoint_full_basename, NULL);
651
	g_free (checkpoint_full_basename);
652
653
	checkpoint_file = fopen (filename, "w");
654
	g_free (filename);
655
}
656
657
void
658
libslab_checkpoint (const char *format, ...)
659
{
660
	va_list args;
661
	struct timeval tv;
662
	struct tm tm;
663
	struct rusage rusage;
664
665
	if (!checkpoint_file)
666
		return;
667
668
	gettimeofday (&tv, NULL);
669
	tm = *localtime (&tv.tv_sec);
670
671
	getrusage (RUSAGE_SELF, &rusage);
672
673
	fprintf (checkpoint_file,
674
		 "%02d:%02d:%02d.%04d (user:%d.%04d, sys:%d.%04d) - ",
675
		 (int) tm.tm_hour,
676
		 (int) tm.tm_min,
677
		 (int) tm.tm_sec,
678
		 (int) (tv.tv_usec / 100),
679
		 (int) rusage.ru_utime.tv_sec,
680
		 (int) (rusage.ru_utime.tv_usec / 100),
681
		 (int) rusage.ru_stime.tv_sec,
682
		 (int) (rusage.ru_stime.tv_usec / 100));
683
684
	va_start (args, format);
685
	vfprintf (checkpoint_file, format, args);
686
	va_end (args);
687
688
	fputs ("\n", checkpoint_file);
689
	fflush (checkpoint_file);
690
}
(-)a/libslab/libslab-utils.h (+7 lines)
Lines 5-10 Link Here
5
#include <gtk/gtk.h>
5
#include <gtk/gtk.h>
6
#include <gconf/gconf-client.h>
6
#include <gconf/gconf-client.h>
7
#include <libgnome/gnome-desktop-item.h>
7
#include <libgnome/gnome-desktop-item.h>
8
#include <libgnomeui/gnome-thumbnail.h>
8
9
9
G_BEGIN_DECLS
10
G_BEGIN_DECLS
10
11
Lines 27-32 gboolean libslab_desktop_item_is_lockscreen (const gchar *uri); Link Here
27
gchar            *libslab_string_replace_once (const gchar *string, const gchar *key, const gchar *value);
28
gchar            *libslab_string_replace_once (const gchar *string, const gchar *key, const gchar *value);
28
void              libslab_spawn_command (const gchar *cmd);
29
void              libslab_spawn_command (const gchar *cmd);
29
30
31
void libslab_thumbnail_factory_preinit (void);
32
GnomeThumbnailFactory *libslab_thumbnail_factory_get (void);
33
34
void libslab_checkpoint_init (const char *checkpoint_config_file_basename, const char *checkpoint_file_basename);
35
void libslab_checkpoint (const char *format, ...);
36
30
G_END_DECLS
37
G_END_DECLS
31
38
32
#endif
39
#endif
(-)a/main-menu/src/main-menu-ui.c (-3 / +233 lines)
Lines 36-41 Link Here
36
#include <libgnomevfs/gnome-vfs.h>
36
#include <libgnomevfs/gnome-vfs.h>
37
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
37
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
38
38
39
#include <gtk/gtkversion.h>
40
#if GTK_CHECK_VERSION (2, 10, 0)
41
#	define USE_GTK_RECENT_MANAGER
42
#endif
43
39
#include "tile.h"
44
#include "tile.h"
40
#include "application-tile.h"
45
#include "application-tile.h"
41
#include "document-tile.h"
46
#include "document-tile.h"
Lines 119-124 typedef struct { Link Here
119
	GnomeVFSVolumeMonitor *volume_mon;
124
	GnomeVFSVolumeMonitor *volume_mon;
120
	GList                 *mounts;
125
	GList                 *mounts;
121
126
127
	guint recently_used_throttle_timeout_id;
128
	GnomeVFSMonitorHandle *recently_used_store_monitor;
129
122
	guint search_cmd_gconf_mntr_id;
130
	guint search_cmd_gconf_mntr_id;
123
	guint current_page_gconf_mntr_id;
131
	guint current_page_gconf_mntr_id;
124
	guint more_link_vis_gconf_mntr_id;
132
	guint more_link_vis_gconf_mntr_id;
Lines 136-141 typedef struct { Link Here
136
144
137
	gboolean ptr_is_grabbed;
145
	gboolean ptr_is_grabbed;
138
	gboolean kbd_is_grabbed;
146
	gboolean kbd_is_grabbed;
147
148
	guint recently_used_store_has_changed : 1;
139
} MainMenuUIPrivate;
149
} MainMenuUIPrivate;
140
150
141
#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MAIN_MENU_UI_TYPE, MainMenuUIPrivate))
151
#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MAIN_MENU_UI_TYPE, MainMenuUIPrivate))
Lines 157-162 static void create_more_buttons (MainMenuUI *); Link Here
157
static void setup_file_tables        (MainMenuUI *);
167
static void setup_file_tables        (MainMenuUI *);
158
static void setup_bookmark_agents    (MainMenuUI *);
168
static void setup_bookmark_agents    (MainMenuUI *);
159
static void setup_lock_down          (MainMenuUI *);
169
static void setup_lock_down          (MainMenuUI *);
170
static void setup_recently_used_store_monitor (MainMenuUI *this, gboolean is_startup);
171
static void update_recently_used_sections (MainMenuUI *this);
160
172
161
static void       select_page                (MainMenuUI *);
173
static void       select_page                (MainMenuUI *);
162
static void       update_limits              (MainMenuUI *);
174
static void       update_limits              (MainMenuUI *);
Lines 277-301 main_menu_ui_new (PanelApplet *applet) Link Here
277
	priv->panel_button_xml = glade_xml_new (glade_xml_path, "slab-panel-button-root", NULL);
289
	priv->panel_button_xml = glade_xml_new (glade_xml_path, "slab-panel-button-root", NULL);
278
	g_free (glade_xml_path);
290
	g_free (glade_xml_path);
279
291
292
	libslab_checkpoint ("main_menu_ui_new(): setup_recently_used_store_monitor");
293
	setup_recently_used_store_monitor (this, TRUE);
294
	libslab_checkpoint ("main_menu_ui_new(): setup_bookmark_agents");
280
	setup_bookmark_agents    (this);
295
	setup_bookmark_agents    (this);
296
	libslab_checkpoint ("main_menu_ui_new(): create_panel_button");
281
	create_panel_button      (this);
297
	create_panel_button      (this);
298
	libslab_checkpoint ("main_menu_ui_new(): create_slab_window");
282
	create_slab_window       (this);
299
	create_slab_window       (this);
300
	libslab_checkpoint ("main_menu_ui_new(): create_search_section");
283
	create_search_section    (this);
301
	create_search_section    (this);
302
	libslab_checkpoint ("main_menu_ui_new(): create_file_section");
284
	create_file_section      (this);
303
	create_file_section      (this);
304
	libslab_checkpoint ("main_menu_ui_new(): create_user_apps_section");
285
	create_user_apps_section (this);
305
	create_user_apps_section (this);
306
	libslab_checkpoint ("main_menu_ui_new(): create_rct_apps_section");
286
	create_rct_apps_section  (this);
307
	create_rct_apps_section  (this);
308
	libslab_checkpoint ("main_menu_ui_new(): create_user_docs_section");
287
	create_user_docs_section (this);
309
	create_user_docs_section (this);
310
	libslab_checkpoint ("main_menu_ui_new(): create_rct_docs_section");
288
	create_rct_docs_section  (this);
311
	create_rct_docs_section  (this);
312
	libslab_checkpoint ("main_menu_ui_new(): create_user_dirs_section");
289
	create_user_dirs_section (this);
313
	create_user_dirs_section (this);
314
	libslab_checkpoint ("main_menu_ui_new(): create_system_section");
290
	create_system_section    (this);
315
	create_system_section    (this);
316
	libslab_checkpoint ("main_menu_ui_new(): create_status_section");
291
	create_status_section    (this);
317
	create_status_section    (this);
318
	libslab_checkpoint ("main_menu_ui_new(): create_more_buttons");
292
	create_more_buttons      (this);
319
	create_more_buttons      (this);
320
	libslab_checkpoint ("main_menu_ui_new(): setup_file_tables");
293
	setup_file_tables        (this);
321
	setup_file_tables        (this);
322
	libslab_checkpoint ("main_menu_ui_new(): setup_lock_down");
294
	setup_lock_down          (this);
323
	setup_lock_down          (this);
295
324
325
	libslab_checkpoint ("main_menu_ui_new(): bind_beagle_search_key");
296
	bind_beagle_search_key  (this);
326
	bind_beagle_search_key  (this);
297
	update_limits           (this);
327
	libslab_checkpoint ("main_menu_ui_new(): select_page");
298
	select_page             (this);
328
	select_page             (this);
329
	libslab_checkpoint ("main_menu_ui_new(): apply_lockdown_settings");
299
	apply_lockdown_settings (this);
330
	apply_lockdown_settings (this);
300
331
301
	return this;
332
	return this;
Lines 404-409 main_menu_ui_finalize (GObject *g_obj) Link Here
404
435
405
	gint i;
436
	gint i;
406
437
438
	if (priv->recently_used_store_monitor)
439
		gnome_vfs_monitor_cancel (priv->recently_used_store_monitor);
440
441
	if (priv->recently_used_throttle_timeout_id)
442
		g_source_remove (priv->recently_used_throttle_timeout_id);
407
443
408
	for (i = 0; i < 4; ++i) {
444
	for (i = 0; i < 4; ++i) {
409
		g_object_unref (G_OBJECT (g_object_get_data (
445
		g_object_unref (G_OBJECT (g_object_get_data (
Lines 921-926 setup_lock_down (MainMenuUI *this) Link Here
921
		DISABLE_LOCKSCREEN_GCONF_KEY, lockdown_notify_cb, this);
957
		DISABLE_LOCKSCREEN_GCONF_KEY, lockdown_notify_cb, this);
922
}
958
}
923
959
960
static char *
961
get_recently_used_store_filename (void)
962
{
963
	const char *basename;
964
965
#ifdef USE_GTK_RECENT_MANAGER
966
	basename = ".recently-used.xbel";
967
#else
968
	basename = ".recently-used";
969
#endif
970
971
	return g_build_filename (g_get_home_dir (), basename, NULL);
972
}
973
974
static gboolean
975
recently_used_throttle_timeout_cb (gpointer data)
976
{
977
	MainMenuUI *this = MAIN_MENU_UI (data);
978
	MainMenuUIPrivate *priv = PRIVATE (this);
979
980
	update_recently_used_sections (this);
981
982
	priv->recently_used_throttle_timeout_id = 0;
983
984
	return FALSE;
985
}
986
987
#define RECENTLY_USED_STORE_THROTTLE_SECONDS 2
988
989
static void
990
setup_recently_used_throttle_timeout (MainMenuUI *this, gboolean is_startup)
991
{
992
	MainMenuUIPrivate *priv = PRIVATE (this);
993
994
	if (priv->recently_used_throttle_timeout_id != 0)
995
		g_source_remove (priv->recently_used_throttle_timeout_id);
996
997
	/* Some apps do many updates to the recently-used store quickly, like
998
	 * when Nautilus or EOG are asked to open a bunch of files at the same
999
	 * time.  So, we throttle our updates to the recently-used store to
1000
	 * avoid re-reading the store more times than needed.
1001
	 *
1002
	 * Additionally, we do this in an idle during startup, not a timeout,
1003
	 * so that the Computer menu will be up to date as soon as possible.
1004
	 */
1005
	if (is_startup)
1006
		priv->recently_used_throttle_timeout_id = g_idle_add (recently_used_throttle_timeout_cb, this);
1007
	else
1008
		priv->recently_used_throttle_timeout_id = g_timeout_add_seconds (RECENTLY_USED_STORE_THROTTLE_SECONDS,
1009
										 recently_used_throttle_timeout_cb,
1010
										 this);
1011
}
1012
1013
/* Called from GnomeVFSMonitor when the recently-used store changes.  We'll note
1014
 * this in a flag, and we'll check that flag later, when it is necessary to have
1015
 * an up-to-date view of the recently-used store.
1016
 */
1017
static void recently_used_store_monitor_changed_cb (GnomeVFSMonitorHandle *handle,
1018
						    const gchar *monitor_uri,
1019
						    const gchar *info_uri,
1020
						    GnomeVFSMonitorEventType event_type,
1021
						    gpointer data)
1022
{
1023
	MainMenuUI *this = MAIN_MENU_UI (data);
1024
	MainMenuUIPrivate *priv = PRIVATE (this);
1025
1026
	priv->recently_used_store_has_changed = TRUE;
1027
	setup_recently_used_throttle_timeout (this, FALSE);
1028
}
1029
1030
/* Creates a GnomeVFSMonitor for the recently-used store, so we can be informed
1031
 * when the store changes.
1032
 */
1033
static void
1034
setup_recently_used_store_monitor (MainMenuUI *this, gboolean is_startup)
1035
{
1036
	MainMenuUIPrivate *priv = PRIVATE (this);
1037
	char *filename;
1038
	char *uri;
1039
1040
	priv->recently_used_store_has_changed = TRUE; /* ensure the store gets read the first time we need it */
1041
1042
	filename = get_recently_used_store_filename ();
1043
	uri = g_strconcat ("file://", filename, NULL);
1044
	g_free (filename);
1045
1046
	if (gnome_vfs_monitor_add (&priv->recently_used_store_monitor,
1047
				   uri,
1048
				   GNOME_VFS_MONITOR_FILE,
1049
				   recently_used_store_monitor_changed_cb,
1050
				   this) != GNOME_VFS_OK)
1051
		priv->recently_used_store_monitor = NULL;
1052
1053
	g_free (uri);
1054
1055
	setup_recently_used_throttle_timeout (this, is_startup);
1056
}
1057
924
static Tile *
1058
static Tile *
925
item_to_user_app_tile (BookmarkItem *item, gpointer data)
1059
item_to_user_app_tile (BookmarkItem *item, gpointer data)
926
{
1060
{
Lines 1492-1497 apply_lockdown_settings (MainMenuUI *this) Link Here
1492
	GList *node;
1626
	GList *node;
1493
	gint   i;
1627
	gint   i;
1494
1628
1629
	libslab_checkpoint ("apply_lockdown_settings(): start");
1495
1630
1496
	more_link_visible   = GPOINTER_TO_INT (libslab_get_gconf_value (MORE_LINK_VIS_GCONF_KEY));
1631
	more_link_visible   = GPOINTER_TO_INT (libslab_get_gconf_value (MORE_LINK_VIS_GCONF_KEY));
1497
	status_area_visible = GPOINTER_TO_INT (libslab_get_gconf_value (STATUS_VIS_GCONF_KEY));
1632
	status_area_visible = GPOINTER_TO_INT (libslab_get_gconf_value (STATUS_VIS_GCONF_KEY));
Lines 1531-1543 apply_lockdown_settings (MainMenuUI *this) Link Here
1531
	for (i = 0; i < 5; ++i)
1666
	for (i = 0; i < 5; ++i)
1532
		set_table_section_visible (this, priv->file_tables [i]);
1667
		set_table_section_visible (this, priv->file_tables [i]);
1533
1668
1669
	libslab_checkpoint ("apply_lockdown_settings(): loading sys_table");
1534
	tile_table_reload (priv->sys_table);
1670
	tile_table_reload (priv->sys_table);
1671
1672
	libslab_checkpoint ("apply_lockdown_settings(): loading user_apps_table");
1535
	tile_table_reload (priv->file_tables [USER_APPS_TABLE]);
1673
	tile_table_reload (priv->file_tables [USER_APPS_TABLE]);
1536
	tile_table_reload (priv->file_tables [RCNT_APPS_TABLE]);
1674
1675
	libslab_checkpoint ("apply_lockdown_settings(): loading user_docs_table");
1537
	tile_table_reload (priv->file_tables [USER_DOCS_TABLE]);
1676
	tile_table_reload (priv->file_tables [USER_DOCS_TABLE]);
1677
1678
	libslab_checkpoint ("apply_lockdown_settings(): loading user_dirs_table");
1538
	tile_table_reload (priv->file_tables [USER_DIRS_TABLE]);
1679
	tile_table_reload (priv->file_tables [USER_DIRS_TABLE]);
1539
1680
1681
	libslab_checkpoint ("apply_lockdown_settings(): update_limits");
1540
	update_limits (this);
1682
	update_limits (this);
1683
1684
	libslab_checkpoint ("apply_lockdown_settings(): end");
1541
}
1685
}
1542
1686
1543
static void
1687
static void
Lines 1616-1621 exit: Link Here
1616
	xmlFreeDoc (doc);
1760
	xmlFreeDoc (doc);
1617
}
1761
}
1618
1762
1763
static GBookmarkFile *
1764
load_recently_used_store (void)
1765
{
1766
	GBookmarkFile *store;
1767
	char *filename;
1768
1769
	store = g_bookmark_file_new ();
1770
1771
	filename = get_recently_used_store_filename ();
1772
1773
	/* FIXME: if we can't load the store, do we need to hide the
1774
	 * recently-used sections in the GUI?  If so, do that in the caller(s)
1775
	 * of this function, not here.
1776
	 */
1777
1778
	libslab_checkpoint ("main-menu-ui.c: load_recently_used_store(): start loading %s", filename);
1779
	g_bookmark_file_load_from_file (store, filename, NULL); /* NULL-GError */
1780
	libslab_checkpoint ("main-menu-ui.c: load_recently_used_store(): end loading %s", filename);
1781
1782
	g_free (filename);
1783
1784
	return store;
1785
}
1786
1787
/* Updates the bookmark agents for the recently-used apps and documents, by reading the
1788
 * recently-used store.
1789
 */
1790
static void
1791
update_recently_used_bookmark_agents (MainMenuUI *this)
1792
{
1793
	MainMenuUIPrivate *priv = PRIVATE (this);
1794
	GBookmarkFile *store;
1795
1796
	store = load_recently_used_store ();
1797
1798
	bookmark_agent_update_from_bookmark_file (priv->bm_agents[BOOKMARK_STORE_RECENT_APPS], store);
1799
	bookmark_agent_update_from_bookmark_file (priv->bm_agents[BOOKMARK_STORE_RECENT_DOCS], store);
1800
1801
	g_bookmark_file_free (store);
1802
}
1803
1804
/* Updates the recently-used tile tables from their corresponding bookmark agents */
1805
static void
1806
update_recently_used_tables (MainMenuUI *this)
1807
{
1808
	MainMenuUIPrivate *priv = PRIVATE (this);
1809
1810
	tile_table_reload (priv->file_tables[RCNT_APPS_TABLE]);
1811
	tile_table_reload (priv->file_tables[RCNT_DOCS_TABLE]);
1812
}
1813
1814
/* If the recently-used store has changed since the last time we updated from
1815
 * it, this updates our view of the store and the corresponding sections in the
1816
 * slab_window.
1817
 */
1818
static void
1819
update_recently_used_sections (MainMenuUI *this)
1820
{
1821
	MainMenuUIPrivate *priv = PRIVATE (this);
1822
1823
	libslab_checkpoint ("main-menu-ui.c: update_recently_used_sections() start");
1824
1825
	if (priv->recently_used_store_has_changed) {
1826
		update_recently_used_bookmark_agents (this);
1827
		update_recently_used_tables (this);
1828
1829
		priv->recently_used_store_has_changed = FALSE;
1830
	}
1831
1832
	if (!priv->recently_used_store_monitor)
1833
		setup_recently_used_store_monitor (this, FALSE); /* for if we couldn't create the monitor the first time */
1834
1835
	libslab_checkpoint ("main-menu-ui.c: update_recently_used_sections() end");
1836
}
1837
1838
/* Updates the slab_window's sections that need updating and presents the window */
1839
static void
1840
present_slab_window (MainMenuUI *this)
1841
{
1842
	MainMenuUIPrivate *priv = PRIVATE (this);
1843
1844
	update_recently_used_sections (this);
1845
1846
	gtk_window_present_with_time (GTK_WINDOW (priv->slab_window), gtk_get_current_event_time ());
1847
}
1848
1619
static void
1849
static void
1620
panel_button_clicked_cb (GtkButton *button, gpointer user_data)
1850
panel_button_clicked_cb (GtkButton *button, gpointer user_data)
1621
{
1851
{
Lines 1636-1642 panel_button_clicked_cb (GtkButton *button, gpointer user_data) Link Here
1636
1866
1637
	if (! double_click_detector_is_double_click (detector, gtk_get_current_event_time (), TRUE)) {
1867
	if (! double_click_detector_is_double_click (detector, gtk_get_current_event_time (), TRUE)) {
1638
		if (! visible)
1868
		if (! visible)
1639
			gtk_window_present_with_time (GTK_WINDOW (priv->slab_window), gtk_get_current_event_time ());
1869
			present_slab_window (this);
1640
		else
1870
		else
1641
			gtk_widget_hide (priv->slab_window);
1871
			gtk_widget_hide (priv->slab_window);
1642
1872
(-)a/main-menu/src/main-menu.c (+14 lines)
Lines 26-31 Link Here
26
#include <panel-applet.h>
26
#include <panel-applet.h>
27
#include <string.h>
27
#include <string.h>
28
28
29
#include "libslab-utils.h"
29
#include "main-menu-ui.h"
30
#include "main-menu-ui.h"
30
31
31
#include "main-menu-migration.h"
32
#include "main-menu-migration.h"
Lines 35-45 static gboolean main_menu_applet_init (PanelApplet *, const gchar *, gpointer); Link Here
35
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_MainMenu_Factory", PANEL_TYPE_APPLET, "Main Menu", "0",
36
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_MainMenu_Factory", PANEL_TYPE_APPLET, "Main Menu", "0",
36
	main_menu_applet_init, NULL);
37
	main_menu_applet_init, NULL);
37
38
39
#define CHECKPOINT_CONFIG_BASENAME "main-menu-checkpoint.conf"
40
#define CHECKPOINT_FILE_BASENAME "main-menu"
41
38
static gboolean
42
static gboolean
39
main_menu_applet_init (PanelApplet *applet, const gchar *iid, gpointer user_data)
43
main_menu_applet_init (PanelApplet *applet, const gchar *iid, gpointer user_data)
40
{
44
{
41
	gchar *argv [1] = { "slab" };
45
	gchar *argv [1] = { "slab" };
42
46
47
	libslab_checkpoint_init (CHECKPOINT_CONFIG_BASENAME, CHECKPOINT_FILE_BASENAME);
48
49
	libslab_checkpoint ("Main-menu starts up");
50
43
	if (strcmp (iid, "OAFIID:GNOME_MainMenu") != 0)
51
	if (strcmp (iid, "OAFIID:GNOME_MainMenu") != 0)
44
		return FALSE;
52
		return FALSE;
45
53
Lines 58-70 main_menu_applet_init (PanelApplet *applet, const gchar *iid, gpointer user_data Link Here
58
66
59
	gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, 1, argv, NULL, NULL);
67
	gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, 1, argv, NULL, NULL);
60
68
69
	libslab_checkpoint ("Migrating old configurations");
61
	migrate_system_gconf_to_bookmark_file    ();
70
	migrate_system_gconf_to_bookmark_file    ();
62
	migrate_user_apps_gconf_to_bookmark_file ();
71
	migrate_user_apps_gconf_to_bookmark_file ();
63
	migrate_showable_file_types              ();
72
	migrate_showable_file_types              ();
64
73
74
	libslab_checkpoint ("Creating user interface for whole applet");
65
	main_menu_ui_new (applet);
75
	main_menu_ui_new (applet);
66
76
77
	libslab_checkpoint ("Showing all widgets in applet");
67
	gtk_widget_show_all (GTK_WIDGET (applet));
78
	gtk_widget_show_all (GTK_WIDGET (applet));
68
79
80
	libslab_thumbnail_factory_preinit ();
81
82
	libslab_checkpoint ("Finished initializing applet");
69
	return TRUE;
83
	return TRUE;
70
}
84
}
(-)a/main-menu/src/tile-table.c (-2 / +4 lines)
Lines 22-27 Link Here
22
22
23
#include "tile.h"
23
#include "tile.h"
24
#include "nameplate-tile.h"
24
#include "nameplate-tile.h"
25
#include "libslab-utils.h"
25
26
26
G_DEFINE_TYPE (TileTable, tile_table, GTK_TYPE_TABLE)
27
G_DEFINE_TYPE (TileTable, tile_table, GTK_TYPE_TABLE)
27
28
Lines 101-108 tile_table_new (BookmarkAgent *agent, gint limit, gint n_cols, Link Here
101
	priv->create_item_func = uti_func;
102
	priv->create_item_func = uti_func;
102
	priv->item_func_data   = data_uti;
103
	priv->item_func_data   = data_uti;
103
104
104
	tile_table_reload (TILE_TABLE (this));
105
106
	g_signal_connect (
105
	g_signal_connect (
107
		G_OBJECT (priv->agent), "notify::" BOOKMARK_AGENT_ITEMS_PROP,
106
		G_OBJECT (priv->agent), "notify::" BOOKMARK_AGENT_ITEMS_PROP,
108
		G_CALLBACK (agent_notify_cb), this);
107
		G_CALLBACK (agent_notify_cb), this);
Lines 125-130 tile_table_reload (TileTable *this) Link Here
125
	GList *node;
124
	GList *node;
126
	gint   i;
125
	gint   i;
127
126
127
	libslab_checkpoint ("tile_table_reload(): start reloading");
128
128
129
	g_object_get (G_OBJECT (priv->agent), BOOKMARK_AGENT_ITEMS_PROP, & items, NULL);
129
	g_object_get (G_OBJECT (priv->agent), BOOKMARK_AGENT_ITEMS_PROP, & items, NULL);
130
130
Lines 169-174 tile_table_reload (TileTable *this) Link Here
169
	update_bins (this, priv->tiles);
169
	update_bins (this, priv->tiles);
170
170
171
	g_object_notify (G_OBJECT (this), TILE_TABLE_TILES_PROP);
171
	g_object_notify (G_OBJECT (this), TILE_TABLE_TILES_PROP);
172
173
	libslab_checkpoint ("tile_table_reload(): end reloading");
172
}
174
}
173
175
174
void
176
void

Return to bug 230478