sort.c File Reference


Detailed Description

column sort

Author:
Copyright 2006-2007 Neil Williams <linux@codehelp.co.uk>

Copyright 1999 Sam Phillips (sam@usaworks.com)

Definition in file sort.c.

#include "config.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <gtkextra/gtksheet.h>
#include "types.h"
#include "dim_list_menu.h"
#include "edit.h"
#include "main.h"
#include "dialog_initial.h"

Go to the source code of this file.

Data Structures

struct  QlSortRow

Defines

#define FROM_LIST_WIDTH   180
#define FROM_LIST_HEIGHT   180

Enumerations

enum  { SORT_COL, FROM_COL }
enum  QlSortType {
  QL_SORT_NONE, QL_SORT_ADD, QL_SORT_EDIT, QL_SORT_APPLY,
  QL_SORT_DELETE
}

Functions

static void ascending_clicked (GtkObject G_GNUC_UNUSED *object, gpointer entry)
static void descending_clicked (GtkObject G_GNUC_UNUSED *object, gpointer entry)
static void field_change (GtkObject *object, gpointer G_GNUC_UNUSED entry)
static GtkWidget * field_menu (QlTabData *tab, gint level)
static gint sort_compare (gconstpointer fir, gconstpointer sec)
static void do_the_nasty_sort (QlTabData *tab)
static void ok_clicked (GtkWidget *w, gpointer G_GNUC_UNUSED entry)
static void select_ok (GtkButton *button, gpointer data)
static void build_select_box (QlTabData *tab)
static void display_edit_window (QlTabData *tab)
void sort_add (GtkAction G_GNUC_UNUSED *a, gpointer data)
void sort_do_it (QlTabData *tab, gint sortno)
void sort_by_column (GtkAction G_GNUC_UNUSED *w, gpointer data)
void sort_delete (GtkAction G_GNUC_UNUSED *w, gpointer data)
void sort_edit (GtkAction G_GNUC_UNUSED *w, gpointer data)
void sort_apply (GtkWidget G_GNUC_UNUSED *w, gpointer data)

Variables

QlSortRow * big_array
QlSortInfocurr_sort
QlSortInfoedit_sort
QlSortType select_mode
gint levels
gint level_type [MAX_SORT_NESTING+1]
gint level_ascending [MAX_SORT_NESTING+1]
gint level_formatting [MAX_SORT_NESTING+1]


Function Documentation

static GtkWidget* field_menu ( QlTabData tab,
gint  level 
) [static]

Todo:
replace with a callback

Definition at line 114 of file sort.c.

00115 {
00116     GtkWidget *temp_box, *ascend_button, *descend_button;
00117     GtkWidget *menu, *menu_item, *name_label;
00118     gint ret_value, fieldx;
00119     GtkComboBox *field_box;
00120 
00121     menu = gtk_menu_new ();
00122     menu_item = gtk_menu_item_new_with_label (_("-Unused-"));
00123     gtk_widget_show (menu_item);
00124     ret_value = level * 100;
00125     g_signal_connect (GTK_OBJECT (menu_item),
00126         "select", G_CALLBACK (field_change), &ret_value);
00127     gtk_menu_attach (GTK_MENU (menu), menu_item, 0, 1, 0, 1);
00128 
00129     /* add the individual fields to the menu */
00130     field_box = GTK_COMBO_BOX (gtk_combo_box_new_text ());
00132     for (fieldx = 0; fieldx <= tab->file->last_field; fieldx++)
00133     {
00134         QlFieldInfo * field;
00135         ret_value = level * 100 + fieldx + 1;
00136         field = ql_get_fieldinfo (tab, fieldx);
00137         gtk_combo_box_insert_text (field_box, ret_value,
00138             field->name);
00139     }
00140     gtk_widget_show (GTK_WIDGET (field_box));
00141     g_signal_connect (GTK_OBJECT (field_box),
00142         "changed", G_CALLBACK (field_change), NULL);
00143     if (edit_sort->line[level].field >= 0)
00144         gtk_combo_box_set_active (field_box, edit_sort->line[level].field);
00145     /* Pack Widgets into boxes */
00146     temp_box = gtk_hbox_new (FALSE, 5);
00147 
00148     /* now ascending and descending buttons */
00149     /* ad_vbox = gtk_vbox_new (FALSE, 5); */
00150     ascend_button = gtk_radio_button_new_with_label 
00151         (NULL, _("Ascending"));
00152     descend_button =
00153         gtk_radio_button_new_with_label (gtk_radio_button_get_group
00154         (GTK_RADIO_BUTTON (ascend_button)), _("Descending"));
00155     if (edit_sort->line[level].ascending)
00156         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ascend_button),
00157             1);
00158     else
00159         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (descend_button),
00160             1);
00161 
00162     /* Callbacks for radio buttons */
00163     g_signal_connect (GTK_OBJECT (ascend_button), "clicked",
00164         G_CALLBACK (ascending_clicked), GINT_TO_POINTER (level));
00165     g_signal_connect (GTK_OBJECT (descend_button), "clicked",
00166         G_CALLBACK (descending_clicked), GINT_TO_POINTER (level));
00167 
00168     gtk_box_pack_end (GTK_BOX (temp_box), descend_button, FALSE, FALSE, 0);
00169     gtk_box_pack_end (GTK_BOX (temp_box), ascend_button, FALSE, FALSE, 0);
00170     gtk_box_pack_end (GTK_BOX (temp_box), GTK_WIDGET (field_box),
00171         FALSE, FALSE, 0);
00172 
00173     /* now right justify the name label */
00174     if (level)
00175         name_label = gtk_label_new (_("then on: "));
00176     else
00177         name_label = gtk_label_new (_("Primary sort on: "));
00178     gtk_box_pack_end (GTK_BOX (temp_box), name_label, FALSE, FALSE, 0);
00179 
00180     return (temp_box);
00181 }                               /* end of field_menu () */


Generated on Mon Jan 28 22:02:11 2008 for quicklist by  doxygen 1.5.4