[Xfce4-commits] <thunar:jannis/new-shortcuts-pane> Prepare cancellation of pending activations, sensitivity of sendto item.

Jannis Pohlmann noreply at xfce.org
Sun Nov 6 23:36:01 CET 2011


Updating branch refs/heads/jannis/new-shortcuts-pane
         to 79c535f5c5c76235fad98f4369d0e5bf84935f50 (commit)
       from 098e2c7a996247e8d65bbbc87faf3cd3abb59527 (commit)

commit 79c535f5c5c76235fad98f4369d0e5bf84935f50
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Sun Nov 6 23:34:52 2011 +0100

    Prepare cancellation of pending activations, sensitivity of sendto item.

 thunar/thunar-shortcut-group.c |   64 ++++++++++++++++++++++++++++++++++++++++
 thunar/thunar-shortcut-group.h |    5 +++
 thunar/thunar-shortcut.c       |   10 ++++++
 thunar/thunar-shortcut.h       |    1 +
 thunar/thunar-shortcuts-view.c |   47 +++++++++--------------------
 5 files changed, 94 insertions(+), 33 deletions(-)

diff --git a/thunar/thunar-shortcut-group.c b/thunar/thunar-shortcut-group.c
index f4ff2fa..9b23619 100644
--- a/thunar/thunar-shortcut-group.c
+++ b/thunar/thunar-shortcut-group.c
@@ -411,6 +411,32 @@ thunar_shortcut_group_unprelight_shortcuts (ThunarShortcutGroup *group,
 
 
 void
+thunar_shortcut_group_cancel_activations (ThunarShortcutGroup *group,
+                                          ThunarShortcut      *exception)
+{
+  ThunarShortcut *shortcut;
+  GList          *children;
+  GList          *iter;
+
+  _thunar_return_if_fail (THUNAR_IS_SHORTCUT_GROUP (group));
+  _thunar_return_if_fail (exception == NULL || THUNAR_IS_SHORTCUT (exception));
+
+  children = gtk_container_get_children (GTK_CONTAINER (group->shortcuts));
+
+  for (iter = children; iter != NULL; iter = iter->next)
+    {
+      shortcut = THUNAR_SHORTCUT (iter->data);
+
+      if (shortcut != exception)
+        thunar_shortcut_cancel_activation (shortcut);
+    }
+
+  g_list_free (children);
+}
+
+
+
+void
 thunar_shortcut_group_update_selection (ThunarShortcutGroup *group,
                                         ThunarFile          *file)
 {
@@ -497,3 +523,41 @@ thunar_shortcut_group_remove_mount_shortcut (ThunarShortcutGroup *group,
 
   g_list_free (children);
 }
+
+
+
+gboolean
+thunar_shortcut_group_find_shortcut_by_file (ThunarShortcutGroup *group,
+                                             ThunarFile          *file,
+                                             ThunarShortcut     **result)
+{
+  ThunarShortcut *shortcut;
+  gboolean         has_shortcut = FALSE;
+  GList           *children;
+  GList           *iter;
+
+  _thunar_return_val_if_fail (THUNAR_IS_SHORTCUT_GROUP (group), FALSE);
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+
+  children = gtk_container_get_children (GTK_CONTAINER (group->shortcuts));
+
+  if (result != NULL)
+    *result = NULL;
+
+  for (iter = children; !has_shortcut && iter != NULL; iter = iter->next)
+    {
+      shortcut = THUNAR_SHORTCUT (iter->data);
+
+      if (thunar_shortcut_matches_file (shortcut, file))
+        {
+          if (result != NULL)
+            *result = shortcut;
+
+          has_shortcut = TRUE;
+        }
+    }
+
+  g_list_free (children);
+
+  return has_shortcut;
+}
diff --git a/thunar/thunar-shortcut-group.h b/thunar/thunar-shortcut-group.h
index 0590d09..eed1d66 100644
--- a/thunar/thunar-shortcut-group.h
+++ b/thunar/thunar-shortcut-group.h
@@ -47,12 +47,17 @@ void       thunar_shortcut_group_unselect_shortcuts     (ThunarShortcutGroup *gr
                                                          ThunarShortcut      *exception);
 void       thunar_shortcut_group_unprelight_shortcuts   (ThunarShortcutGroup *group,
                                                          ThunarShortcut      *exception);
+void       thunar_shortcut_group_cancel_activations     (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);
+gboolean   thunar_shortcut_group_find_shortcut_by_file  (ThunarShortcutGroup *group,
+                                                         ThunarFile          *file,
+                                                         ThunarShortcut     **result);
 
 G_END_DECLS
 
diff --git a/thunar/thunar-shortcut.c b/thunar/thunar-shortcut.c
index c619dd4..c13e51c 100644
--- a/thunar/thunar-shortcut.c
+++ b/thunar/thunar-shortcut.c
@@ -2049,6 +2049,16 @@ thunar_shortcut_resolve_and_activate (ThunarShortcut *shortcut,
 
 
 void
+thunar_shortcut_cancel_activation (ThunarShortcut *shortcut)
+{
+  _thunar_return_if_fail (THUNAR_IS_SHORTCUT (shortcut));
+
+  /* TODO we need a cancellable for the ThunarBrowser interface */
+}
+
+
+
+void
 thunar_shortcut_mount (ThunarShortcut *shortcut)
 {
   _thunar_return_if_fail (THUNAR_IS_SHORTCUT (shortcut));
diff --git a/thunar/thunar-shortcut.h b/thunar/thunar-shortcut.h
index 3e0a047..59395f1 100644
--- a/thunar/thunar-shortcut.h
+++ b/thunar/thunar-shortcut.h
@@ -83,6 +83,7 @@ void               thunar_shortcut_set_persistent       (ThunarShortcut    *shor
                                                          gboolean           persistent);
 void               thunar_shortcut_resolve_and_activate (ThunarShortcut    *shortcut,
                                                          gboolean           open_in_new_window);
+void               thunar_shortcut_cancel_activation    (ThunarShortcut    *shortcut);
 void               thunar_shortcut_mount                (ThunarShortcut    *shortcut);
 void               thunar_shortcut_unmount              (ThunarShortcut    *shortcut);
 void               thunar_shortcut_disconnect           (ThunarShortcut    *shortcut);
diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c
index 155cf21..ac55bb4 100644
--- a/thunar/thunar-shortcuts-view.c
+++ b/thunar/thunar-shortcuts-view.c
@@ -358,35 +358,6 @@ thunar_shortcuts_view_set_property (GObject      *object,
 
 
 
-static void
-thunar_shortcuts_view_open (ThunarShortcutsView *view,
-                            ThunarFile          *file,
-                            gboolean             new_window)
-{
-  ThunarApplication *application;
-
-  _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
-  _thunar_return_if_fail (THUNAR_IS_FILE (file));
-
-  if (new_window)
-    {
-      /* open the file in a new window */
-      application = thunar_application_get ();
-      thunar_application_open_window (application, file,
-                                      gtk_widget_get_screen (GTK_WIDGET (view)),
-                                      NULL);
-      g_object_unref (application);
-    }
-  else
-    {
-      /* invoke the signal to change to the folder */
-      g_signal_emit (view, view_signals[SHORTCUT_ACTIVATED], 0, file);
-    }
-}
-#endif
-
-
-
 static gboolean
 thunar_shortcuts_view_load_system_shortcuts (gpointer user_data)
 {
@@ -1434,12 +1405,24 @@ gboolean
 thunar_shortcuts_view_has_file (ThunarShortcutsView *view,
                                 ThunarFile          *file)
 {
+  gboolean has_file = FALSE;
+  GList   *groups;
+  GList   *iter;
+
   _thunar_return_val_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view), FALSE);
   _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
 
-  /* TODO */
+  groups = gtk_container_get_children (GTK_CONTAINER (view->group_box));
 
-  return FALSE;
+  for (iter = groups; !has_file && iter != NULL; iter = iter->next)
+    {
+      if (thunar_shortcut_group_find_shortcut_by_file (iter->data, file, NULL))
+        has_file = TRUE;
+    }
+
+  g_list_free (groups);
+
+  return has_file;
 }
 
 
@@ -1475,5 +1458,3 @@ thunar_shortcuts_view_select_by_file (ThunarShortcutsView *view,
   thunar_shortcuts_view_foreach_group (view, thunar_shortcuts_view_update_selection,
                                        file);
 }
-
-


More information about the Xfce4-commits mailing list