[gnome-disk-utility/udisks2-port] Factor window specific parts of GduApplication into a separate class
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/udisks2-port] Factor window specific parts of GduApplication into a separate class
- Date: Tue, 8 Mar 2011 20:18:15 +0000 (UTC)
commit 748e10360dec0878e997693144ff49d74e0bffc2
Author: David Zeuthen <davidz redhat com>
Date: Tue Mar 8 15:17:06 2011 -0500
Factor window specific parts of GduApplication into a separate class
That way, in the future, we can have exactly one GduWindow for each
UDisksClient - e.g. for remote connectivity we just create a new
window.
Signed-off-by: David Zeuthen <davidz redhat com>
data/ui/palimpsest.ui | 160 +++++++++++++++++---
src/palimpsest/Makefile.am | 1 +
src/palimpsest/gdu.h | 2 +
src/palimpsest/gduapplication.c | 135 +----------------
src/palimpsest/gdutypes.h | 3 +
src/palimpsest/gduwindow.c | 318 +++++++++++++++++++++++++++++++++++++++
src/palimpsest/gduwindow.h | 46 ++++++
7 files changed, 516 insertions(+), 149 deletions(-)
---
diff --git a/data/ui/palimpsest.ui b/data/ui/palimpsest.ui
index 97d57a9..a9687c6 100644
--- a/data/ui/palimpsest.ui
+++ b/data/ui/palimpsest.ui
@@ -4,7 +4,6 @@
<object class="GtkWindow" id="palimpsest-window">
<property name="can_focus">False</property>
<property name="border_width">12</property>
- <property name="title" translatable="yes">Disk Utility</property>
<property name="default_width">400</property>
<property name="default_height">500</property>
<child>
@@ -13,24 +12,24 @@
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
- <object class="GtkVBox" id="lunlist-vbox">
+ <object class="GtkVBox" id="device-tree-vbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkScrolledWindow" id="lunlist-scrolledwindow">
+ <object class="GtkScrolledWindow" id="device-tree-scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkTreeView" id="lunlist-treeview">
+ <object class="GtkTreeView" id="device-tree-treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="show_expanders">False</property>
<property name="level_indentation">12</property>
<child internal-child="selection">
- <object class="GtkTreeSelection" id="lunlist-treeview-selection"/>
+ <object class="GtkTreeSelection" id="device-tree-treeview-selection"/>
</child>
</object>
</child>
@@ -42,12 +41,12 @@
</packing>
</child>
<child>
- <object class="GtkToolbar" id="lunlist-add-remove-toolbar">
+ <object class="GtkToolbar" id="device-tree-add-remove-toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_size">1</property>
<child>
- <object class="GtkToolButton" id="lunlist-add-toolbutton">
+ <object class="GtkToolButton" id="device-tree-add-toolbutton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
@@ -59,7 +58,7 @@
</packing>
</child>
<child>
- <object class="GtkToolButton" id="lunlist-remove-toolbutton">
+ <object class="GtkToolButton" id="device-tree-remove-toolbutton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
@@ -89,6 +88,29 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Select a device</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">nothing_selected</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -249,6 +271,9 @@
<placeholder/>
</child>
</object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label1">
@@ -257,31 +282,126 @@
<property name="label" translatable="yes">lun</property>
</object>
<packing>
+ <property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="label2">
+ <object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">page 2</property>
+ <child>
+ <object class="GtkTable" id="loop-table">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">4</property>
+ <property name="column_spacing">10</property>
+ <child>
+ <object class="GtkLabel" id="loop-backing-file-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Backing File</property>
+ <attributes>
+ <attribute name="foreground" value="#555555555555"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="loop-size-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Size</property>
+ <attributes>
+ <attribute name="foreground" value="#555555555555"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="loop-backing-file-value-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="loop-size-value-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
- <property name="position">1</property>
- <property name="tab_fill">False</property>
+ <property name="position">2</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
<child type="tab">
- <object class="GtkLabel" id="label3">
+ <object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">page 3</property>
+ <property name="label" translatable="yes">loop</property>
</object>
<packing>
<property name="position">2</property>
diff --git a/src/palimpsest/Makefile.am b/src/palimpsest/Makefile.am
index 443a384..7f13d94 100644
--- a/src/palimpsest/Makefile.am
+++ b/src/palimpsest/Makefile.am
@@ -9,6 +9,7 @@ palimpsest_SOURCES = \
gduapplication.h gduapplication.c \
gdutreemodel.h gdutreemodel.c \
gdutypes.h \
+ gduwindow.h gduwindow.c \
$(NULL)
palimpsest_CPPFLAGS = \
diff --git a/src/palimpsest/gdu.h b/src/palimpsest/gdu.h
index b61add8..e2791ae 100644
--- a/src/palimpsest/gdu.h
+++ b/src/palimpsest/gdu.h
@@ -25,5 +25,7 @@
#include <gdutypes.h>
#include <gduapplication.h>
+#include <gdutreemodel.h>
+#include <gduwindow.h>
#endif /* __GDU_H__ */
diff --git a/src/palimpsest/gduapplication.c b/src/palimpsest/gduapplication.c
index 13e054d..79b3f12 100644
--- a/src/palimpsest/gduapplication.c
+++ b/src/palimpsest/gduapplication.c
@@ -24,19 +24,16 @@
#include <glib/gi18n.h>
#include "gduapplication.h"
-#include "gdutreemodel.h"
+#include "gduwindow.h"
struct _GduApplication
{
GtkApplication parent_instance;
- GtkBuilder *builder;
- GtkWindow *window;
gboolean running_from_source_tree;
UDisksClient *client;
-
- GduTreeModel *model;
+ GduWindow *window;
};
typedef struct
@@ -56,12 +53,8 @@ gdu_application_finalize (GObject *object)
{
GduApplication *app = GDU_APPLICATION (object);
- if (app->builder != NULL)
- goto out;
-
- g_object_unref (app->model);
+ g_object_unref (app->client);
- out:
G_OBJECT_CLASS (gdu_application_parent_class)->finalize (object);
}
@@ -82,52 +75,11 @@ gdu_application_local_command_line (GApplication *_app,
exit_status);
}
-static gboolean
-dont_select_headings (GtkTreeSelection *selection,
- GtkTreeModel *model,
- GtkTreePath *path,
- gboolean selected,
- gpointer data)
-{
- GtkTreeIter iter;
- gboolean is_heading;
-
- gtk_tree_model_get_iter (model,
- &iter,
- path);
- gtk_tree_model_get (model,
- &iter,
- GDU_TREE_MODEL_COLUMN_IS_HEADING,
- &is_heading,
- -1);
-
- return !is_heading;
-}
-
-static void
-on_row_inserted (GtkTreeModel *tree_model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer user_data)
-{
- GduApplication *app = GDU_APPLICATION (user_data);
- gtk_tree_view_expand_all (GTK_TREE_VIEW (gdu_application_get_widget (app, "lunlist-treeview")));
-}
-
static void
gdu_application_activate (GApplication *_app)
{
GduApplication *app = GDU_APPLICATION (_app);
GError *error;
- GtkNotebook *notebook;
- GtkTreeView *tree_view;
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
- GtkTreeSelection *selection;
- const gchar *path;
-
- if (app->builder != NULL)
- return;
error = NULL;
app->client = udisks_client_new_sync (NULL, /* GCancellable* */
@@ -138,76 +90,10 @@ gdu_application_activate (GApplication *_app)
g_error_free (error);
}
- app->builder = gtk_builder_new ();
- error = NULL;
- path = app->running_from_source_tree ? "../../data/ui/palimpsest.ui" :
- PACKAGE_DATA_DIR "/gnome-disk-utility/palimpsest.ui";
- if (gtk_builder_add_from_file (app->builder,
- path,
- &error) == 0)
- {
- g_error ("Error loading %s: %s", path, error->message);
- g_error_free (error);
- }
-
- app->window = GTK_WINDOW (gdu_application_get_widget (app, "palimpsest-window"));
- gtk_application_add_window (GTK_APPLICATION (app), app->window);
+ app->window = gdu_window_new (app, app->client);
+ gtk_application_add_window (GTK_APPLICATION (app),
+ GTK_WINDOW (app->window));
gtk_widget_show_all (GTK_WIDGET (app->window));
-
- notebook = GTK_NOTEBOOK (gdu_application_get_widget (app, "palimpsest-notebook"));
- gtk_notebook_set_show_tabs (notebook, FALSE);
- gtk_notebook_set_show_border (notebook, FALSE);
-
- GtkStyleContext *context;
- context = gtk_widget_get_style_context (gdu_application_get_widget (app, "lunlist-scrolledwindow"));
- gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
- context = gtk_widget_get_style_context (gdu_application_get_widget (app, "lunlist-add-remove-toolbar"));
- gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
-
- app->model = gdu_tree_model_new (app->client);
-
- tree_view = GTK_TREE_VIEW (gdu_application_get_widget (app, "lunlist-treeview"));
- gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (app->model));
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (app->model),
- GDU_TREE_MODEL_COLUMN_SORT_KEY,
- GTK_SORT_ASCENDING);
-
- selection = gtk_tree_view_get_selection (tree_view);
- gtk_tree_selection_set_select_function (selection, dont_select_headings, NULL, NULL);
-
- column = gtk_tree_view_column_new ();
- gtk_tree_view_append_column (tree_view, column);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column,
- renderer,
- "markup", GDU_TREE_MODEL_COLUMN_HEADING_TEXT,
- "visible", GDU_TREE_MODEL_COLUMN_IS_HEADING,
- NULL);
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- g_object_set (G_OBJECT (renderer),
- "stock-size", GTK_ICON_SIZE_DND,
- NULL);
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column,
- renderer,
- "gicon", GDU_TREE_MODEL_COLUMN_ICON,
- NULL);
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column,
- renderer,
- "text", GDU_TREE_MODEL_COLUMN_NAME,
- NULL);
-
- /* expand on insertion - hmm, I wonder if there's an easier way to do this */
- g_signal_connect (app->model,
- "row-inserted",
- G_CALLBACK (on_row_inserted),
- app);
- gtk_tree_view_expand_all (tree_view);
}
static void
@@ -233,12 +119,3 @@ gdu_application_new (void)
"flags", G_APPLICATION_FLAGS_NONE,
NULL));
}
-
-GtkWidget *
-gdu_application_get_widget (GduApplication *app,
- const gchar *name)
-{
- g_return_val_if_fail (GDU_IS_APPLICATION (app), NULL);
- g_return_val_if_fail (name != NULL, NULL);
- return GTK_WIDGET (gtk_builder_get_object (app->builder, name));
-}
diff --git a/src/palimpsest/gdutypes.h b/src/palimpsest/gdutypes.h
index e821cc1..4459a59 100644
--- a/src/palimpsest/gdutypes.h
+++ b/src/palimpsest/gdutypes.h
@@ -35,6 +35,9 @@ typedef struct _GduApplication GduApplication;
struct _GduTreeModel;
typedef struct _GduTreeModel GduTreeModel;
+struct _GduWindow;
+typedef struct _GduWindow GduWindow;
+
G_END_DECLS
#endif /* __GDU_TYPES_H__ */
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
new file mode 100644
index 0000000..d808a54
--- /dev/null
+++ b/src/palimpsest/gduwindow.c
@@ -0,0 +1,318 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2008-2011 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz redhat com>
+ */
+
+#include "config.h"
+#include <glib/gi18n.h>
+
+#include "gduapplication.h"
+#include "gduwindow.h"
+#include "gdutreemodel.h"
+
+struct _GduWindow
+{
+ GtkWindow parent_instance;
+
+ GduApplication *application;
+ UDisksClient *client;
+
+ GtkBuilder *builder;
+ GduTreeModel *model;
+};
+
+typedef struct
+{
+ GtkWindowClass parent_class;
+} GduWindowClass;
+
+enum
+{
+ PROP_0,
+ PROP_APPLICATION,
+ PROP_CLIENT
+};
+
+G_DEFINE_TYPE (GduWindow, gdu_window, GTK_TYPE_WINDOW);
+
+static void
+gdu_window_init (GduWindow *window)
+{
+}
+
+static void
+gdu_window_finalize (GObject *object)
+{
+ GduWindow *window = GDU_WINDOW (object);
+
+ g_object_unref (window->builder);
+ g_object_unref (window->model);
+ g_object_unref (window->client);
+ g_object_unref (window->application);
+
+ G_OBJECT_CLASS (gdu_window_parent_class)->finalize (object);
+}
+
+static gboolean
+dont_select_headings (GtkTreeSelection *selection,
+ GtkTreeModel *model,
+ GtkTreePath *path,
+ gboolean selected,
+ gpointer data)
+{
+ GtkTreeIter iter;
+ gboolean is_heading;
+
+ gtk_tree_model_get_iter (model,
+ &iter,
+ path);
+ gtk_tree_model_get (model,
+ &iter,
+ GDU_TREE_MODEL_COLUMN_IS_HEADING,
+ &is_heading,
+ -1);
+
+ return !is_heading;
+}
+
+static void
+on_row_inserted (GtkTreeModel *tree_model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (gdu_window_get_widget (window, "device-tree-treeview")));
+}
+
+static void
+gdu_window_constructed (GObject *object)
+{
+ GduWindow *window = GDU_WINDOW (object);
+ GError *error;
+ GtkNotebook *notebook;
+ GtkTreeView *tree_view;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkTreeSelection *selection;
+ const gchar *path;
+ GtkWidget *w;
+ GtkStyleContext *context;
+
+ /* chain up */
+ if (G_OBJECT_CLASS (gdu_window_parent_class)->constructed != NULL)
+ G_OBJECT_CLASS (gdu_window_parent_class)->constructed (object);
+
+ window->builder = gtk_builder_new ();
+ error = NULL;
+ path = (TRUE /*app->running_from_source_tree*/) ? "../../data/ui/palimpsest.ui" :
+ PACKAGE_DATA_DIR "/gnome-disk-utility/palimpsest.ui";
+ if (gtk_builder_add_from_file (window->builder,
+ path,
+ &error) == 0)
+ {
+ g_error ("Error loading %s: %s", path, error->message);
+ g_error_free (error);
+ }
+
+ w = gdu_window_get_widget (window, "palimpsest-hbox");
+ gtk_widget_reparent (w, GTK_WIDGET (window));
+ gtk_window_set_title (GTK_WINDOW (window), _("Disk Utility"));
+ gtk_window_set_default_size (GTK_WINDOW (window), 400, 500);
+
+ notebook = GTK_NOTEBOOK (gdu_window_get_widget (window, "palimpsest-notebook"));
+ gtk_notebook_set_show_tabs (notebook, FALSE);
+ gtk_notebook_set_show_border (notebook, FALSE);
+
+ context = gtk_widget_get_style_context (gdu_window_get_widget (window, "device-tree-scrolledwindow"));
+ gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
+ context = gtk_widget_get_style_context (gdu_window_get_widget (window, "device-tree-add-remove-toolbar"));
+ gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
+
+ window->model = gdu_tree_model_new (window->client);
+
+ tree_view = GTK_TREE_VIEW (gdu_window_get_widget (window, "device-tree-treeview"));
+ gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (window->model));
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (window->model),
+ GDU_TREE_MODEL_COLUMN_SORT_KEY,
+ GTK_SORT_ASCENDING);
+
+ selection = gtk_tree_view_get_selection (tree_view);
+ gtk_tree_selection_set_select_function (selection, dont_select_headings, NULL, NULL);
+
+ column = gtk_tree_view_column_new ();
+ gtk_tree_view_append_column (tree_view, column);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column,
+ renderer,
+ "markup", GDU_TREE_MODEL_COLUMN_HEADING_TEXT,
+ "visible", GDU_TREE_MODEL_COLUMN_IS_HEADING,
+ NULL);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (G_OBJECT (renderer),
+ "stock-size", GTK_ICON_SIZE_DND,
+ NULL);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column,
+ renderer,
+ "gicon", GDU_TREE_MODEL_COLUMN_ICON,
+ NULL);
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column,
+ renderer,
+ "text", GDU_TREE_MODEL_COLUMN_NAME,
+ NULL);
+
+ /* expand on insertion - hmm, I wonder if there's an easier way to do this */
+ g_signal_connect (window->model,
+ "row-inserted",
+ G_CALLBACK (on_row_inserted),
+ window);
+ gtk_tree_view_expand_all (tree_view);
+}
+
+static void
+gdu_window_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GduWindow *window = GDU_WINDOW (object);
+
+ switch (prop_id)
+ {
+ case PROP_APPLICATION:
+ g_value_set_object (value, gdu_window_get_application (window));
+ break;
+
+ case PROP_CLIENT:
+ g_value_set_object (value, gdu_window_get_client (window));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gdu_window_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GduWindow *window = GDU_WINDOW (object);
+
+ switch (prop_id)
+ {
+ case PROP_APPLICATION:
+ window->application = g_value_dup_object (value);
+ break;
+
+ case PROP_CLIENT:
+ window->client = g_value_dup_object (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gdu_window_class_init (GduWindowClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->constructed = gdu_window_constructed;
+ gobject_class->finalize = gdu_window_finalize;
+ gobject_class->get_property = gdu_window_get_property;
+ gobject_class->set_property = gdu_window_set_property;
+
+ /**
+ * GduWindow:application:
+ *
+ * The #GduApplication for the #GduWindow.
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_APPLICATION,
+ g_param_spec_object ("application",
+ "Application",
+ "The application for the window",
+ GDU_TYPE_APPLICATION,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GduWindow:client:
+ *
+ * The #UDisksClient used by the #GduWindow.
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_CLIENT,
+ g_param_spec_object ("client",
+ "Client",
+ "The client used by the window",
+ UDISKS_TYPE_CLIENT,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+}
+
+GduWindow *
+gdu_window_new (GduApplication *application,
+ UDisksClient *client)
+{
+ return GDU_WINDOW (g_object_new (GDU_TYPE_WINDOW,
+ "application", application,
+ "client", client,
+ NULL));
+}
+
+GduApplication *
+gdu_window_get_application (GduWindow *window)
+{
+ g_return_val_if_fail (GDU_IS_WINDOW (window), NULL);
+ return window->application;
+}
+
+UDisksClient *
+gdu_window_get_client (GduWindow *window)
+{
+ g_return_val_if_fail (GDU_IS_WINDOW (window), NULL);
+ return window->client;
+}
+
+GtkWidget *
+gdu_window_get_widget (GduWindow *window,
+ const gchar *name)
+{
+ g_return_val_if_fail (GDU_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+ return GTK_WIDGET (gtk_builder_get_object (window->builder, name));
+}
diff --git a/src/palimpsest/gduwindow.h b/src/palimpsest/gduwindow.h
new file mode 100644
index 0000000..4e35ca9
--- /dev/null
+++ b/src/palimpsest/gduwindow.h
@@ -0,0 +1,46 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2008-2011 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz redhat com>
+ */
+
+#ifndef __GDU_WINDOW_H__
+#define __GDU_WINDOW_H__
+
+#include <gtk/gtk.h>
+#include "gdutypes.h"
+
+G_BEGIN_DECLS
+
+#define GDU_TYPE_WINDOW (gdu_window_get_type ())
+#define GDU_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDU_TYPE_WINDOW, GduWindow))
+#define GDU_IS_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDU_TYPE_WINDOW))
+
+GType gdu_window_get_type (void) G_GNUC_CONST;
+GduWindow *gdu_window_new (GduApplication *application,
+ UDisksClient *client);
+GduApplication *gdu_window_get_application (GduWindow *window);
+UDisksClient *gdu_window_get_client (GduWindow *window);
+GtkWidget *gdu_window_get_widget (GduWindow *window,
+ const gchar *name);
+
+
+G_END_DECLS
+
+#endif /* __GDU_WINDOW_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]