[Xfce4-commits] <ristretto:master> Merge branch 'stephan/properties-dialog'

Stephan Arts noreply at xfce.org
Sun Sep 25 19:30:12 CEST 2011


Updating branch refs/heads/master
         to 02be3c95c1caf226bdd59a09f9871a2e7ab207dc (commit)
       from bd819d9d78be1db21c7d991cbc34cf2d3a6788ae (commit)

commit 02be3c95c1caf226bdd59a09f9871a2e7ab207dc
Merge: bd819d9 68151bc
Author: Stephan Arts <stephan at xfce.org>
Date:   Sun Sep 25 19:27:43 2011 +0200

    Merge branch 'stephan/properties-dialog'

commit 68151bcb4be5d47922459582ea684bc56e9e1c71
Author: Stephan Arts <stephan at xfce.org>
Date:   Sun Sep 25 19:27:04 2011 +0200

    Add 'use-thunar-properties' setting.

commit 040bad4a9156dca43a1278a0d02f6117269ca9d8
Author: Stephan Arts <stephan at xfce.org>
Date:   Sun Sep 25 09:10:54 2011 +0200

    cleanup set_property function

commit 1d2c01fb5b3afea16fced5053c0614eb4a9416d3
Author: Stephan Arts <stephan at xfce.org>
Date:   Sun Sep 25 08:46:23 2011 +0200

    Add some data to the properties-dialog
    
    Show the filename and mimetype

commit 3afe9247fd20e68e488ec51621c7ee2c2290947f
Author: Stephan Arts <stephan at xfce.org>
Date:   Sun Sep 25 08:19:51 2011 +0200

    Cleanup thumbnailer.{c,h} code-style

commit 8cb76184c09b53688eb05100713ff86cc23d8e11
Author: Stephan Arts <stephan at xfce.org>
Date:   Thu Sep 22 23:26:52 2011 +0200

    Add skeleton code for a built-in and fallback properties dialog

commit 09df735fbdf4ea6022d2d3043e5cc6ec85c06cc7
Merge: b8b96b4 38a2c77
Author: Stephan Arts <stephan at xfce.org>
Date:   Thu Sep 22 22:48:03 2011 +0200

    Merge branch 'stephan/properties-dialog' of ssh://git.xfce.org/git/apps/ristretto into stephan/properties-dialog

commit b8b96b487974663850f31c761ac54c849c8d719a
Author: Stephan Arts <stephan at xfce.org>
Date:   Wed Sep 21 21:20:58 2011 +0200

    Update TODO file
    
     - Implement a fallback properties-dialog, for when thunar is not available
       (it happens, bug #4054)
    
     - Implement file-monitoring, to track an opened file even when it moves
       across the filesystem. The thunar-properties dialog allows renaming
       of the files, using that dialog makes ristretto lose track of an
       opened file at runtime.

commit 62fb3256f148b29be6223d2fdb6179fa8e25ff23
Author: Stephan Arts <stephan at xfce.org>
Date:   Wed Sep 21 21:09:13 2011 +0200

    Add properties-dialog d-bus interface to thunar again.

commit 38a2c77a8c5816e7cfcb62bb1b7e10f018cc4d35
Author: Stephan Arts <stephan at xfce.org>
Date:   Wed Sep 21 21:20:58 2011 +0200

    Update TODO file
    
     - Implement a fallback properties-dialog, for when thunar is not available
       (it happens, bug #4054)
    
     - Implement file-monitoring, to track an opened file even when it moves
       across the filesystem. The thunar-properties dialog allows renaming
       of the files, using that dialog makes ristretto lose track of an
       opened file at runtime.

commit 5553970f2182cc5831e00de7c4750bbe82578546
Author: Stephan Arts <stephan at xfce.org>
Date:   Wed Sep 21 21:09:13 2011 +0200

    Add properties-dialog d-bus interface to thunar again.

 TODO                    |    7 +
 src/Makefile.am         |    1 +
 src/main_window.c       |   75 +++++++++
 src/main_window_ui.xml  |    1 +
 src/properties_dialog.c |  411 +++++++++++++++++++++++++++++++++++++++++++++++
 src/properties_dialog.h |   72 ++++++++
 src/settings.c          |   21 +++-
 7 files changed, 587 insertions(+), 1 deletions(-)

diff --git a/TODO b/TODO
index e69de29..ab94e3a 100644
--- a/TODO
+++ b/TODO
@@ -0,0 +1,7 @@
+ - Implement a fallback properties-dialog, for when thunar is not available
+   (it happens, bug #4054)
+
+ - Implement file-monitoring, to track an opened file even when it moves
+   across the filesystem. The thunar-properties dialog allows renaming
+   of the files, using that dialog makes ristretto lose track of an
+   opened file at runtime.
diff --git a/src/Makefile.am b/src/Makefile.am
index 8fbcad8..19a9852 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,6 +6,7 @@ ristretto_SOURCES = \
 	settings.c settings.h \
 	privacy_dialog.h privacy_dialog.c \
 	preferences_dialog.h preferences_dialog.c \
+	properties_dialog.h properties_dialog.c \
 	main_window_ui.h \
 	main_window.c main_window.h \
 	wallpaper_manager.c wallpaper_manager.h \
diff --git a/src/main_window.c b/src/main_window.c
index 0132984..e67cd1c 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -27,6 +27,8 @@
 #include <libxfce4ui/libxfce4ui.h>
 #include <libexif/exif-data.h>
 
+#include <dbus/dbus-glib.h>
+
 #include <cairo/cairo.h>
 
 #include "settings.h"
@@ -40,6 +42,7 @@
 #include "gnome_wallpaper_manager.h"
 
 #include "privacy_dialog.h"
+#include "properties_dialog.h"
 #include "preferences_dialog.h"
 #include "app_menu_item.h"
 
@@ -62,6 +65,9 @@ struct _RsttoMainWindowPriv
         gboolean        toolbar_visible;
     } props;
 
+    DBusGConnection *connection;
+    DBusGProxy *filemanager_proxy;
+
     guint show_fs_toolbar_timeout_id;
     gint window_save_geometry_timer_id;
     gint open_image_timer_id;
@@ -189,6 +195,8 @@ cb_rstto_main_window_open_folder (GtkWidget *widget, RsttoMainWindow *window);
 static void
 cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *window);
 static void
+cb_rstto_main_window_properties (GtkWidget *widget, RsttoMainWindow *window);
+static void
 cb_rstto_main_window_close (GtkWidget *widget, RsttoMainWindow *window);
 static void
 cb_rstto_main_window_close_all (GtkWidget *widget, RsttoMainWindow *window);
@@ -272,6 +280,7 @@ static GtkActionEntry action_entries[] =
   { "open", "document-open", N_ ("_Open"), "<control>O", N_ ("Open an image"), G_CALLBACK (cb_rstto_main_window_open_image), },
   { "open-folder", "folder-open", N_ ("Open _Folder"), NULL, N_ ("Open a folder"), G_CALLBACK (cb_rstto_main_window_open_folder), },
   { "save-copy", GTK_STOCK_SAVE_AS, N_ ("_Save copy"), "<control>s", N_ ("Save a copy of the image"), G_CALLBACK (cb_rstto_main_window_save_copy), },
+  { "properties", GTK_STOCK_PROPERTIES, N_ ("_Properties"), NULL, N_ ("Show file properties"), G_CALLBACK (cb_rstto_main_window_properties), },
   { "close", GTK_STOCK_CLOSE, N_ ("_Close"), "<control>W", N_ ("Close this image"), G_CALLBACK (cb_rstto_main_window_close), },
   { "close-all", NULL, N_ ("_Close All"), NULL, N_ ("Close all images"), G_CALLBACK (cb_rstto_main_window_close_all), },
   { "quit", GTK_STOCK_QUIT, N_ ("_Quit"), "<control>Q", N_ ("Quit Ristretto"), G_CALLBACK (cb_rstto_main_window_quit), },
@@ -412,6 +421,19 @@ rstto_main_window_init (RsttoMainWindow *window)
     window->priv->recent_manager = gtk_recent_manager_get_default();
     window->priv->settings_manager = rstto_settings_new();
 
+    /* D-Bus stuff */
+
+    window->priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+    if (window->priv->connection)
+    {
+        window->priv->filemanager_proxy =
+                dbus_g_proxy_new_for_name(
+                        window->priv->connection,
+                        "org.xfce.FileManager",
+                        "/org/xfce/FileManager",
+                        "org.xfce.FileManager");
+    }
+
     desktop_type = rstto_settings_get_string_property (window->priv->settings_manager, "desktop-type");
     if (desktop_type)
     {
@@ -924,6 +946,7 @@ rstto_main_window_update_buttons (RsttoMainWindow *window)
             /*
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/print"), FALSE);
             */
+            gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/properties"), FALSE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close"), FALSE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close-all"), FALSE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/edit-menu/delete"), FALSE);
@@ -984,6 +1007,7 @@ rstto_main_window_update_buttons (RsttoMainWindow *window)
             /*
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/print"), TRUE);
             */
+            gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/properties"), TRUE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close"), TRUE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close-all"), FALSE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/edit-menu/delete"), TRUE);
@@ -1046,6 +1070,7 @@ rstto_main_window_update_buttons (RsttoMainWindow *window)
             /*
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/print"), TRUE);
             */
+            gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/properties"), TRUE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close"), TRUE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close-all"), TRUE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/edit-menu/delete"), TRUE);
@@ -2319,6 +2344,56 @@ cb_rstto_main_window_save_copy (GtkWidget *widget, RsttoMainWindow *window)
 
 }
 
+static void
+cb_rstto_main_window_properties (GtkWidget *widget, RsttoMainWindow *window)
+{
+    /* The display object is owned by gdk, do not unref it */
+    GdkDisplay *display = gdk_display_get_default();
+    GError *error = NULL;
+    GFile *file = rstto_image_list_iter_get_file (window->priv->iter);
+    gchar *uri = NULL;
+    GtkWidget *dialog = NULL;
+    gboolean use_thunar_properties = rstto_settings_get_boolean_property (
+            window->priv->settings_manager,
+            "use-thunar-properties");
+    if (file)
+    {
+        /* TODO: Add a property that allows forcing the built-in
+         * properties dialog
+         * 
+         * For now this is here for development purposes.
+         */
+        if ( TRUE == use_thunar_properties )
+        {
+            uri = g_file_get_uri(file);
+            if(dbus_g_proxy_call(window->priv->filemanager_proxy,
+                                 "DisplayFileProperties",
+                                 &error,
+                                 G_TYPE_STRING, uri,
+                                 G_TYPE_STRING, gdk_display_get_name(display),
+                                 G_TYPE_STRING, "",
+                                 G_TYPE_INVALID,
+                                 G_TYPE_INVALID) == FALSE)
+            {
+                g_warning("DBUS CALL FAILED: '%s'", error->message);
+                dialog = rstto_properties_dialog_new (
+                        GTK_WINDOW (window),
+                        file);
+                gtk_dialog_run (GTK_DIALOG(dialog));
+                gtk_widget_destroy(dialog);
+            }
+            g_free(uri);
+        }
+        else
+        {
+            dialog = rstto_properties_dialog_new (
+                    GTK_WINDOW (window),
+                    file);
+            gtk_dialog_run (GTK_DIALOG(dialog));
+            gtk_widget_destroy(dialog);
+        }
+    }
+}
 /**
  * cb_rstto_main_window_close:
  * @widget:
diff --git a/src/main_window_ui.xml b/src/main_window_ui.xml
index ed76f3c..279843e 100644
--- a/src/main_window_ui.xml
+++ b/src/main_window_ui.xml
@@ -15,6 +15,7 @@
             <menuitem action="print"/>
             -->
             <separator/>
+            <menuitem action="properties"/>
             <menuitem action="close"/>
             <menuitem action="close-all"/>
             <menuitem action="quit"/>
diff --git a/src/properties_dialog.c b/src/properties_dialog.c
new file mode 100644
index 0000000..72eec38
--- /dev/null
+++ b/src/properties_dialog.c
@@ -0,0 +1,411 @@
+/*
+ *  Copyright (c) Stephan Arts 2006-2011 <stephan at xfce.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include <libxfce4ui/libxfce4ui.h>
+#include <libxfce4util/libxfce4util.h>
+
+#include "settings.h"
+#include "properties_dialog.h"
+
+static void
+rstto_properties_dialog_init (RsttoPropertiesDialog *);
+static void
+rstto_properties_dialog_class_init (GObjectClass *);
+
+static void
+rstto_properties_dialog_dispose (GObject *object);
+
+static void
+rstto_properties_dialog_set_property (
+        GObject      *object,
+        guint         property_id,
+        const GValue *value,
+        GParamSpec   *pspec);
+static void
+rstto_properties_dialog_get_property (
+        GObject    *object,
+        guint       property_id,
+        GValue     *value,
+        GParamSpec *pspec);
+static void
+properties_dialog_set_file (
+        RsttoPropertiesDialog *dialog,
+        GFile *file);
+
+static GtkWidgetClass *parent_class = NULL;
+
+enum
+{
+    PROP_0,
+    PROP_FILE,
+};
+
+struct _RsttoPropertiesDialogPriv
+{
+    GFile *file;
+    RsttoSettings *settings;
+
+    GtkWidget *name_entry;
+    GtkWidget *mime_content_label;
+    GtkWidget *modified_content_label;
+    GtkWidget *accessed_content_label;
+    GtkWidget *size_content_label;
+};
+
+GType
+rstto_properties_dialog_get_type (void)
+{
+    static GType rstto_properties_dialog_type = 0;
+
+    if (!rstto_properties_dialog_type)
+    {
+        static const GTypeInfo rstto_properties_dialog_info = 
+        {
+            sizeof (RsttoPropertiesDialogClass),
+            (GBaseInitFunc) NULL,
+            (GBaseFinalizeFunc) NULL,
+            (GClassInitFunc) rstto_properties_dialog_class_init,
+            (GClassFinalizeFunc) NULL,
+            NULL,
+            sizeof (RsttoPropertiesDialog),
+            0,
+            (GInstanceInitFunc) rstto_properties_dialog_init,
+            NULL
+        };
+
+        rstto_properties_dialog_type = g_type_register_static (
+                GTK_TYPE_DIALOG,
+                "RsttoPropertiesDialog",
+                &rstto_properties_dialog_info,
+                0);
+    }
+    return rstto_properties_dialog_type;
+}
+
+static void
+rstto_properties_dialog_init (RsttoPropertiesDialog *dialog)
+{
+    GtkWidget *vbox;
+    GtkWidget *notebook;
+    GtkWidget *table;
+    GtkWidget *general_label;
+    GtkWidget *name_label = gtk_label_new(NULL);
+    GtkWidget *mime_label = gtk_label_new(NULL);
+
+    GtkWidget *modified_label = gtk_label_new(NULL);
+    GtkWidget *accessed_label = gtk_label_new(NULL);
+    GtkWidget *created_label  = gtk_label_new(NULL);
+
+    GtkWidget *size_label  = gtk_label_new(NULL);
+
+    dialog->priv = g_new0 (RsttoPropertiesDialogPriv, 1);
+
+    dialog->priv->settings = rstto_settings_new ();
+    dialog->priv->name_entry = gtk_entry_new();
+    dialog->priv->mime_content_label = gtk_label_new(NULL);
+    dialog->priv->modified_content_label = gtk_label_new(NULL);
+    dialog->priv->accessed_content_label = gtk_label_new(NULL);
+    dialog->priv->size_content_label = gtk_label_new(NULL);
+
+    gtk_misc_set_alignment (
+            GTK_MISC (dialog->priv->mime_content_label),
+            0.0,
+            0.5);
+    gtk_misc_set_alignment (
+            GTK_MISC (dialog->priv->modified_content_label),
+            0.0,
+            0.5);
+    gtk_misc_set_alignment (
+            GTK_MISC (dialog->priv->accessed_content_label),
+            0.0,
+            0.5);
+    gtk_misc_set_alignment (
+            GTK_MISC (dialog->priv->size_content_label),
+            0.0,
+            0.5);
+
+    vbox = gtk_dialog_get_content_area (
+            GTK_DIALOG (dialog));
+    notebook = gtk_notebook_new ();
+
+    table = gtk_table_new (5, 2, FALSE);
+    gtk_label_set_markup (GTK_LABEL(name_label), _("<b>Name:</b>"));
+    gtk_label_set_markup (GTK_LABEL(mime_label), _("<b>Kind:</b>"));
+    gtk_label_set_markup (GTK_LABEL(modified_label), _("<b>Modified:</b>"));
+    gtk_label_set_markup (GTK_LABEL(accessed_label), _("<b>Accessed:</b>"));
+    gtk_label_set_markup (GTK_LABEL(size_label), _("<b>Size:</b>"));
+
+    gtk_misc_set_alignment (GTK_MISC (name_label), 1.0, 0.5);
+    gtk_misc_set_alignment (GTK_MISC (mime_label), 1.0, 0.5);
+    gtk_misc_set_alignment (GTK_MISC (modified_label), 1.0, 0.5);
+    gtk_misc_set_alignment (GTK_MISC (accessed_label), 1.0, 0.5);
+    gtk_misc_set_alignment (GTK_MISC (size_label), 1.0, 0.5);
+
+    gtk_table_attach (
+            GTK_TABLE (table),
+            name_label,
+            0,
+            1,
+            0,
+            1,
+            GTK_SHRINK | GTK_FILL,
+            GTK_SHRINK,
+            4,
+            4);
+
+    gtk_table_attach (
+            GTK_TABLE (table),
+            dialog->priv->name_entry,
+            1,
+            2,
+            0,
+            1,
+            GTK_EXPAND | GTK_FILL,
+            GTK_SHRINK,
+            4,
+            4);
+
+    gtk_table_attach (
+            GTK_TABLE (table),
+            mime_label,
+            0,
+            1,
+            1,
+            2,
+            GTK_SHRINK | GTK_FILL,
+            GTK_SHRINK,
+            4,
+            4);
+    gtk_table_attach (
+            GTK_TABLE (table),
+            dialog->priv->mime_content_label,
+            1,
+            2,
+            1,
+            2,
+            GTK_EXPAND | GTK_FILL,
+            GTK_SHRINK,
+            4,
+            4);
+
+    gtk_table_attach (
+            GTK_TABLE (table),
+            modified_label,
+            0,
+            1,
+            2,
+            3,
+            GTK_SHRINK | GTK_FILL,
+            GTK_SHRINK,
+            4,
+            4);
+    gtk_table_attach (
+            GTK_TABLE (table),
+            dialog->priv->modified_content_label,
+            1,
+            2,
+            2,
+            3,
+            GTK_EXPAND | GTK_FILL,
+            GTK_SHRINK,
+            4,
+            4);
+
+    gtk_table_attach (
+            GTK_TABLE (table),
+            accessed_label,
+            0,
+            1,
+            3,
+            4,
+            GTK_SHRINK | GTK_FILL,
+            GTK_SHRINK,
+            4,
+            4);
+    gtk_table_attach (
+            GTK_TABLE (table),
+            dialog->priv->accessed_content_label,
+            1,
+            2,
+            3,
+            4,
+            GTK_EXPAND | GTK_FILL,
+            GTK_SHRINK,
+            4,
+            4);
+
+    gtk_table_attach (
+            GTK_TABLE (table),
+            size_label,
+            0,
+            1,
+            4,
+            5,
+            GTK_SHRINK | GTK_FILL,
+            GTK_SHRINK,
+            4,
+            4);
+    gtk_table_attach (
+            GTK_TABLE (table),
+            dialog->priv->size_content_label,
+            1,
+            2,
+            4,
+            5,
+            GTK_EXPAND | GTK_FILL,
+            GTK_SHRINK,
+            4,
+            4);
+
+    general_label = gtk_label_new (_("General"));
+    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, general_label);
+
+    gtk_box_pack_start (GTK_BOX(vbox), notebook, TRUE, TRUE, 3);
+
+    gtk_widget_show_all (vbox);
+
+
+    gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_OK);
+}
+
+static void
+rstto_properties_dialog_class_init (GObjectClass *object_class)
+{
+    GParamSpec *pspec;
+
+    parent_class = g_type_class_peek_parent (
+            RSTTO_PROPERTIES_DIALOG_CLASS (object_class));
+
+    object_class->dispose = rstto_properties_dialog_dispose;
+
+    object_class->set_property = rstto_properties_dialog_set_property;
+    object_class->get_property = rstto_properties_dialog_get_property;
+
+    pspec = g_param_spec_object ("file",
+                                 "",
+                                 "",
+                                 G_TYPE_FILE,
+                                 G_PARAM_READWRITE);
+    g_object_class_install_property (object_class,
+                                     PROP_FILE,
+                                     pspec);
+}
+
+static void
+rstto_properties_dialog_dispose (GObject *object)
+{
+    RsttoPropertiesDialog *dialog = RSTTO_PROPERTIES_DIALOG (object);
+    if (dialog->priv->settings)
+    {
+        g_object_unref (dialog->priv->settings);
+        dialog->priv->settings = NULL;
+    }
+    
+    G_OBJECT_CLASS(parent_class)->dispose(object);
+}
+
+
+static void
+rstto_properties_dialog_set_property (
+        GObject      *object,
+        guint         property_id,
+        const GValue *value,
+        GParamSpec   *pspec)
+{
+    RsttoPropertiesDialog *dialog = RSTTO_PROPERTIES_DIALOG (object);
+
+    switch (property_id)
+    {
+        case PROP_FILE:
+            properties_dialog_set_file (dialog, g_value_get_object (value));
+            break;
+        default:
+            break;
+    }
+
+}
+
+static void
+rstto_properties_dialog_get_property (
+        GObject    *object,
+        guint       property_id,
+        GValue     *value,
+        GParamSpec *pspec)
+{
+}
+
+static void
+properties_dialog_set_file (
+        RsttoPropertiesDialog *dialog,
+        GFile *file)
+{
+    GFileInfo *file_info = NULL;
+    gchar *description;
+
+    dialog->priv->file = file;
+
+    if (dialog->priv->file)
+    {
+        file_info = g_file_query_info (
+                dialog->priv->file,
+                "standard::content-type,standard::edit-name,standard::size,time::modified,time_accessed",
+                0,
+                NULL,
+                NULL);
+        description = g_content_type_get_description (
+                g_file_info_get_attribute_string (
+                        file_info,
+                        "standard::content-type")
+                );
+        gtk_label_set_text (
+                GTK_LABEL (dialog->priv->mime_content_label),
+                description
+                );
+        gtk_entry_set_text (
+                GTK_ENTRY (dialog->priv->name_entry),
+                g_file_info_get_attribute_string (
+                        file_info,
+                        "standard::edit-name")
+                );
+        g_free (description);
+    }
+}
+
+/********************/
+/* Public functions */
+/********************/
+
+GtkWidget *
+rstto_properties_dialog_new (
+        GtkWindow *parent,
+        GFile *file)
+{
+    gchar *title = g_strdup_printf (_("%s - Properties"), g_file_get_basename(file));
+    GtkWidget *dialog = g_object_new (RSTTO_TYPE_PROPERTIES_DIALOG,
+                                      "title", title,
+                                      "icon-name", GTK_STOCK_PROPERTIES,
+                                      "file", file,
+                                      NULL);
+
+    gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+
+    return dialog;
+}
+
diff --git a/src/properties_dialog.h b/src/properties_dialog.h
new file mode 100644
index 0000000..0714b12
--- /dev/null
+++ b/src/properties_dialog.h
@@ -0,0 +1,72 @@
+/*
+ *  Copyright (c) Stephan Arts 2009-2010 <stephan at xfce.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __RISTRETTO_PROPERTIES_DIALOG_H__
+#define __RISTRETTO_PROPERTIES_DIALOG_H__
+
+G_BEGIN_DECLS
+
+#define RSTTO_TYPE_PROPERTIES_DIALOG rstto_properties_dialog_get_type()
+
+#define RSTTO_PROPERTIES_DIALOG(obj)( \
+        G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+                RSTTO_TYPE_PROPERTIES_DIALOG, \
+                RsttoPropertiesDialog))
+
+#define RSTTO_IS_PROPERTIES_DIALOG(obj)( \
+        G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+                RSTTO_TYPE_PROPERTIES_DIALOG))
+
+#define RSTTO_PROPERTIES_DIALOG_CLASS(klass)( \
+        G_TYPE_CHECK_CLASS_CAST ((klass), \
+                RSTTO_TYPE_PROPERTIES_DIALOG, \
+                RsttoPropertiesDialogClass))
+
+#define RSTTO_IS_PROPERTIES_DIALOG_CLASS(klass)( \
+        G_TYPE_CHECK_CLASS_TYPE ((klass), \
+                RSTTO_TYPE_PROPERTIES_DIALOG()))
+
+typedef struct _RsttoPropertiesDialog RsttoPropertiesDialog;
+
+typedef struct _RsttoPropertiesDialogPriv RsttoPropertiesDialogPriv;
+
+struct _RsttoPropertiesDialog
+{
+    GtkDialog parent;
+    RsttoPropertiesDialogPriv *priv;
+};
+
+typedef struct _RsttoPropertiesDialogClass RsttoPropertiesDialogClass;
+
+struct _RsttoPropertiesDialogClass
+{
+    GtkDialogClass  parent_class;
+};
+
+GType
+rstto_properties_dialog_get_type();
+
+GtkWidget *
+rstto_properties_dialog_new (
+        GtkWindow *parent,
+        GFile *file
+        );
+
+G_END_DECLS
+
+#endif /* __RISTRETTO_PROPERTIES_DIALOG_H__ */
diff --git a/src/settings.c b/src/settings.c
index b127c48..647348d 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -74,6 +74,7 @@ enum
     PROP_THUMBNAILBAR_SIZE,
     PROP_DESKTOP_TYPE,
     PROP_REVERT_ZOOM_DIRECTION,
+    PROP_USE_THUNAR_PROPERTIES,
 };
 
 GType
@@ -126,6 +127,7 @@ struct _RsttoSettingsPriv
     gboolean  wrap_images;
     gint      thumbnailbar_size;
     gchar    *desktop_type;
+    gboolean  use_thunar_properties;
 };
 
 
@@ -157,6 +159,7 @@ rstto_settings_init (GObject *object)
     settings->priv->window_width = 600;
     settings->priv->window_height = 400;
     settings->priv->wrap_images = TRUE;
+    settings->priv->use_thunar_properties = TRUE;
 
     xfconf_g_property_bind (settings->priv->channel, "/window/width", G_TYPE_UINT, settings, "window-width");
     xfconf_g_property_bind (settings->priv->channel, "/window/height", G_TYPE_UINT, settings, "window-height");
@@ -179,9 +182,10 @@ rstto_settings_init (GObject *object)
 
     xfconf_g_property_bind_gdkcolor (settings->priv->channel, "/window/bgcolor-fullscreen", settings, "bgcolor-fullscreen");
     xfconf_g_property_bind (settings->priv->channel, "/window/revert-zoom-direction", G_TYPE_BOOLEAN, settings, "revert-zoom-direction");
+    xfconf_g_property_bind (settings->priv->channel, "/window/thumbnailbar/size", G_TYPE_INT, settings, "thumbnailbar-size");
     xfconf_g_property_bind (settings->priv->channel, "/image/quality", G_TYPE_UINT, settings, "image-quality");
     xfconf_g_property_bind (settings->priv->channel, "/image/wrap", G_TYPE_BOOLEAN, settings, "wrap-images");
-    xfconf_g_property_bind (settings->priv->channel, "/window/thumbnailbar/size", G_TYPE_INT, settings, "thumbnailbar-size");
+    xfconf_g_property_bind (settings->priv->channel, "/window/use-thunar-properties", G_TYPE_BOOLEAN, settings, "use-thunar-properties");
 }
 
 
@@ -389,6 +393,15 @@ rstto_settings_class_init (GObjectClass *object_class)
     g_object_class_install_property (object_class,
                                      PROP_DESKTOP_TYPE,
                                      pspec);
+
+    pspec = g_param_spec_boolean ("use-thunar-properties",
+                                  "",
+                                  "",
+                                  TRUE,
+                                  G_PARAM_READWRITE);
+    g_object_class_install_property (object_class,
+                                     PROP_USE_THUNAR_PROPERTIES,
+                                     pspec);
 }
 
 /**
@@ -555,6 +568,9 @@ rstto_settings_set_property    (GObject      *object,
                 g_free (settings->priv->desktop_type);
             settings->priv->desktop_type = g_value_dup_string (value);
             break;
+        case PROP_USE_THUNAR_PROPERTIES:
+            settings->priv->use_thunar_properties = g_value_get_boolean (value);
+            break;
         default:
             break;
     }
@@ -630,6 +646,9 @@ rstto_settings_get_property    (GObject    *object,
         case PROP_DESKTOP_TYPE:
             g_value_set_string (value, settings->priv->desktop_type);
             break;
+        case PROP_USE_THUNAR_PROPERTIES:
+            g_value_set_boolean (value, settings->priv->use_thunar_properties);
+            break;
         default:
             break;
 


More information about the Xfce4-commits mailing list