[gnome-commander] search: new GnomeCmdSelectionProfileComponent
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] search: new GnomeCmdSelectionProfileComponent
- Date: Sat, 11 Jun 2011 08:41:50 +0000 (UTC)
commit 01bfa3cac2bb1e81cad71f1a9cae98132a4991d3
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Sat Jun 11 10:38:47 2011 +0200
search: new GnomeCmdSelectionProfileComponent
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
src/gnome-cmd-selection-profile-component.cc | 249 ++++++++++++++++++++++++++
src/gnome-cmd-selection-profile-component.h | 62 +++++++
4 files changed, 313 insertions(+), 0 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index bf29359..3845790 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -52,6 +52,7 @@ src/gnome-cmd-python-plugin.cc
src/gnome-cmd-quicksearch-popup.cc
src/gnome-cmd-remote-dialog.cc
src/gnome-cmd-rename-dialog.cc
+src/gnome-cmd-selection-profile-component.cc
src/gnome-cmd-smb-auth.cc
src/gnome-cmd-smb-path.cc
src/gnome-cmd-user-actions.cc
diff --git a/src/Makefile.am b/src/Makefile.am
index 99785ad..72f062f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -70,6 +70,7 @@ gnome_commander_SOURCES = \
gnome-cmd-remote-dialog.h gnome-cmd-remote-dialog.cc \
gnome-cmd-quicksearch-popup.h gnome-cmd-quicksearch-popup.cc \
gnome-cmd-rename-dialog.h gnome-cmd-rename-dialog.cc \
+ gnome-cmd-selection-profile-component.h gnome-cmd-selection-profile-component.cc \
gnome-cmd-smb-auth.h gnome-cmd-smb-auth.cc \
gnome-cmd-smb-net.h gnome-cmd-smb-net.cc \
gnome-cmd-smb-path.h gnome-cmd-smb-path.cc \
diff --git a/src/gnome-cmd-selection-profile-component.cc b/src/gnome-cmd-selection-profile-component.cc
new file mode 100755
index 0000000..7022e2f
--- /dev/null
+++ b/src/gnome-cmd-selection-profile-component.cc
@@ -0,0 +1,249 @@
+/*
+ GNOME Commander - A GNOME based file manager
+ Copyright (C) 2001-2006 Marcus Bjurman
+ Copyright (C) 2007-2011 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 <vector>
+
+#include "gnome-cmd-includes.h"
+#include "gnome-cmd-selection-profile-component.h"
+#include "gnome-cmd-data.h"
+#include "gnome-cmd-menu-button.h"
+#include "utils.h"
+
+using namespace std;
+
+
+struct GnomeCmdSelectionProfileComponentClass
+{
+ GtkVBoxClass parent_class;
+};
+
+
+struct GnomeCmdSelectionProfileComponent::Private
+{
+ GtkWidget *table;
+ GtkWidget *filter_type_combo;
+ GtkWidget *pattern_combo;
+ GtkWidget *recurse_combo;
+ GtkWidget *find_text_combo;
+ GtkWidget *find_text_check;
+ GtkWidget *case_check;
+
+ static void on_filter_type_changed (GtkComboBox *combo, GnomeCmdSelectionProfileComponent *component);
+ static void on_find_text_toggled (GtkToggleButton *togglebutton, GnomeCmdSelectionProfileComponent *component);
+
+ Private();
+ ~Private();
+};
+
+
+inline GnomeCmdSelectionProfileComponent::Private::Private()
+{
+}
+
+
+inline GnomeCmdSelectionProfileComponent::Private::~Private()
+{
+ // g_object_unref (template_entry);
+
+ // clear_regex_model(regex_model);
+
+ // if (regex_model) g_object_unref (regex_model);
+
+ // g_free (sample_fname);
+}
+
+
+void GnomeCmdSelectionProfileComponent::Private::on_filter_type_changed(GtkComboBox *combo, GnomeCmdSelectionProfileComponent *component)
+{
+ gtk_widget_grab_focus (component->priv->pattern_combo);
+}
+
+
+void GnomeCmdSelectionProfileComponent::Private::on_find_text_toggled(GtkToggleButton *togglebutton, GnomeCmdSelectionProfileComponent *component)
+{
+ if (gtk_toggle_button_get_active (togglebutton))
+ {
+ gtk_widget_set_sensitive (component->priv->find_text_combo, TRUE);
+ gtk_widget_set_sensitive (component->priv->case_check, TRUE);
+ gtk_widget_grab_focus (component->priv->find_text_combo);
+ }
+ else
+ {
+ gtk_widget_set_sensitive (component->priv->find_text_combo, FALSE);
+ gtk_widget_set_sensitive (component->priv->case_check, FALSE);
+ }
+}
+
+
+static void combo_box_insert_text (const gchar *text, GtkComboBox *widget)
+{
+ gtk_combo_box_append_text (widget, text);
+}
+
+
+G_DEFINE_TYPE (GnomeCmdSelectionProfileComponent, gnome_cmd_selection_profile_component, GTK_TYPE_VBOX)
+
+
+static void gnome_cmd_selection_profile_component_init (GnomeCmdSelectionProfileComponent *component)
+{
+ component->priv = new GnomeCmdSelectionProfileComponent::Private;
+
+ component->priv->table = gtk_table_new (5, 2, FALSE);
+ gtk_table_set_row_spacings (GTK_TABLE (component->priv->table), 6);
+ gtk_table_set_col_spacings (GTK_TABLE (component->priv->table), 6);
+ gtk_box_pack_start (GTK_BOX (component), component->priv->table, FALSE, TRUE, 0);
+
+
+ // search for
+ component->priv->filter_type_combo = gtk_combo_box_new_text ();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (component->priv->filter_type_combo), _("Name matches regex:"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (component->priv->filter_type_combo), _("Name contains:"));
+ component->priv->pattern_combo = gtk_combo_box_entry_new_text ();
+ table_add (component->priv->table, component->priv->filter_type_combo, 0, 0, GTK_FILL);
+ table_add (component->priv->table, component->priv->pattern_combo, 1, 0, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
+
+
+ // recurse check
+ component->priv->recurse_combo = gtk_combo_box_new_text ();
+
+ gtk_combo_box_append_text (GTK_COMBO_BOX (component->priv->recurse_combo), _("Unlimited depth"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (component->priv->recurse_combo), _("Current directory only"));
+ for (int i=1; i<=40; ++i)
+ {
+ gchar *item = g_strdup_printf (ngettext("%i level", "%i levels", i), i);
+ gtk_combo_box_append_text (GTK_COMBO_BOX (component->priv->recurse_combo), item);
+ g_free (item);
+ }
+
+ table_add (component->priv->table, create_label_with_mnemonic (*component, _("Search _recursively:"), component->priv->recurse_combo), 0, 2, GTK_FILL);
+ table_add (component->priv->table, component->priv->recurse_combo, 1, 2, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
+
+
+ // find text
+ component->priv->find_text_check = create_check_with_mnemonic (*component, _("Contains _text:"), "find_text");
+ table_add (component->priv->table, component->priv->find_text_check, 0, 3, GTK_FILL);
+
+ component->priv->find_text_combo = gtk_combo_box_entry_new_text ();
+ table_add (component->priv->table, component->priv->find_text_combo, 1, 3, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
+ gtk_widget_set_sensitive (component->priv->find_text_combo, FALSE);
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (component->priv->find_text_combo), 0);
+
+
+ // case check
+ component->priv->case_check = create_check_with_mnemonic (*component, _("Case sensiti_ve"), "case_check");
+ gtk_table_attach (GTK_TABLE (component->priv->table), component->priv->case_check, 1, 2, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
+ gtk_widget_set_sensitive (component->priv->case_check, FALSE);
+}
+
+
+static void gnome_cmd_selection_profile_component_finalize (GObject *object)
+{
+ GnomeCmdSelectionProfileComponent *component = GNOME_CMD_SELECTION_PROFILE_COMPONENT (object);
+
+ delete component->priv;
+
+ G_OBJECT_CLASS (gnome_cmd_selection_profile_component_parent_class)->finalize (object);
+}
+
+
+static void gnome_cmd_selection_profile_component_class_init (GnomeCmdSelectionProfileComponentClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gnome_cmd_selection_profile_component_finalize;
+}
+
+
+GnomeCmdSelectionProfileComponent::GnomeCmdSelectionProfileComponent(GnomeCmdData::Selection &p, GtkWidget *widget, gchar *label): profile(p)
+{
+ if (widget)
+ {
+ if (label)
+ table_add (priv->table, create_label_with_mnemonic (*this, label, widget), 0, 1, GTK_FILL);
+ table_add (priv->table, widget, 1, 1, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
+ }
+
+ // if (!profile.name_patterns.empty())
+ // {
+ // g_list_foreach (profile.name_patterns.ents, (GFunc) combo_box_insert_text, priv->pattern_combo);
+ // gtk_combo_box_set_active (GTK_COMBO_BOX (priv->pattern_combo), 0);
+ // }
+
+ // if (!profile.content_patterns.empty())
+ // g_list_foreach (profile.content_patterns.ents, (GFunc) combo_box_insert_text, priv->find_text_combo);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->case_check), profile.match_case);
+
+ gtk_widget_grab_focus (priv->pattern_combo);
+
+ gtk_widget_show_all (priv->table);
+
+ g_signal_connect (priv->filter_type_combo, "changed", G_CALLBACK (Private::on_filter_type_changed), this);
+ g_signal_connect (priv->find_text_check, "toggled", G_CALLBACK (Private::on_find_text_toggled), this);
+
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->pattern_combo)), "activate", G_CALLBACK (gtk_window_activate_default), this);
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->find_text_combo)), "activate", G_CALLBACK (gtk_window_activate_default), this);
+}
+
+
+void GnomeCmdSelectionProfileComponent::update()
+{
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->pattern_combo))), profile.filename_pattern.c_str());
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->filter_type_combo), (int) profile.syntax);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->recurse_combo), profile.max_depth+1);
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->find_text_combo))), profile.text_pattern.c_str());
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->find_text_check), profile.content_search);
+}
+
+
+void GnomeCmdSelectionProfileComponent::copy()
+{
+ stringify(profile.filename_pattern, gtk_combo_box_get_active_text (GTK_COMBO_BOX (priv->pattern_combo)));
+ profile.syntax = (Filter::Type) gtk_combo_box_get_active (GTK_COMBO_BOX (priv->filter_type_combo));
+ profile.max_depth = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->recurse_combo)) - 1;
+ stringify(profile.text_pattern, gtk_combo_box_get_active_text (GTK_COMBO_BOX (priv->find_text_combo)));
+ profile.content_search = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->find_text_check));
+}
+
+
+void GnomeCmdSelectionProfileComponent::copy(GnomeCmdData::Selection &profile)
+{
+ stringify(profile.filename_pattern, gtk_combo_box_get_active_text (GTK_COMBO_BOX (priv->pattern_combo)));
+ profile.syntax = (Filter::Type) gtk_combo_box_get_active (GTK_COMBO_BOX (priv->filter_type_combo));
+ profile.max_depth = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->recurse_combo)) - 1;
+ stringify(profile.text_pattern, gtk_combo_box_get_active_text (GTK_COMBO_BOX (priv->find_text_combo)));
+ profile.content_search = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->find_text_check));
+}
+
+
+void GnomeCmdSelectionProfileComponent::set_name_patterns_history(GList *history)
+{
+ g_list_foreach (history, (GFunc) combo_box_insert_text, priv->pattern_combo);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->pattern_combo), 0);
+}
+
+
+void GnomeCmdSelectionProfileComponent::set_content_patterns_history(GList *history)
+{
+ g_list_foreach (history, (GFunc) combo_box_insert_text, priv->find_text_combo);
+}
diff --git a/src/gnome-cmd-selection-profile-component.h b/src/gnome-cmd-selection-profile-component.h
new file mode 100755
index 0000000..868856a
--- /dev/null
+++ b/src/gnome-cmd-selection-profile-component.h
@@ -0,0 +1,62 @@
+/*
+ GNOME Commander - A GNOME based file manager
+ Copyright (C) 2001-2006 Marcus Bjurman
+ Copyright (C) 2007-2011 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_SELECTION_PROFILE_COMPONENT_H__
+#define __GNOME_CMD_SELECTION_PROFILE_COMPONENT_H__
+
+#include "gnome-cmd-data.h"
+
+#define GNOME_CMD_TYPE_SELECTION_PROFILE_COMPONENT (gnome_cmd_selection_profile_component_get_type ())
+#define GNOME_CMD_SELECTION_PROFILE_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNOME_CMD_TYPE_SELECTION_PROFILE_COMPONENT, GnomeCmdSelectionProfileComponent))
+#define GNOME_CMD_SELECTION_PROFILE_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNOME_CMD_TYPE_SELECTION_PROFILE_COMPONENT, GnomeCmdSelectionProfileComponentClass))
+#define GNOME_CMD_IS_SELECTION_PROFILE_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNOME_CMD_TYPE_SELECTION_PROFILE_COMPONENT))
+#define GNOME_CMD_IS_SELECTION_PROFILE_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_CMD_TYPE_SELECTION_PROFILE_COMPONENT))
+#define GNOME_CMD_SELECTION_PROFILE_COMPONENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNOME_CMD_TYPE_SELECTION_PROFILE_COMPONENT, GnomeCmdSelectionProfileComponentClass))
+
+
+GType gnome_cmd_selection_profile_component_get_type ();
+
+
+struct GnomeCmdSelectionProfileComponent
+{
+ GtkVBox parent;
+
+ class Private;
+
+ Private *priv;
+
+ operator GtkWidget * () const { return GTK_WIDGET (this); }
+
+ void *operator new (size_t size) { return g_object_new (GNOME_CMD_TYPE_SELECTION_PROFILE_COMPONENT, NULL); }
+ void operator delete (void *p) { g_object_unref (p); }
+
+ GnomeCmdData::Selection &profile;
+
+ GnomeCmdSelectionProfileComponent(GnomeCmdData::Selection &profile, GtkWidget *widget=NULL, gchar *label=NULL);
+ ~GnomeCmdSelectionProfileComponent() {}
+
+ void update();
+ void copy(); // copies component to associated profile
+ void copy(GnomeCmdData::Selection &profile); // copies component to specified profile
+
+ void set_name_patterns_history(GList *history);
+ void set_content_patterns_history(GList *history);
+};
+
+#endif // __GNOME_CMD_SELECTION_PROFILE_COMPONENT_H__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]