[Xfce4-commits] [xfce/thunar] 01/01: Add computer:/// to Go menu (Bug #16472)
noreply at xfce.org
noreply at xfce.org
Thu Feb 27 23:52:36 CET 2020
This is an automated email from the git hooks/post-receive script.
a l e x p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/thunar.
commit e0def00a1fbb858e7cc0deef66162d672eb60d0f
Author: Yousuf Philips <philipz85 at hotmail.com>
Date: Thu Feb 27 23:49:57 2020 +0100
Add computer:/// to Go menu (Bug #16472)
---
thunar/thunar-gio-extensions.c | 8 ++++++++
thunar/thunar-gio-extensions.h | 1 +
thunar/thunar-window-ui.xml | 1 +
thunar/thunar-window.c | 37 +++++++++++++++++++++++++++++++++++++
4 files changed, 47 insertions(+)
diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c
index a72bef4..93bd64f 100644
--- a/thunar/thunar-gio-extensions.c
+++ b/thunar/thunar-gio-extensions.c
@@ -65,6 +65,14 @@ thunar_g_file_new_for_trash (void)
GFile *
+thunar_g_file_new_for_computer (void)
+{
+ return g_file_new_for_uri ("computer:///");
+}
+
+
+
+GFile *
thunar_g_file_new_for_desktop (void)
{
return g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
diff --git a/thunar/thunar-gio-extensions.h b/thunar/thunar-gio-extensions.h
index 48cc8ac..28a63e4 100644
--- a/thunar/thunar-gio-extensions.h
+++ b/thunar/thunar-gio-extensions.h
@@ -29,6 +29,7 @@ GFile *thunar_g_file_new_for_home (void);
GFile *thunar_g_file_new_for_root (void);
GFile *thunar_g_file_new_for_trash (void);
GFile *thunar_g_file_new_for_desktop (void);
+GFile *thunar_g_file_new_for_computer (void);
GFile *thunar_g_file_new_for_bookmarks (void);
gboolean thunar_g_file_is_root (GFile *file);
diff --git a/thunar/thunar-window-ui.xml b/thunar/thunar-window-ui.xml
index d251a70..457b82b 100644
--- a/thunar/thunar-window-ui.xml
+++ b/thunar/thunar-window-ui.xml
@@ -80,6 +80,7 @@
<menuitem action="open-home" />
<menuitem action="open-desktop" />
+ <menuitem action="open-computer" />
<placeholder name="placeholder-go-items-actions" />
<menuitem action="open-file-system" />
<menuitem action="open-templates" />
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 81d528a..b37e678 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -201,6 +201,8 @@ static void thunar_window_action_open_home (GtkAction
ThunarWindow *window);
static void thunar_window_action_open_desktop (GtkAction *action,
ThunarWindow *window);
+static void thunar_window_action_open_computer (GtkAction *action,
+ ThunarWindow *window);
static void thunar_window_action_open_templates (GtkAction *action,
ThunarWindow *window);
static void thunar_window_action_open_file_system (GtkAction *action,
@@ -376,6 +378,7 @@ static GtkActionEntry action_entries[] =
{ "open-parent", "go-up-symbolic", N_ ("Open _Parent"), "<alt>Up", N_ ("Open the parent folder"), G_CALLBACK (thunar_window_action_go_up), },
{ "open-home", "go-home-symbolic", N_ ("_Home"), "<alt>Home", N_ ("Go to the home folder"), G_CALLBACK (thunar_window_action_open_home), },
{ "open-desktop", "user-desktop", N_ ("Desktop"), NULL, N_ ("Go to the desktop folder"), G_CALLBACK (thunar_window_action_open_desktop), },
+ { "open-computer", "computer-symbolic", N_ ("Computer"), NULL, N_ ("Go to the computer folder"), G_CALLBACK (thunar_window_action_open_computer), },
{ "open-file-system", "drive-harddisk", N_ ("File System"), NULL, N_ ("Browse the file system"), G_CALLBACK (thunar_window_action_open_file_system), },
{ "open-network", "network-workgroup", N_("B_rowse Network"), NULL, N_ ("Browse local network connections"), G_CALLBACK (thunar_window_action_open_network), },
{ "open-templates", "text-x-generic-template", N_("T_emplates"), NULL, N_ ("Go to the templates folder"), G_CALLBACK (thunar_window_action_open_templates), },
@@ -3095,6 +3098,40 @@ G_GNUC_END_IGNORE_DEPRECATIONS
static void
+thunar_window_action_open_computer (GtkAction *action,
+ ThunarWindow *window)
+{
+ GFile *computer;
+ ThunarFile *computer_file;
+ GError *error = NULL;
+
+ _thunar_return_if_fail (THUNAR_IS_WINDOW (window));
+
+ /* determine the path to the computer directory */
+ computer = thunar_g_file_new_for_computer ();
+
+ /* determine the file for the computer directory */
+ computer_file = thunar_file_get (computer, &error);
+ if (G_UNLIKELY (computer_file == NULL))
+ {
+ /* display an error to the user */
+ thunar_dialogs_show_error (GTK_WIDGET (window), error, _("Failed to open the computer folder"));
+ g_error_free (error);
+ }
+ else
+ {
+ /* open the computer folder */
+ thunar_window_set_current_directory (window, computer_file);
+ g_object_unref (G_OBJECT (computer_file));
+ }
+
+ /* release our reference on the computer path */
+ g_object_unref (computer);
+}
+
+
+
+static void
thunar_window_action_open_templates (GtkAction *action,
ThunarWindow *window)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list