[gnome-disk-utility/udisks2-port] Move filesystem dialog into separate file
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/udisks2-port] Move filesystem dialog into separate file
- Date: Thu, 22 Sep 2011 17:03:06 +0000 (UTC)
commit 947e0ab93869bbd9b20a798a554f9c5337403c32
Author: David Zeuthen <davidz redhat com>
Date: Thu Sep 22 13:02:45 2011 -0400
Move filesystem dialog into separate file
Signed-off-by: David Zeuthen <davidz redhat com>
src/palimpsest/Makefile.am | 1 +
src/palimpsest/gdufilesystemdialog.c | 141 ++++++++++++++++++++++++++++++++++
src/palimpsest/gdufilesystemdialog.h | 36 +++++++++
src/palimpsest/gduwindow.c | 101 +------------------------
4 files changed, 179 insertions(+), 100 deletions(-)
---
diff --git a/src/palimpsest/Makefile.am b/src/palimpsest/Makefile.am
index 7b0301d..2195c5c 100644
--- a/src/palimpsest/Makefile.am
+++ b/src/palimpsest/Makefile.am
@@ -33,6 +33,7 @@ palimpsest_SOURCES = \
gduwindow.h gduwindow.c \
gduatasmartdialog.h gduatasmartdialog.c \
gducrypttabdialog.h gducrypttabdialog.c \
+ gdufilesystemdialog.h gdufilesystemdialog.c \
gdufstabdialog.h gdufstabdialog.c \
$(enum_built_sources) \
$(NULL)
diff --git a/src/palimpsest/gdufilesystemdialog.c b/src/palimpsest/gdufilesystemdialog.c
new file mode 100644
index 0000000..5e51c40
--- /dev/null
+++ b/src/palimpsest/gdufilesystemdialog.c
@@ -0,0 +1,141 @@
+/* -*- 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 "gdufilesystemdialog.h"
+#include "gduvolumegrid.h"
+#include "gduutils.h"
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+
+typedef struct
+{
+ GtkWidget *dialog;
+ gchar *orig_label;
+} ChangeFilesystemLabelData;
+
+static void
+on_change_filesystem_label_entry_changed (GtkEditable *editable,
+ gpointer user_data)
+{
+ ChangeFilesystemLabelData *data = user_data;
+ gboolean sensitive;
+
+ sensitive = FALSE;
+ if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (editable)), data->orig_label) != 0)
+ {
+ sensitive = TRUE;
+ }
+
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog),
+ GTK_RESPONSE_OK,
+ sensitive);
+}
+
+static void
+change_filesystem_label_cb (UDisksFilesystem *filesystem,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ GError *error;
+
+ error = NULL;
+ if (!udisks_filesystem_call_set_label_finish (filesystem,
+ res,
+ &error))
+ {
+ gdu_window_show_error (window,
+ _("Error setting label"),
+ error);
+ g_error_free (error);
+ }
+ g_object_unref (window);
+}
+
+void
+gdu_filesystem_dialog_show (GduWindow *window,
+ UDisksObject *object)
+{
+ gint response;
+ GtkBuilder *builder;
+ GtkWidget *dialog;
+ GtkWidget *entry;
+ UDisksBlock *block;
+ UDisksFilesystem *filesystem;
+ const gchar *label;
+ ChangeFilesystemLabelData data;
+ const gchar *label_to_set;
+
+ block = udisks_object_peek_block (object);
+ filesystem = udisks_object_peek_filesystem (object);
+ g_assert (block != NULL);
+ g_assert (filesystem != NULL);
+
+ dialog = gdu_application_new_widget (gdu_window_get_application (window),
+ "edit-filesystem-dialog.ui",
+ "change-filesystem-label-dialog",
+ &builder);
+ entry = GTK_WIDGET (gtk_builder_get_object (builder, "change-filesystem-label-entry"));
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+ label = udisks_block_get_id_label (block);
+ g_signal_connect (entry,
+ "changed",
+ G_CALLBACK (on_change_filesystem_label_entry_changed),
+ &data);
+ memset (&data, '\0', sizeof (ChangeFilesystemLabelData));
+ data.dialog = dialog;
+ data.orig_label = g_strdup (label);
+
+ gtk_entry_set_text (GTK_ENTRY (entry), label);
+ gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
+
+ gtk_widget_show_all (dialog);
+ gtk_widget_grab_focus (entry);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (response != GTK_RESPONSE_OK)
+ goto out;
+
+ label_to_set = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ udisks_filesystem_call_set_label (filesystem,
+ label_to_set,
+ g_variant_new ("a{sv}", NULL), /* options */
+ NULL, /* cancellable */
+ (GAsyncReadyCallback) change_filesystem_label_cb,
+ g_object_ref (window));
+
+ out:
+ g_free (data.orig_label);
+ gtk_widget_hide (dialog);
+ gtk_widget_destroy (dialog);
+ g_object_unref (builder);
+}
diff --git a/src/palimpsest/gdufilesystemdialog.h b/src/palimpsest/gdufilesystemdialog.h
new file mode 100644
index 0000000..7386718
--- /dev/null
+++ b/src/palimpsest/gdufilesystemdialog.h
@@ -0,0 +1,36 @@
+/* -*- 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_FILESYSTEM_DIALOG_H_H__
+#define __GDU_FILESYSTEM_DIALOG_H_H__
+
+#include <gtk/gtk.h>
+#include "gdutypes.h"
+
+G_BEGIN_DECLS
+
+void gdu_filesystem_dialog_show (GduWindow *window,
+ UDisksObject *object);
+
+G_END_DECLS
+
+#endif /* __GDU_FILESYSTEM_DIALOG_H__ */
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index 129ad9f..6aad431 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -2111,115 +2111,16 @@ gdu_window_show_error (GduWindow *window,
/* ---------------------------------------------------------------------------------------------------- */
-typedef struct
-{
- GtkWidget *dialog;
- gchar *orig_label;
-} ChangeFilesystemLabelData;
-
-static void
-on_change_filesystem_label_entry_changed (GtkEditable *editable,
- gpointer user_data)
-{
- ChangeFilesystemLabelData *data = user_data;
- gboolean sensitive;
-
- sensitive = FALSE;
- if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (editable)), data->orig_label) != 0)
- {
- sensitive = TRUE;
- }
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog),
- GTK_RESPONSE_OK,
- sensitive);
-}
-
-static void
-change_filesystem_label_cb (UDisksFilesystem *filesystem,
- GAsyncResult *res,
- gpointer user_data)
-{
- GduWindow *window = GDU_WINDOW (user_data);
- GError *error;
-
- error = NULL;
- if (!udisks_filesystem_call_set_label_finish (filesystem,
- res,
- &error))
- {
- gdu_window_show_error (window,
- _("Error setting label"),
- error);
- g_error_free (error);
- }
- g_object_unref (window);
-}
-
static void
on_generic_menu_item_edit_label (GtkMenuItem *menu_item,
gpointer user_data)
{
GduWindow *window = GDU_WINDOW (user_data);
- gint response;
- GtkBuilder *builder;
- GtkWidget *dialog;
- GtkWidget *entry;
UDisksObject *object;
- UDisksBlock *block;
- UDisksFilesystem *filesystem;
- const gchar *label;
- ChangeFilesystemLabelData data;
- const gchar *label_to_set;
object = gdu_volume_grid_get_selected_device (GDU_VOLUME_GRID (window->volume_grid));
g_assert (object != NULL);
- block = udisks_object_peek_block (object);
- filesystem = udisks_object_peek_filesystem (object);
- g_assert (block != NULL);
- g_assert (filesystem != NULL);
-
- dialog = gdu_application_new_widget (window->application,
- "edit-filesystem-dialog.ui",
- "change-filesystem-label-dialog",
- &builder);
- entry = GTK_WIDGET (gtk_builder_get_object (builder, "change-filesystem-label-entry"));
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- label = udisks_block_get_id_label (block);
- g_signal_connect (entry,
- "changed",
- G_CALLBACK (on_change_filesystem_label_entry_changed),
- &data);
- memset (&data, '\0', sizeof (ChangeFilesystemLabelData));
- data.dialog = dialog;
- data.orig_label = g_strdup (label);
-
- gtk_entry_set_text (GTK_ENTRY (entry), label);
- gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
-
- gtk_widget_show_all (dialog);
- gtk_widget_grab_focus (entry);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- if (response != GTK_RESPONSE_OK)
- goto out;
-
- label_to_set = gtk_entry_get_text (GTK_ENTRY (entry));
-
- udisks_filesystem_call_set_label (filesystem,
- label_to_set,
- g_variant_new ("a{sv}", NULL), /* options */
- NULL, /* cancellable */
- (GAsyncReadyCallback) change_filesystem_label_cb,
- g_object_ref (window));
-
- out:
- g_free (data.orig_label);
- gtk_widget_hide (dialog);
- gtk_widget_destroy (dialog);
- g_object_unref (builder);
+ gdu_filesystem_dialog_show (window, object);
}
/* ---------------------------------------------------------------------------------------------------- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]