[gimp] Bug 723901 - Add open in file manager button in Folders settings
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 723901 - Add open in file manager button in Folders settings
- Date: Sun, 29 Mar 2015 21:52:56 +0000 (UTC)
commit 9b6bacc0d8569375fc69edb6b9a7c7d4e201197d
Author: Michael Natterer <mitch gimp org>
Date: Sun Mar 29 23:52:11 2015 +0200
Bug 723901 - Add open in file manager button in Folders settings
Add the button, using the new gimp_file_show_in_file_manager() API.
libgimpwidgets/gimpfileentry.c | 60 ++++++++++++++++++++++++++++++++++------
1 files changed, 51 insertions(+), 9 deletions(-)
---
diff --git a/libgimpwidgets/gimpfileentry.c b/libgimpwidgets/gimpfileentry.c
index c403397..90ccf10 100644
--- a/libgimpwidgets/gimpfileentry.c
+++ b/libgimpwidgets/gimpfileentry.c
@@ -25,6 +25,8 @@
#include <gtk/gtk.h>
+#include "libgimpbase/gimpbase.h"
+
#include "gimpwidgetstypes.h"
#undef GIMP_DISABLE_DEPRECATED
@@ -66,16 +68,18 @@ enum
};
-static void gimp_file_entry_dispose (GObject *object);
+static void gimp_file_entry_dispose (GObject *object);
-static void gimp_file_entry_entry_activate (GtkWidget *widget,
- GimpFileEntry *entry);
-static gint gimp_file_entry_entry_focus_out (GtkWidget *widget,
- GdkEvent *event,
- GimpFileEntry *entry);
-static void gimp_file_entry_browse_clicked (GtkWidget *widget,
- GimpFileEntry *entry);
-static void gimp_file_entry_check_filename (GimpFileEntry *entry);
+static void gimp_file_entry_entry_activate (GtkWidget *widget,
+ GimpFileEntry *entry);
+static gint gimp_file_entry_entry_focus_out (GtkWidget *widget,
+ GdkEvent *event,
+ GimpFileEntry *entry);
+static void gimp_file_entry_file_manager_clicked (GtkWidget *widget,
+ GimpFileEntry *entry);
+static void gimp_file_entry_browse_clicked (GtkWidget *widget,
+ GimpFileEntry *entry);
+static void gimp_file_entry_check_filename (GimpFileEntry *entry);
G_DEFINE_TYPE (GimpFileEntry, gimp_file_entry, GTK_TYPE_BOX)
@@ -113,6 +117,7 @@ static void
gimp_file_entry_init (GimpFileEntry *entry)
{
GtkWidget *image;
+ GtkWidget *button;
entry->title = NULL;
entry->file_dialog = NULL;
@@ -125,6 +130,21 @@ gimp_file_entry_init (GimpFileEntry *entry)
gtk_box_set_spacing (GTK_BOX (entry), 4);
gtk_box_set_homogeneous (GTK_BOX (entry), FALSE);
+ button = gtk_button_new ();
+ gtk_box_pack_end (GTK_BOX (entry), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
+
+ image = gtk_image_new_from_icon_name ("gtk-directory", GTK_ICON_SIZE_BUTTON);
+ gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_widget_show (image);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (gimp_file_entry_file_manager_clicked),
+ entry);
+
+ gimp_help_set_help_data (button,
+ _("Show file location in the file manager"), NULL);
+
entry->browse_button = gtk_button_new ();
gtk_box_pack_end (GTK_BOX (entry), entry->browse_button, FALSE, FALSE, 0);
gtk_widget_show (entry->browse_button);
@@ -340,6 +360,28 @@ gimp_file_entry_chooser_response (GtkWidget *dialog,
}
static void
+gimp_file_entry_file_manager_clicked (GtkWidget *widget,
+ GimpFileEntry *entry)
+{
+ gchar *utf8;
+ GFile *file;
+ GError *error = NULL;
+
+ utf8 = gtk_editable_get_chars (GTK_EDITABLE (entry->entry), 0, -1);
+ file = g_file_parse_name (utf8);
+ g_free (utf8);
+
+ if (! gimp_file_show_in_file_manager (file, &error))
+ {
+ g_message (_("Can't show file in file manager: %s"),
+ error->message);
+ g_clear_error (&error);
+ }
+
+ g_object_unref (file);
+}
+
+static void
gimp_file_entry_browse_clicked (GtkWidget *widget,
GimpFileEntry *entry)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]