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

(-)main-menu/src/main-menu-ui.c (+11 lines)
Lines 211-216 Link Here
211
static gboolean grabbing_window_event_cb          (GtkWidget *, GdkEvent *, gpointer);
211
static gboolean grabbing_window_event_cb          (GtkWidget *, GdkEvent *, gpointer);
212
static void     user_app_agent_notify_cb          (GObject *, GParamSpec *, gpointer);
212
static void     user_app_agent_notify_cb          (GObject *, GParamSpec *, gpointer);
213
static void     user_doc_agent_notify_cb          (GObject *, GParamSpec *, gpointer);
213
static void     user_doc_agent_notify_cb          (GObject *, GParamSpec *, gpointer);
214
static void     user_dir_agent_notify_cb          (GObject *, GParamSpec *, gpointer);
214
static void     volume_monitor_mount_cb           (GnomeVFSVolumeMonitor *, GnomeVFSVolume *, gpointer);
215
static void     volume_monitor_mount_cb           (GnomeVFSVolumeMonitor *, GnomeVFSVolume *, gpointer);
215
216
216
static GdkFilterReturn slab_gdk_message_filter (GdkXEvent *, GdkEvent *, gpointer);
217
static GdkFilterReturn slab_gdk_message_filter (GdkXEvent *, GdkEvent *, gpointer);
Lines 883-888 Link Here
883
			g_signal_connect (
884
			g_signal_connect (
884
				G_OBJECT (priv->bm_agents [i]), "notify::" BOOKMARK_AGENT_ITEMS_PROP,
885
				G_OBJECT (priv->bm_agents [i]), "notify::" BOOKMARK_AGENT_ITEMS_PROP,
885
				G_CALLBACK (user_doc_agent_notify_cb), this);
886
				G_CALLBACK (user_doc_agent_notify_cb), this);
887
		else if (i == BOOKMARK_STORE_USER_DIRS)
888
		        g_signal_connect (
889
				G_OBJECT (priv->bm_agents [i]), "notify::" BOOKMARK_AGENT_ITEMS_PROP,
890
				G_CALLBACK (user_dir_agent_notify_cb), this);
886
	}
891
	}
887
}
892
}
888
893
Lines 2269-2274 Link Here
2269
}
2274
}
2270
2275
2271
static void
2276
static void
2277
user_dir_agent_notify_cb (GObject *g_obj, GParamSpec *pspec, gpointer user_data)
2278
{
2279
	tile_table_reload (PRIVATE (user_data)->file_tables [USER_DIRS_TABLE]);
2280
}
2281
2282
static void
2272
volume_monitor_mount_cb (GnomeVFSVolumeMonitor *mon, GnomeVFSVolume *vol, gpointer data)
2283
volume_monitor_mount_cb (GnomeVFSVolumeMonitor *mon, GnomeVFSVolume *vol, gpointer data)
2273
{
2284
{
2274
	MainMenuUIPrivate *priv = PRIVATE (data);
2285
	MainMenuUIPrivate *priv = PRIVATE (data);
(-)ChangeLog (+13 lines)
Lines 1-3 Link Here
1
2007-12-19  Lukas Lipka  <lukaslipka@gmail.com>
2
3
	* libslab/bookmark-agent.c
4
	* libslab/directory-tile.c
5
	* libslab/bookmark-agent.c
6
	* libslab/directory-tile.h
7
	* main-menu/src/main-menu-ui.c:
8
	Main-Menu "Places" Items have no "Remove from Favorites" - BNC #309058
9
	Remove the Move to Trash, Delete, Rename, Send to actions from the
10
	directory tiles since they don't really make sense for bookmarks.
11
	Do the correct thing upon removal when a bookmark comes
12
	from ~/.gtk-bookmarks.
13
1
2007-11-28  Scott Reeves  <sreeves@novell.com>
14
2007-11-28  Scott Reeves  <sreeves@novell.com>
2
	* libslab/app-shell-startup.c
15
	* libslab/app-shell-startup.c
3
	* libslab/app-shell.c:
16
	* libslab/app-shell.c:
(-)libslab/directory-tile.c (-368 / +12 lines)
Lines 29-39 Link Here
29
#include "slab-gnome-util.h"
29
#include "slab-gnome-util.h"
30
#include "gnome-utils.h"
30
#include "gnome-utils.h"
31
#include "libslab-utils.h"
31
#include "libslab-utils.h"
32
#include "bookmark-agent.h"
32
33
33
#define GCONF_SEND_TO_CMD_KEY       "/desktop/gnome/applications/main-menu/file-area/file_send_to_cmd"
34
#define GCONF_ENABLE_DELETE_KEY_DIR "/apps/nautilus/preferences"
35
#define GCONF_ENABLE_DELETE_KEY     GCONF_ENABLE_DELETE_KEY_DIR "/enable_delete"
36
37
G_DEFINE_TYPE (DirectoryTile, directory_tile, NAMEPLATE_TILE_TYPE)
34
G_DEFINE_TYPE (DirectoryTile, directory_tile, NAMEPLATE_TILE_TYPE)
38
35
39
static void directory_tile_finalize (GObject *);
36
static void directory_tile_finalize (GObject *);
Lines 47-63 Link Here
47
static void header_size_allocate_cb (GtkWidget *, GtkAllocation *, gpointer);
44
static void header_size_allocate_cb (GtkWidget *, GtkAllocation *, gpointer);
48
45
49
static void open_trigger (Tile *, TileEvent *, TileAction *);
46
static void open_trigger (Tile *, TileEvent *, TileAction *);
50
static void rename_trigger (Tile *, TileEvent *, TileAction *);
47
static void remove_favorite_trigger (Tile *tile, TileEvent *event, TileAction *action);
51
static void move_to_trash_trigger (Tile *, TileEvent *, TileAction *);
52
static void delete_trigger (Tile *, TileEvent *, TileAction *);
53
static void send_to_trigger (Tile *, TileEvent *, TileAction *);
54
48
55
static void rename_entry_activate_cb (GtkEntry *, gpointer);
56
static gboolean rename_entry_key_release_cb (GtkWidget *, GdkEventKey *, gpointer);
57
static void gconf_enable_delete_cb (GConfClient *, guint, GConfEntry *, gpointer);
58
59
static void disown_spawned_child (gpointer);
60
61
typedef struct
49
typedef struct
62
{
50
{
63
	gchar *basename;
51
	gchar *basename;
Lines 66-76 Link Here
66
54
67
	gchar *icon_name;
55
	gchar *icon_name;
68
	
56
	
69
	gboolean renaming;
70
	gboolean image_is_broken;
57
	gboolean image_is_broken;
71
	
58
72
	gboolean delete_enabled;
59
	BookmarkAgent *agent;
73
	guint gconf_conn_id;
74
} DirectoryTilePrivate;
60
} DirectoryTilePrivate;
75
61
76
#define DIRECTORY_TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DIRECTORY_TILE_TYPE, DirectoryTilePrivate))
62
#define DIRECTORY_TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DIRECTORY_TILE_TYPE, DirectoryTilePrivate))
Lines 182-244 Link Here
182
	menu_item = gtk_separator_menu_item_new ();
168
	menu_item = gtk_separator_menu_item_new ();
183
	gtk_container_add (menu_ctnr, menu_item);
169
	gtk_container_add (menu_ctnr, menu_item);
184
170
185
	/* make rename action */
171
	/* make remove from favorites action */
186
172
187
	action = tile_action_new (TILE (this), rename_trigger, _("Rename..."), 0);
173
	action = tile_action_new (TILE (this), remove_favorite_trigger, _("Remove from Favorites"), 0);
188
	TILE (this)->actions[DIRECTORY_TILE_ACTION_RENAME] = action;
174
	TILE (this)->actions[DIRECTORY_TILE_ACTION_REMOVE_FAVORITE] = action;
189
175
190
	menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
176
	menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
191
	gtk_container_add (menu_ctnr, menu_item);
177
	gtk_container_add (menu_ctnr, menu_item);
192
178
193
	/* make send to action */
194
179
195
	/* Only allow Send To for local files, ideally this would use something
196
	 * equivalent to gnome_vfs_uri_is_local, but that method will stat the file and
197
	 * that can hang in some conditions. */
198
199
	if (!strncmp (TILE (this)->uri, "file://", 7))
200
	{
201
		action = tile_action_new (TILE (this), send_to_trigger, _("Send To..."),
202
			TILE_ACTION_OPENS_NEW_WINDOW);
203
204
		menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
205
	}
206
	else
207
	{
208
		action = NULL;
209
210
		menu_item = gtk_menu_item_new_with_label (_("Send To..."));
211
		gtk_widget_set_sensitive (menu_item, FALSE);
212
	}
213
214
	TILE (this)->actions[DIRECTORY_TILE_ACTION_SEND_TO] = action;
215
216
	gtk_container_add (menu_ctnr, menu_item);
217
218
	/* insert separator */
219
220
	menu_item = gtk_separator_menu_item_new ();
221
	gtk_container_add (menu_ctnr, menu_item);
222
223
	/* make move to trash action */
224
225
	action = tile_action_new (TILE (this), move_to_trash_trigger, _("Move to Trash"), 0);
226
	TILE (this)->actions[DIRECTORY_TILE_ACTION_MOVE_TO_TRASH] = action;
227
228
	menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
229
	gtk_container_add (menu_ctnr, menu_item);
230
231
	/* make delete action */
232
233
	if (priv->delete_enabled)
234
	{
235
		action = tile_action_new (TILE (this), delete_trigger, _("Delete"), 0);
236
		TILE (this)->actions[DIRECTORY_TILE_ACTION_DELETE] = action;
237
238
		menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
239
		gtk_container_add (menu_ctnr, menu_item);
240
	}
241
242
	gtk_widget_show_all (GTK_WIDGET (TILE (this)->context_menu));
180
	gtk_widget_show_all (GTK_WIDGET (TILE (this)->context_menu));
243
181
244
	load_image (this);
182
	load_image (this);
Lines 257-277 Link Here
257
{
195
{
258
	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
196
	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
259
197
260
	GConfClient *client;
261
198
262
199
	priv->agent = bookmark_agent_get_instance (BOOKMARK_STORE_USER_DIRS);
263
	priv->renaming = FALSE;
264
265
	priv->delete_enabled =
266
		(gboolean) GPOINTER_TO_INT (get_gconf_value (GCONF_ENABLE_DELETE_KEY));
267
268
	client = gconf_client_get_default ();
269
270
	gconf_client_add_dir (client, GCONF_ENABLE_DELETE_KEY_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL);
271
	priv->gconf_conn_id =
272
		connect_gconf_notify (GCONF_ENABLE_DELETE_KEY, gconf_enable_delete_cb, tile);
273
274
	g_object_unref (client);
275
}
200
}
276
201
277
static void
202
static void
Lines 279-291 Link Here
279
{
204
{
280
	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
205
	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
281
206
207
282
	priv->basename = NULL;
208
	priv->basename = NULL;
283
	priv->header_bin = NULL;
209
	priv->header_bin = NULL;
284
	priv->icon_name = NULL;
210
	priv->icon_name = NULL;
285
	priv->renaming = FALSE;
286
	priv->image_is_broken = TRUE;
211
	priv->image_is_broken = TRUE;
287
	priv->delete_enabled = FALSE;
288
	priv->gconf_conn_id = 0;
289
}
212
}
290
213
291
static void
214
static void
Lines 293-310 Link Here
293
{
216
{
294
	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (g_object);
217
	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (g_object);
295
218
296
	GConfClient *client;
297
219
298
	g_free (priv->basename);
220
	g_free (priv->basename);
299
	g_free (priv->icon_name);
221
	g_free (priv->icon_name);
300
222
301
	client = gconf_client_get_default ();
302
303
	gconf_client_notify_remove (client, priv->gconf_conn_id);
304
	gconf_client_remove_dir (client, GCONF_ENABLE_DELETE_KEY_DIR, NULL);
305
306
	g_object_unref (client);
307
308
	(* G_OBJECT_CLASS (directory_tile_parent_class)->finalize) (g_object);
223
	(* G_OBJECT_CLASS (directory_tile_parent_class)->finalize) (g_object);
309
}
224
}
310
225
Lines 355-467 Link Here
355
}
270
}
356
271
357
static void
272
static void
358
rename_entry_activate_cb (GtkEntry *entry, gpointer user_data)
359
{
360
	DirectoryTile *tile = DIRECTORY_TILE (user_data);
361
	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
362
363
	GnomeVFSURI *src_uri;
364
	GnomeVFSURI *dst_uri;
365
366
	gchar *dirname;
367
	gchar *dst_path;
368
	gchar *dst_uri_str;
369
370
	GtkWidget *child;
371
	GtkWidget *header;
372
373
	GnomeVFSResult retval;
374
375
376
	if (strlen (gtk_entry_get_text (entry)) < 1)
377
		return;
378
379
	src_uri = gnome_vfs_uri_new (TILE (tile)->uri);
380
381
	dirname = gnome_vfs_uri_extract_dirname (src_uri);
382
383
	dst_path = g_build_filename (dirname, gtk_entry_get_text (entry), NULL);
384
385
	dst_uri = gnome_vfs_uri_new (dst_path);
386
387
	retval = gnome_vfs_xfer_uri (src_uri, dst_uri, GNOME_VFS_XFER_REMOVESOURCE,
388
		GNOME_VFS_XFER_ERROR_MODE_ABORT, GNOME_VFS_XFER_OVERWRITE_MODE_SKIP, NULL, NULL);
389
390
	dst_uri_str = gnome_vfs_uri_to_string (dst_uri, GNOME_VFS_URI_HIDE_NONE);
391
392
	if (retval == GNOME_VFS_OK) {
393
		g_free (priv->basename);
394
		priv->basename = g_strdup (gtk_entry_get_text (entry));
395
	}
396
	else
397
		g_warning ("unable to move [%s] to [%s]\n", TILE (tile)->uri, dst_uri_str);
398
399
	header = gtk_label_new (priv->basename);
400
	gtk_misc_set_alignment (GTK_MISC (header), 0.0, 0.5);
401
402
	child = gtk_bin_get_child (priv->header_bin);
403
404
	if (child)
405
		gtk_widget_destroy (child);
406
407
	gtk_container_add (GTK_CONTAINER (priv->header_bin), header);
408
409
	gtk_widget_show (header);
410
411
	gnome_vfs_uri_unref (src_uri);
412
	gnome_vfs_uri_unref (dst_uri);
413
414
	g_free (dirname);
415
	g_free (dst_path);
416
	g_free (dst_uri_str);
417
}
418
419
static gboolean
420
rename_entry_key_release_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
421
{
422
	return TRUE;
423
}
424
425
static void
426
gconf_enable_delete_cb (GConfClient *client, guint conn_id, GConfEntry *entry, gpointer user_data)
427
{
428
	Tile *tile = TILE (user_data);
429
	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (user_data);
430
431
	GtkMenuShell *menu;
432
	gboolean delete_enabled;
433
434
	TileAction *action;
435
	GtkWidget *menu_item;
436
437
	menu = GTK_MENU_SHELL (tile->context_menu);
438
439
	delete_enabled = gconf_value_get_bool (entry->value);
440
441
	if (delete_enabled == priv->delete_enabled)
442
		return;
443
444
	priv->delete_enabled = delete_enabled;
445
446
	if (priv->delete_enabled)
447
	{
448
		action = tile_action_new (tile, delete_trigger, _("Delete"), 0);
449
		tile->actions[DIRECTORY_TILE_ACTION_DELETE] = action;
450
451
		menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
452
		gtk_menu_shell_insert (menu, menu_item, 7);
453
454
		gtk_widget_show_all (menu_item);
455
	}
456
	else
457
	{
458
		g_object_unref (tile->actions[DIRECTORY_TILE_ACTION_DELETE]);
459
460
		tile->actions[DIRECTORY_TILE_ACTION_DELETE] = NULL;
461
	}
462
}
463
464
static void
465
open_trigger (Tile *tile, TileEvent *event, TileAction *action)
273
open_trigger (Tile *tile, TileEvent *event, TileAction *action)
466
{
274
{
467
	gchar *cmd;
275
	gchar *cmd;
Lines 475-648 Link Here
475
}
283
}
476
284
477
static void
285
static void
478
rename_trigger (Tile *tile, TileEvent *event, TileAction *action)
286
remove_favorite_trigger (Tile *tile, TileEvent *event, TileAction *action)
479
{
287
{
480
	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
288
	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
481
289
  
482
	GtkWidget *child;
290
	bookmark_agent_remove_item (priv->agent, TILE (tile)->uri);
483
	GtkWidget *entry;
484
485
486
	entry = gtk_entry_new ();
487
	gtk_entry_set_text (GTK_ENTRY (entry), priv->basename);
488
	gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
489
490
	child = gtk_bin_get_child (priv->header_bin);
491
492
	if (child)
493
		gtk_widget_destroy (child);
494
495
	gtk_container_add (GTK_CONTAINER (priv->header_bin), entry);
496
497
	g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (rename_entry_activate_cb), tile);
498
499
	g_signal_connect (G_OBJECT (entry), "key_release_event",
500
		G_CALLBACK (rename_entry_key_release_cb), NULL);
501
502
	gtk_widget_show (entry);
503
	gtk_widget_grab_focus (entry);
504
}
291
}
505
292
506
static void
507
move_to_trash_trigger (Tile *tile, TileEvent *event, TileAction *action)
508
{
509
	GnomeVFSURI *src_uri;
510
	GnomeVFSURI *trash_uri;
511
512
	gchar *file_name;
513
	gchar *trash_uri_str;
514
515
	GnomeVFSResult retval;
516
517
518
	src_uri = gnome_vfs_uri_new (TILE (tile)->uri);
519
520
	gnome_vfs_find_directory (src_uri, GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri,
521
		FALSE, FALSE, 0777);
522
523
	if (!trash_uri) {
524
		g_warning ("unable to find trash location\n");
525
526
		return;
527
	}
528
529
	file_name = gnome_vfs_uri_extract_short_name (src_uri);
530
531
	if (!file_name) {
532
		g_warning ("unable to extract short name from [%s]\n",
533
			gnome_vfs_uri_to_string (src_uri, GNOME_VFS_URI_HIDE_NONE));
534
535
		return;
536
	}
537
538
	trash_uri = gnome_vfs_uri_append_file_name (trash_uri, file_name);
539
540
	retval = gnome_vfs_xfer_uri (src_uri, trash_uri, GNOME_VFS_XFER_REMOVESOURCE,
541
		GNOME_VFS_XFER_ERROR_MODE_ABORT, GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE, NULL, NULL);
542
543
	if (retval != GNOME_VFS_OK) {
544
		trash_uri_str = gnome_vfs_uri_to_string (trash_uri, GNOME_VFS_URI_HIDE_NONE);
545
546
		g_warning ("unable to move [%s] to the trash [%s]\n", TILE (tile)->uri,
547
			trash_uri_str);
548
549
		g_free (trash_uri_str);
550
	}
551
552
	gnome_vfs_uri_unref (src_uri);
553
	gnome_vfs_uri_unref (trash_uri);
554
555
	g_free (file_name);
556
}
557
558
static void
559
delete_trigger (Tile *tile, TileEvent *event, TileAction *action)
560
{
561
	GnomeVFSURI *src_uri;
562
	GList *list = NULL;
563
564
	GnomeVFSResult retval;
565
566
567
	src_uri = gnome_vfs_uri_new (TILE (tile)->uri);
568
569
	list = g_list_append (list, src_uri);
570
571
	retval = gnome_vfs_xfer_delete_list (list, GNOME_VFS_XFER_ERROR_MODE_ABORT,
572
		GNOME_VFS_XFER_REMOVESOURCE, NULL, NULL);
573
574
	if (retval != GNOME_VFS_OK)
575
		g_warning ("unable to delete [%s]\n", TILE (tile)->uri);
576
577
	gnome_vfs_uri_unref (src_uri);
578
	g_list_free (list);
579
}
580
581
static void
582
send_to_trigger (Tile *tile, TileEvent *event, TileAction *action)
583
{
584
	gchar  *cmd;
585
	gint    argc;
586
	gchar **argv_parsed = NULL;
587
	gchar **argv        = NULL;
588
589
	gchar *path;
590
	gchar *dirname;
591
	gchar *basename;
592
593
	GError *error = NULL;
594
595
	gint i;
596
597
598
	cmd = (gchar *) get_gconf_value (GCONF_SEND_TO_CMD_KEY);
599
600
	if (! g_shell_parse_argv (cmd, & argc, & argv_parsed, NULL))
601
		goto exit;
602
603
	argv = g_new0 (gchar *, argc + 1);
604
605
	path     = g_filename_from_uri (tile->uri, NULL, NULL);
606
	dirname  = g_path_get_dirname  (path);
607
	basename = g_path_get_basename (path);
608
609
	for (i = 0; i < argc; ++i) {
610
		if (strstr (argv_parsed [i], "DIRNAME"))
611
			argv [i] = string_replace_once (argv_parsed [i], "DIRNAME", dirname);
612
		else if (strstr (argv_parsed [i], "BASENAME"))
613
			argv [i] = string_replace_once (argv_parsed [i], "BASENAME", basename);
614
		else
615
			argv [i] = g_strdup (argv_parsed [i]);
616
	}
617
618
	argv [argc] = NULL;
619
620
	g_free (path);
621
	g_free (dirname);
622
	g_free (basename);
623
624
	g_spawn_async (
625
		NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
626
		disown_spawned_child, NULL, NULL, & error);
627
628
	if (error) {
629
		cmd = g_strjoinv (" ", argv);
630
		libslab_handle_g_error (
631
			& error, "%s: can't execute search [%s]\n", G_STRFUNC, cmd);
632
		g_free (cmd);
633
	}
634
635
	g_strfreev (argv);
636
637
exit:
638
639
	g_free (cmd);
640
	g_strfreev (argv_parsed);
641
}
642
643
static void
644
disown_spawned_child (gpointer user_data)
645
{
646
	setsid  ();
647
	setpgid (0, 0);
648
}
(-)libslab/bookmark-agent.c (+63 lines)
Lines 121-126 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 save_places_store        (BookmarkAgent *);
124
static void load_recent_store        (BookmarkAgent *);
125
static void load_recent_store        (BookmarkAgent *);
125
static void update_user_spec_path    (BookmarkAgent *);
126
static void update_user_spec_path    (BookmarkAgent *);
126
static void update_recent_store_path (BookmarkAgent *);
127
static void update_recent_store_path (BookmarkAgent *);
Lines 446-451 Link Here
446
			priv->reorderable     = FALSE;
447
			priv->reorderable     = FALSE;
447
448
448
			priv->load_store = load_places_store;
449
			priv->load_store = load_places_store;
450
			priv->save_store = save_places_store;
449
451
450
			priv->gtk_store_path = g_build_filename (g_get_home_dir (), GTK_BOOKMARKS_FILE, NULL);
452
			priv->gtk_store_path = g_build_filename (g_get_home_dir (), GTK_BOOKMARKS_FILE, NULL);
451
			gnome_vfs_monitor_add (
453
			gnome_vfs_monitor_add (
Lines 822-827 Link Here
822
}
824
}
823
825
824
static void
826
static void
827
save_places_store (BookmarkAgent *this)
828
{
829
	BookmarkAgentPrivate *priv = PRIVATE (this);
830
	
831
	GError *error = NULL;
832
	
833
	gchar *buffer = NULL;
834
	gchar **uris;
835
	gint i;
836
	gsize count;
837
	
838
	
839
	if (! g_bookmark_file_to_file (priv->store, priv->store_path, & error))
840
		libslab_handle_g_error (
841
			& error, "%s: couldn't save bookmark file [%s]\n", G_STRFUNC, priv->store_path);
842
	
843
	uris = g_bookmark_file_get_uris (priv->store, & count);
844
	
845
	for (i = 0; uris && uris [i]; i++) {
846
		gchar **groups;
847
		gint j;
848
		
849
		groups = g_bookmark_file_get_groups (priv->store, uris [i], & count, & error);
850
		
851
		for (j = 0; groups && groups [j]; j++) {
852
			gchar *line;
853
			gchar *label;
854
855
			if (g_ascii_strcasecmp (groups [j], "gtk-bookmarks"))
856
				continue;
857
			
858
			label = g_bookmark_file_get_title (priv->store, uris [i], NULL);
859
860
			if (label != NULL) {
861
				line = g_strconcat (uris [i], " ", label, "\n", NULL);
862
				g_free (label);
863
			} else {
864
				line = g_strconcat (uris [i], "\n", NULL);
865
			}
866
			
867
			if (buffer != NULL) {
868
				gchar *temp = buffer;
869
				buffer = g_strconcat (buffer, line, NULL);
870
				g_free (temp);
871
				g_free (line);
872
			} else {
873
				buffer = line;
874
			}
875
		}
876
		
877
		g_strfreev (groups);
878
	}
879
	
880
	g_strfreev (uris);
881
882
	if (! g_file_set_contents (priv->gtk_store_path, buffer, -1, & error))
883
		libslab_handle_g_error (
884
			& error, "%s: couldn't save gtk-bookmark file [%s]\n", G_STRFUNC, priv->store_path);
885
}
886
887
static void
825
load_recent_store (BookmarkAgent *this)
888
load_recent_store (BookmarkAgent *this)
826
{
889
{
827
	BookmarkAgentPrivate *priv = PRIVATE (this);
890
	BookmarkAgentPrivate *priv = PRIVATE (this);
(-)libslab/directory-tile.h (-5 / +2 lines)
Lines 42-52 Link Here
42
	NameplateTileClass nameplate_tile_class;
42
	NameplateTileClass nameplate_tile_class;
43
} DirectoryTileClass;
43
} DirectoryTileClass;
44
44
45
#define DIRECTORY_TILE_ACTION_OPEN          0
45
#define DIRECTORY_TILE_ACTION_OPEN            0
46
#define DIRECTORY_TILE_ACTION_RENAME        1
46
#define DIRECTORY_TILE_ACTION_REMOVE_FAVORITE 1
47
#define DIRECTORY_TILE_ACTION_MOVE_TO_TRASH 2
48
#define DIRECTORY_TILE_ACTION_DELETE        3
49
#define DIRECTORY_TILE_ACTION_SEND_TO       4
50
47
51
GType directory_tile_get_type (void);
48
GType directory_tile_get_type (void);
52
49

Return to bug 309058