[gnome-commander] advrename profiles: addded dialog for editing profiles



commit 1083506934d10a917c206f7e599d36ee747463e3
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sat May 23 11:47:16 2009 +0200

    advrename profiles: addded dialog for editing profiles
---
 ChangeLog                                    |    8 ++
 po/POTFILES.in                               |    1 +
 src/dialogs/Makefile.am                      |    5 +-
 src/dialogs/gnome-cmd-edit-profile-dialog.cc |  120 ++++++++++++++++++++++++++
 src/dialogs/gnome-cmd-edit-profile-dialog.h  |   28 ++++++
 5 files changed, 160 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index feea05b..2ef5bc0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-05-23  Piotr Eljasiak  <epiotr use pl>
+
+	* po/POTFILES.in:
+	* src/dialogs/Makefile.am:
+	* src/dialogs/gnome-cmd-edit-profile-dialog.cc:
+	* src/dialogs/gnome-cmd-edit-profile-dialog.h:
+	advrename profiles: addded dialog for editing profiles
+
 2009-05-22  Piotr Eljasiak  <epiotr use pl>
 
 	* src/gnome-cmd-advrename-dialog.cc:
diff --git a/po/POTFILES.in b/po/POTFILES.in
index cd32965..365d9c5 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -8,6 +8,7 @@ plugins/cvs/interface.c
 plugins/fileroller/file-roller-plugin.c
 plugins/test/test-plugin.c
 src/dialogs/gnome-cmd-advrename-regex-dialog.cc
+src/dialogs/gnome-cmd-edit-profile-dialog.cc
 src/dialogs/gnome-cmd-manage-profiles-dialog.cc
 src/dirlist.cc
 src/eggcellrendererkeys.cc
diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am
index 5bef93e..322ef5f 100644
--- a/src/dialogs/Makefile.am
+++ b/src/dialogs/Makefile.am
@@ -16,5 +16,6 @@ AM_CPPFLAGS = \
 	-DPLUGIN_DIR=\""$(libdir)/$(PACKAGE)/plugins"\"
 
 libgcmd_dialogs_a_SOURCES = \
-	gnome-cmd-manage-profiles-dialog.h gnome-cmd-manage-profiles-dialog.cc \
-	gnome-cmd-advrename-regex-dialog.h gnome-cmd-advrename-regex-dialog.cc
+	gnome-cmd-advrename-regex-dialog.h gnome-cmd-advrename-regex-dialog.cc \
+	gnome-cmd-edit-profile-dialog.h gnome-cmd-edit-profile-dialog.cc \
+	gnome-cmd-manage-profiles-dialog.h gnome-cmd-manage-profiles-dialog.cc
diff --git a/src/dialogs/gnome-cmd-edit-profile-dialog.cc b/src/dialogs/gnome-cmd-edit-profile-dialog.cc
new file mode 100644
index 0000000..35785f1
--- /dev/null
+++ b/src/dialogs/gnome-cmd-edit-profile-dialog.cc
@@ -0,0 +1,120 @@
+/*
+    GNOME Commander - A GNOME based file manager
+    Copyright (C) 2001-2006 Marcus Bjurman
+    Copyright (C) 2007-2009 Piotr Eljasiak
+
+    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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include <config.h>
+
+#include "gnome-cmd-includes.h"
+#include "gnome-cmd-profile-component.h"
+#include "gnome-cmd-edit-profile-dialog.h"
+#include "utils.h"
+
+using namespace std;
+
+
+enum {GCMD_RESPONSE_RESET=123};
+
+
+static void response_callback (GtkDialog *dialog, int response_id, GnomeCmdProfileComponent *profile)
+{
+    switch (response_id)
+    {
+        case GTK_RESPONSE_HELP:
+            gnome_cmd_help_display ("gnome-commander.xml", "gnome-commander-advanced-rename");
+            g_signal_stop_emission_by_name (dialog, "response");
+            break;
+
+        case GCMD_RESPONSE_RESET:
+            profile->profile.reset();
+            profile->update();
+            g_signal_stop_emission_by_name (dialog, "response");
+            break;
+
+        case GTK_RESPONSE_OK:
+            profile->profile.name = gtk_entry_get_text (GTK_ENTRY (lookup_widget (GTK_WIDGET (dialog), "name")));
+            profile->copy();
+            break;
+
+        case GTK_RESPONSE_NONE:
+        case GTK_RESPONSE_DELETE_EVENT:
+        case GTK_RESPONSE_CANCEL:
+            break;
+
+        default :
+            g_assert_not_reached ();
+    }
+}
+
+
+gboolean gnome_cmd_edit_profile_dialog_new (GtkWindow *parent, GnomeCmdData::AdvrenameConfig::Profile &profile)
+{
+    GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Edit Profile"), parent,
+                                                     GtkDialogFlags (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                                                     GTK_STOCK_HELP, GTK_RESPONSE_HELP,
+                                                     _("Reset"), GCMD_RESPONSE_RESET,
+                                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                                     GTK_STOCK_OK, GTK_RESPONSE_OK,
+                                                     NULL);
+
+    gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+    gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+
+    // HIG defaults
+    gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+    gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5);
+    gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area),6);
+
+    GtkWidget *vbox = gtk_vbox_new (FALSE, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, TRUE, TRUE, 0);
+
+    gchar *str = g_strdup_printf ("<b>%s</b>", _("_Name"));
+    GtkWidget *label = gtk_label_new_with_mnemonic (str);
+    g_free (str);
+
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+    GtkWidget *align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
+    gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 6, 12, 0);
+    gtk_container_add (GTK_CONTAINER (vbox), align);
+
+    GtkWidget *entry = gtk_entry_new ();
+    g_object_set_data (G_OBJECT (dialog), "name", entry);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+    gtk_entry_set_text (GTK_ENTRY (entry), profile.name.c_str());
+    gtk_container_add (GTK_CONTAINER (align), entry);
+
+    GnomeCmdProfileComponent *profile_component = new GnomeCmdProfileComponent(profile);
+    gtk_container_add (GTK_CONTAINER (vbox), *profile_component);
+
+    gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
+
+    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+    g_signal_connect (dialog, "response", G_CALLBACK (response_callback), profile_component);
+
+    gint result = gtk_dialog_run (GTK_DIALOG (dialog));
+
+    gtk_widget_destroy (dialog);
+
+    return result==GTK_RESPONSE_OK;
+}
diff --git a/src/dialogs/gnome-cmd-edit-profile-dialog.h b/src/dialogs/gnome-cmd-edit-profile-dialog.h
new file mode 100644
index 0000000..b719f30
--- /dev/null
+++ b/src/dialogs/gnome-cmd-edit-profile-dialog.h
@@ -0,0 +1,28 @@
+/*
+    GNOME Commander - A GNOME based file manager
+    Copyright (C) 2001-2006 Marcus Bjurman
+    Copyright (C) 2007-2009 Piotr Eljasiak
+
+    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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __GNOME_CMD_EDIT_PROFILE_DIALOG_H__
+#define __GNOME_CMD_EDIT_PROFILE_DIALOG_H__
+
+#include "gnome-cmd-data.h"
+
+gboolean gnome_cmd_edit_profile_dialog_new (GtkWindow *parent, GnomeCmdData::AdvrenameConfig::Profile &profile);
+
+#endif // __GNOME_CMD_EDIT_PROFILE_DIALOG_H__



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]