[Xfce4-commits] <ristretto:master> Add skeleton code for a built-in and fallback properties dialog

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


Updating branch refs/heads/master
         to 8cb76184c09b53688eb05100713ff86cc23d8e11 (commit)
       from 09df735fbdf4ea6022d2d3043e5cc6ec85c06cc7 (commit)

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

 src/Makefile.am         |    1 +
 src/main_window.c       |   41 ++++++++---
 src/properties_dialog.c |  173 +++++++++++++++++++++++++++++++++++++++++++++++
 src/properties_dialog.h |   72 +++++++++++++++++++
 4 files changed, 276 insertions(+), 11 deletions(-)

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 48fae77..e2576d9 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -42,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"
 
@@ -2350,21 +2351,39 @@ cb_rstto_main_window_properties (GtkWidget *widget, RsttoMainWindow *window)
     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;
     if (file)
     {
-        gchar *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)
+        /* TODO: Add a property that allows forcing the built-in
+         * properties dialog
+         * 
+         * For now this is here for development purposes.
+         */
+        if ( 0 )
+        {
+            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);
+            }
+            g_free(uri);
+        }
+        else
         {
-            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);
     }
 }
 /**
diff --git a/src/properties_dialog.c b/src/properties_dialog.c
new file mode 100644
index 0000000..ffa59bd
--- /dev/null
+++ b/src/properties_dialog.c
@@ -0,0 +1,173 @@
+/*
+ *  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 GtkWidgetClass *parent_class = NULL;
+
+enum
+{
+    PROP_0,
+};
+
+struct _RsttoPropertiesDialogPriv
+{
+    GFile *file;
+    RsttoSettings *settings;
+};
+
+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)
+{
+    dialog->priv = g_new0 (RsttoPropertiesDialogPriv, 1);
+
+    dialog->priv->settings = rstto_settings_new ();
+
+    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;
+}
+
+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)
+    {
+        default:
+            break;
+    }
+
+}
+
+static void
+rstto_properties_dialog_get_property (
+        GObject    *object,
+        guint       property_id,
+        GValue     *value,
+        GParamSpec *pspec)
+{
+}
+
+/********************/
+/* 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,
+                                      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__ */


More information about the Xfce4-commits mailing list