/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007, 2009, 2011, 2012 Free Software Foundation
+ Copyright (C) 2007, 2009, 2011, 2012, 2015 Free Software Foundation
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
#include <config.h>
-#include "find-dialog.h"
-#include "psppire-selector.h"
-#include "psppire-dialog.h"
-#include "builder-wrapper.h"
-#include "helper.h"
-#include "psppire-data-window.h"
-#include "dict-display.h"
-#include <data/value.h>
-#include <data/format.h>
-#include <data/datasheet.h>
-#include <data/data-in.h>
-#include "psppire-data-store.h"
#include <ctype.h>
-#include <sys/types.h>
-#include <regex.h>
-#include <libpspp/cast.h>
-#include <libpspp/message.h>
-
#include <gtk/gtk.h>
+#include <regex.h>
#include <stdlib.h>
+#include <sys/types.h>
-#include "xalloc.h"
+#include "data/data-in.h"
+#include "data/datasheet.h"
+#include "data/format.h"
+#include "data/value.h"
+#include "libpspp/cast.h"
+#include "libpspp/message.h"
+#include "ui/gui/builder-wrapper.h"
+#include "ui/gui/dict-display.h"
+#include "ui/gui/find-dialog.h"
+#include "ui/gui/helper.h"
+#include "ui/gui/psppire-data-sheet.h"
+#include "ui/gui/psppire-data-store.h"
+#include "ui/gui/psppire-data-window.h"
+#include "ui/gui/psppire-dialog.h"
+#include "ui/gui/psppire-selector.h"
+
+#include "gl/xalloc.h"
#include <gettext.h>
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-/* FIXME: These shouldn't be here */
-#include "psppire-var-store.h"
-
struct find_dialog
{
GtkBuilder *xml;
static void
do_find (GObject *obj, const struct find_dialog *fd)
{
+ PsppireDataSheet *data_sheet;
casenumber x = -1;
gint column = -1;
glong row;
- g_object_get (fd->de->data_editor, "current-case", &row, NULL);
-
- if ( row < 0 )
- row = 0;
+ data_sheet = psppire_data_editor_get_active_data_sheet (fd->de->data_editor);
+ row = psppire_data_sheet_get_selected_case (data_sheet);
find_value (fd, row, &x, &column);
-
if ( x != -1)
{
gtk_notebook_set_current_page (GTK_NOTEBOOK (fd->de->data_editor),
PSPPIRE_DATA_EDITOR_DATA_VIEW);
- g_object_set (fd->de->data_editor,
- "current-case", x,
- "current-variable", column,
- NULL);
+ psppire_data_sheet_goto_case (data_sheet, x);
+ psppire_data_sheet_goto_variable (data_sheet, column);
}
-
}
/* Callback on the selector.
GtkWidget *buttonbox;
- PsppireVarStore *vs ;
PsppireDataStore *ds ;
fd.xml = builder_new ("find.ui");
fd.de = de;
- find_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
+ find_button = gtk_button_new_with_label (_("Find"));
gtk_widget_show (find_button);
buttonbox = get_widget_assert (fd.xml, "find-buttonbox");
selector = get_widget_assert (fd.xml, "find-selector");
g_object_get (de->data_editor,
- "var-store", &vs,
+ "dictionary", &fd.dict,
"data-store", &ds,
NULL);
- g_object_get (vs, "dictionary", &fd.dict, NULL);
-
fd.data = ds->datasheet;
fd.variable_entry = get_widget_assert (fd.xml, "find-variable-entry");
static casenumber
cm1 (casenumber current, struct datasheet *data)
{
+ if (current == -1)
+ return datasheet_get_n_rows (data);
+
return current - 1;
}
{
casenumber next = current;
+ if (current == -1)
+ return datasheet_get_n_rows (data);
+
backward_wrap (&next, data);
return next;
static casenumber
minus1 (casenumber current, struct datasheet *data)
{
+ if (current == -1)
+ return 0;
+
return -1;
}
const struct string_comparator *ssc =
(const struct string_comparator *) cmptr;
+ int width;
+
const char *text = var_lookup_value_label (cmptr->var, val);
- int width = strlen (text);
+ if (text == NULL)
+ return false;
+
+ width = strlen (text);
assert ( cmptr->flags & STR_CMP_LABELS);
const char *target_string = gtk_entry_get_text (GTK_ENTRY (fd->value_entry));
enum string_cmp_flags flags = 0;
- g_assert (current_row >= 0);
var = dict_lookup_var (fd->dict->dict, var_name);
if ( ! var )