Updating branch refs/heads/jannis/new-shortcuts-pane
to fbe09422f8193865eb415068a7706bc5484c5bee (commit)
from 6d9c903dab4c5f175215e05765a0452abd537089 (commit)
commit fbe09422f8193865eb415068a7706bc5484c5bee
Author: Jannis Pohlmann <[email protected]>
Date: Sun Nov 6 17:40:02 2011 +0100
Squashme: Remove volume/mount shortcuts properly (unless persistent).
thunar/thunar-shortcut-group.c | 62 ++++++++++++++++++++++
thunar/thunar-shortcut-group.h | 28 ++++++----
thunar/thunar-shortcuts-view.c | 111 ++++++++++++++++++++++++++++------------
3 files changed, 156 insertions(+), 45 deletions(-)
diff --git a/thunar/thunar-shortcut-group.c b/thunar/thunar-shortcut-group.c
index f774bf4..f4ff2fa 100644
--- a/thunar/thunar-shortcut-group.c
+++ b/thunar/thunar-shortcut-group.c
@@ -435,3 +435,65 @@ thunar_shortcut_group_update_selection
(ThunarShortcutGroup *group,
g_list_free (children);
}
+
+
+
+void
+thunar_shortcut_group_remove_volume_shortcut (ThunarShortcutGroup *group,
+ GVolume *volume)
+{
+ ThunarShortcut *shortcut;
+ GVolume *shortcut_volume;
+ GList *children;
+ GList *iter;
+
+ _thunar_return_if_fail (THUNAR_IS_SHORTCUT_GROUP (group));
+ _thunar_return_if_fail (G_IS_VOLUME (volume));
+
+ children = gtk_container_get_children (GTK_CONTAINER (group->shortcuts));
+
+ for (iter = children; iter != NULL; iter = iter->next)
+ {
+ shortcut = THUNAR_SHORTCUT (iter->data);
+ shortcut_volume = thunar_shortcut_get_volume (shortcut);
+
+ if (shortcut_volume == volume)
+ gtk_container_remove (GTK_CONTAINER (group->shortcuts),
+ GTK_WIDGET (shortcut));
+ }
+
+ g_list_free (children);
+}
+
+
+
+void
+thunar_shortcut_group_remove_mount_shortcut (ThunarShortcutGroup *group,
+ GMount *mount)
+{
+ ThunarShortcut *shortcut;
+ GMount *shortcut_mount;
+ GList *children;
+ GList *iter;
+
+ _thunar_return_if_fail (THUNAR_IS_SHORTCUT_GROUP (group));
+ _thunar_return_if_fail (G_IS_MOUNT (mount));
+
+ children = gtk_container_get_children (GTK_CONTAINER (group->shortcuts));
+
+ for (iter = children; iter != NULL; iter = iter->next)
+ {
+ shortcut = THUNAR_SHORTCUT (iter->data);
+
+ if (!thunar_shortcut_get_persistent (shortcut))
+ {
+ shortcut_mount = thunar_shortcut_get_mount (shortcut);
+
+ if (shortcut_mount == mount)
+ gtk_container_remove (GTK_CONTAINER (group->shortcuts),
+ GTK_WIDGET (shortcut));
+ }
+ }
+
+ g_list_free (children);
+}
diff --git a/thunar/thunar-shortcut-group.h b/thunar/thunar-shortcut-group.h
index 7112b33..0590d09 100644
--- a/thunar/thunar-shortcut-group.h
+++ b/thunar/thunar-shortcut-group.h
@@ -37,18 +37,22 @@ typedef struct _ThunarShortcutGroupPrivate
ThunarShortcutGroupPrivate;
typedef struct _ThunarShortcutGroupClass ThunarShortcutGroupClass;
typedef struct _ThunarShortcutGroup ThunarShortcutGroup;
-GType thunar_shortcut_group_get_type (void) G_GNUC_CONST;
-
-GtkWidget *thunar_shortcut_group_new (const gchar
*label,
- ThunarShortcutType
accepted_types);
-gboolean thunar_shortcut_group_try_add_shortcut (ThunarShortcutGroup
*group,
- ThunarShortcut
*shortcut);
-void thunar_shortcut_group_unselect_shortcuts (ThunarShortcutGroup
*group,
- ThunarShortcut
*exception);
-void thunar_shortcut_group_unprelight_shortcuts (ThunarShortcutGroup
*group,
- ThunarShortcut
*exception);
-void thunar_shortcut_group_update_selection (ThunarShortcutGroup
*group,
- ThunarFile
*file);
+GType thunar_shortcut_group_get_type (void) G_GNUC_CONST;
+
+GtkWidget *thunar_shortcut_group_new (const gchar
*label,
+ ThunarShortcutType
accepted_types);
+gboolean thunar_shortcut_group_try_add_shortcut (ThunarShortcutGroup
*group,
+ ThunarShortcut
*shortcut);
+void thunar_shortcut_group_unselect_shortcuts (ThunarShortcutGroup
*group,
+ ThunarShortcut
*exception);
+void thunar_shortcut_group_unprelight_shortcuts (ThunarShortcutGroup
*group,
+ ThunarShortcut
*exception);
+void thunar_shortcut_group_update_selection (ThunarShortcutGroup
*group,
+ ThunarFile
*file);
+void thunar_shortcut_group_remove_volume_shortcut (ThunarShortcutGroup
*group,
+ GVolume
*volume);
+void thunar_shortcut_group_remove_mount_shortcut (ThunarShortcutGroup
*group,
+ GMount
*mount);
G_END_DECLS
diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c
index f007930..3990774 100644
--- a/thunar/thunar-shortcuts-view.c
+++ b/thunar/thunar-shortcuts-view.c
@@ -104,6 +104,18 @@ static void
thunar_shortcuts_view_volume_added (Thunar
static void thunar_shortcuts_view_mount_added
(ThunarShortcutsView *view,
GMount *mount,
GVolumeMonitor *monitor);
+static void thunar_shortcuts_view_volume_removed
(ThunarShortcutsView *view,
+
GVolume *volume,
+
GVolumeMonitor *monitor);
+static void thunar_shortcuts_view_remove_volume_shortcut
(ThunarShortcutsView *view,
+
ThunarShortcutGroup *group,
+
gpointer user_data);
+static void thunar_shortcuts_view_mount_removed
(ThunarShortcutsView *view,
+
GMount *mount,
+
GVolumeMonitor *monitor);
+static void thunar_shortcuts_view_remove_mount_shortcut
(ThunarShortcutsView *view,
+
ThunarShortcutGroup *group,
+
gpointer user_data);
static void thunar_shortcuts_view_add_shortcut
(ThunarShortcutsView *view,
ThunarShortcut *shortcut);
static void thunar_shortcuts_view_shortcut_activated
(ThunarShortcutsView *view,
@@ -126,27 +138,9 @@ static void thunar_shortcuts_view_open
(Thunar
ThunarFile *file,
gboolean new_window);
#if 0
-static void thunar_shortcuts_view_row_inserted
(ThunarShortcutsView *view,
-
GtkTreePath *path,
-
GtkTreeIter *iter,
-
GtkTreeModel *model);
static void thunar_shortcuts_view_row_deleted
(ThunarShortcutsView *view,
GtkTreePath *path,
GtkTreeModel *model);
-static void thunar_shortcuts_view_row_changed
(ThunarShortcutsView *view,
-
GtkTreePath *path,
-
GtkTreeIter *iter,
-
GtkTreeModel *model);
-static gboolean thunar_shortcuts_view_flash_expander
(gpointer user_data);
-static GtkWidget * thunar_shortcuts_view_get_expander_at
(ThunarShortcutsView *view,
- gint
index);
-static void thunar_shortcuts_view_row_activated
(ThunarShortcutsView *view,
-
ThunarFile *file,
-
gboolean open_in_new_window,
-
ThunarShortcutRow *row);
-static void thunar_shortcuts_view_row_state_changed
(ThunarShortcutsView *view,
-
GtkStateType previous_state,
-
ThunarShortcutRow *row);
static gboolean thunar_shortcuts_view_row_context_menu
(ThunarShortcutsView *view,
GtkWidget *widget);
static void thunar_shortcuts_view_row_open
(ThunarShortcutsView *view);
@@ -161,15 +155,6 @@ static ThunarShortcutRow
*thunar_shortcuts_view_get_selected_row (Thunar
static void thunar_shortcuts_view_find_selected_row
(ThunarShortcutsView *view,
ThunarShortcutRow *row,
gpointer user_data);
-static void thunar_shortcuts_view_foreach_row
(ThunarShortcutsView *view,
-
ThunarShortcutsViewForeachRowFunc func,
-
gpointer user_data);
-static void thunar_shortcuts_view_unselect_rows
(ThunarShortcutsView *view,
-
ThunarShortcutRow *row,
-
gpointer user_data);
-static void thunar_shortcuts_view_unprelight_rows
(ThunarShortcutsView *view,
-
ThunarShortcutRow *row,
-
gpointer user_data);
#endif
static void thunar_shortcuts_view_update_selection
(ThunarShortcutsView *view,
ThunarShortcutGroup *group,
@@ -1133,16 +1118,12 @@ thunar_shortcuts_view_load_volumes (gpointer user_data)
/* be notified of new and removed volumes on the system */
g_signal_connect_swapped (view->volume_monitor, "volume-added",
G_CALLBACK (thunar_shortcuts_view_volume_added),
view);
-#if 0
g_signal_connect_swapped (view->volume_monitor, "volume-removed",
G_CALLBACK (thunar_shortcuts_view_volume_removed),
view);
-#endif
g_signal_connect_swapped (view->volume_monitor, "mount-added",
G_CALLBACK (thunar_shortcuts_view_mount_added),
view);
-#if 0
g_signal_connect_swapped (view->volume_monitor, "mount-removed",
G_CALLBACK (thunar_shortcuts_view_mount_removed),
view);
-#endif
/* reset the load idle ID */
view->load_idle_id = 0;
@@ -1197,9 +1178,41 @@ thunar_shortcuts_view_volume_added (ThunarShortcutsView
*view,
static void
+thunar_shortcuts_view_volume_removed (ThunarShortcutsView *view,
+ GVolume *volume,
+ GVolumeMonitor *monitor)
+{
+ _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
+ _thunar_return_if_fail (G_IS_VOLUME (volume));
+ _thunar_return_if_fail (G_IS_VOLUME_MONITOR (monitor));
+
+ thunar_shortcuts_view_foreach_group (view,
+
thunar_shortcuts_view_remove_volume_shortcut,
+ volume);
+}
+
+
+
+static void
+thunar_shortcuts_view_remove_volume_shortcut (ThunarShortcutsView *view,
+ ThunarShortcutGroup *group,
+ gpointer user_data)
+{
+ GVolume *volume = G_VOLUME (user_data);
+
+ _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
+ _thunar_return_if_fail (THUNAR_IS_SHORTCUT_GROUP (group));
+ _thunar_return_if_fail (G_IS_VOLUME (volume));
+
+ thunar_shortcut_group_remove_volume_shortcut (group, volume);
+}
+
+
+
+static void
thunar_shortcuts_view_mount_added (ThunarShortcutsView *view,
- GMount *mount,
- GVolumeMonitor *monitor)
+ GMount *mount,
+ GVolumeMonitor *monitor)
{
ThunarShortcutType shortcut_type;
ThunarShortcut *shortcut;
@@ -1255,6 +1268,38 @@ thunar_shortcuts_view_mount_added (ThunarShortcutsView
*view,
static void
+thunar_shortcuts_view_mount_removed (ThunarShortcutsView *view,
+ GMount *mount,
+ GVolumeMonitor *monitor)
+{
+ _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
+ _thunar_return_if_fail (G_IS_MOUNT (mount));
+ _thunar_return_if_fail (G_IS_VOLUME_MONITOR (monitor));
+
+ thunar_shortcuts_view_foreach_group (view,
+
thunar_shortcuts_view_remove_mount_shortcut,
+ mount);
+}
+
+
+
+static void
+thunar_shortcuts_view_remove_mount_shortcut (ThunarShortcutsView *view,
+ ThunarShortcutGroup *group,
+ gpointer user_data)
+{
+ GMount *mount = G_MOUNT (user_data);
+
+ _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
+ _thunar_return_if_fail (THUNAR_IS_SHORTCUT_GROUP (group));
+ _thunar_return_if_fail (G_IS_MOUNT (mount));
+
+ thunar_shortcut_group_remove_mount_shortcut (group, mount);
+}
+
+
+
+static void
thunar_shortcuts_view_add_shortcut (ThunarShortcutsView *view,
ThunarShortcut *shortcut)
{
_______________________________________________
Xfce4-commits mailing list
[email protected]
https://mail.xfce.org/mailman/listinfo/xfce4-commits