diff options
author | Miguel de Icaza <miguel@src.gnome.org> | 2000-03-31 12:49:36 +0800 |
---|---|---|
committer | Miguel de Icaza <miguel@src.gnome.org> | 2000-03-31 12:49:36 +0800 |
commit | bf794358e25773ec43a6f3dbb98cd019779e0e2f (patch) | |
tree | 2df8920b3b7313f391d9629b298a883a5f66c1f4 /widgets | |
parent | 394ae06d04f2840da08ba63cc6b7e3d9657046b7 (diff) | |
download | gsoc2013-evolution-bf794358e25773ec43a6f3dbb98cd019779e0e2f.tar.gz gsoc2013-evolution-bf794358e25773ec43a6f3dbb98cd019779e0e2f.tar.zst gsoc2013-evolution-bf794358e25773ec43a6f3dbb98cd019779e0e2f.zip |
More work
svn path=/trunk/; revision=2266
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/e-table/e-table-config.c | 168 | ||||
-rw-r--r-- | widgets/e-table/e-table-config.glade | 84 | ||||
-rw-r--r-- | widgets/e-table/e-table-sort-info.c | 30 | ||||
-rw-r--r-- | widgets/e-table/e-table.c | 3 | ||||
-rw-r--r-- | widgets/table/e-table-config.c | 168 | ||||
-rw-r--r-- | widgets/table/e-table-config.glade | 84 | ||||
-rw-r--r-- | widgets/table/e-table-sort-info.c | 30 | ||||
-rw-r--r-- | widgets/table/e-table.c | 3 |
8 files changed, 422 insertions, 148 deletions
diff --git a/widgets/e-table/e-table-config.c b/widgets/e-table/e-table-config.c index da7dde1990..8367a727c1 100644 --- a/widgets/e-table/e-table-config.c +++ b/widgets/e-table/e-table-config.c @@ -9,7 +9,7 @@ */ #include <config.h> #include <gnome.h> -#inclued <glade/glade.h> +#include <glade/glade.h> #include "e-util/e-util.h" #include "e-util/e-xml-utils.h" #include "e-util/e-canvas.h" @@ -19,6 +19,112 @@ #include "e-table-item.h" #include "e-table-group.h" +typedef struct { + GladeXML *gui; + char *old_spec; +} ConfigData; + +static void +load_data (GladeXML *xml, char *label_widget, const char *content) +{ + GtkLabel *label = GTK_LABEL (glade_xml_get_widget (xml, label_widget)); + + gtk_label_set_text (label, content); +} + +static char * +get_fields (ETable *etable) +{ + xmlNode *xmlRoot, *xmlColumns; + xmlNode *column; + GString *res; + char *s; + + res = g_string_new (""); + xmlRoot = xmlDocGetRootElement (xmlSpec); + xmlColumns = e_xml_get_child_by_name (xmlRoot, "columns-shown"); + + for (column = xmlColumns->childs; column; column = column->next){ + ETableCol *ecol; + int col = atoi (colum->childs->content); + + ecol = e_table_header_get_column (etable->header, col); + + g_string_append (res, text); + if (column->next) + g_string_appen (res, ", "); + } + s = res->str; + g_string_free (res, FALSE); + + return s; +} + +static char * +get_grouping (ETable *etable) +{ + return g_strdup ("None"); +} + +static char * +get_sort (ETable *etable) +{ + return g_strdup ("None"); +} + +static char * +get_filter (ETable *etable) +{ + return g_strdup ("None"); +} + +/* + * Loads a user-readable definition of the various e-table parameters + * into the dialog for configuring it + */ +static void +load_label_data (GladeXML *gui, ETabel *etable) +{ + GtkWidget *l; + char *s; + + s = get_fields (etable); + load_data (gui, "label1", s); + g_free (s); + + s = get_grouping (etable); + load_data (gui, "label2", s); + g_free (s); + + s = get_sort (etable); + load_data (gui, "label3", s); + g_free (s); + + s = get_filter (etable); + load_data (gui, "label4", s); + g_free (s); +} + +static void +cb_button_fields (GtkWidget *widget, ETable *etable) +{ +} + +static void +cb_button_grouping (GtkWidget *widget, ETable *etable) +{ +} + +static void +cb_button_sort (GtkWidget *widget, ETable *etable) +{ +} + +static void +cb_button_filter (GtkWidget *widget, ETable *etable) +{ +} + GtkWidget * e_table_gui_config (ETable *etable) { @@ -30,12 +136,70 @@ e_table_gui_config (ETable *etable) return NULL; dialog = GNOME_DIALOG (glade_xml_get_widget (gui, "e-table-config")); + + gtk_signal_connect ( + GTK_OBJECT (glade_xml_get_widget (gui, "button-fields")), + "clicked", GTK_SIGNAL_FUNC (cb_button_fields), etable); + gtk_signal_connect ( + GTK_OBJECT (glade_xml_get_widget (gui, "button-grouping")), + "clicked", GTK_SIGNAL_FUNC (cb_button_grouping), etable); + gtk_signal_connect ( + GTK_OBJECT (glade_xml_get_widget (gui, "button-sort")), + "clicked", GTK_SIGNAL_FUNC (cb_button_sort), etable); + gtk_signal_connect ( + GTK_OBJECT (glade_xml_get_widget (gui, "button-filter")), + "clicked", GTK_SIGNAL_FUNC (cb_button_filter), etable); + + load_label_data (etable); + + gtk_object_set_data ( + GTK_OBJECT (dialog), "config-data", + config_data); + + return dialog; +} + +static void +e_table_gui_destroy_config_data (GtkWidget *widget) +{ + ConfigData *cd = gtk_object_get_data (GTK_OBJECT (widget), "config-data"); + + g_free (cd->old_spec); + gtk_object_destroy (cd->gui); + g_free (cd); +} + +void +e_table_gui_config_accept (GtkWidget *widget, ETable *etable) +{ + e_table_gui_destroy_config_data (widget); } +void +e_table_gui_config_cancel (GtkWidget *widget, ETable *etable) +{ + e_table_gui_destroy_config_data (widget); +} void -e_table_do_gui_config (ETable *etable) +e_table_do_gui_config (GtkWidget *parent, ETable *etable) { + GnomeDialog *dialog; + int r; + + dialog = GNOME_DIALOG (e_table_gui_config (etable)); + if (!dialog) + return; + + if (parent) + gnome_dialog_set_parent (dialog, parent); + + r = gnome_dialog_run (GNOME_DIALOG (dialog)); + + if (r == -1 || r == 1) + e_table_gui_config_cancel (GTK_WIDGET (dialog), etable); + else + e_table_gui_config_accept (GTK_WIDGET (dialog), etable); } diff --git a/widgets/e-table/e-table-config.glade b/widgets/e-table/e-table-config.glade index 176a8c3ab7..8affa8cefa 100644 --- a/widgets/e-table/e-table-config.glade +++ b/widgets/e-table/e-table-config.glade @@ -10,17 +10,9 @@ <language>C</language> <gnome_support>True</gnome_support> <gettext_support>True</gettext_support> - <use_widget_names>False</use_widget_names> <output_main_file>False</output_main_file> <output_support_files>False</output_support_files> <output_build_files>False</output_build_files> - <backup_source_files>True</backup_source_files> - <main_source_file>interface.c</main_source_file> - <main_header_file>interface.h</main_header_file> - <handler_source_file>callbacks.c</handler_source_file> - <handler_header_file>callbacks.h</handler_header_file> - <support_source_file>support.c</support_source_file> - <support_header_file>support.h</support_header_file> <output_translatable_strings>True</output_translatable_strings> <translatable_strings_file>e-table-config.glade.h</translatable_strings_file> </project> @@ -51,6 +43,40 @@ </child> <widget> + <class>GtkHButtonBox</class> + <child_name>GnomeDialog:action_area</child_name> + <name>dialog-action_area2</name> + <layout_style>GTK_BUTTONBOX_END</layout_style> + <spacing>0</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + <pack>GTK_PACK_END</pack> + </child> + + <widget> + <class>GtkButton</class> + <name>button12</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> + </widget> + + <widget> + <class>GtkButton</class> + <name>button14</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> + </widget> + </widget> + + <widget> <class>GtkFrame</class> <name>top-frame</name> <border_width>2</border_width> @@ -75,7 +101,7 @@ <widget> <class>GtkButton</class> - <name>button3</name> + <name>button-fields</name> <can_focus>True</can_focus> <label>Fields</label> <child> @@ -96,7 +122,7 @@ <widget> <class>GtkButton</class> - <name>button4</name> + <name>button-groups</name> <can_focus>True</can_focus> <label>Grouping</label> <child> @@ -117,7 +143,7 @@ <widget> <class>GtkButton</class> - <name>button5</name> + <name>button-sort</name> <can_focus>True</can_focus> <label>Sort</label> <child> @@ -138,7 +164,7 @@ <widget> <class>GtkButton</class> - <name>button6</name> + <name>button-filter</name> <can_focus>True</can_focus> <label>Filter</label> <child> @@ -262,40 +288,6 @@ </widget> </widget> </widget> - - <widget> - <class>GtkHButtonBox</class> - <child_name>GnomeDialog:action_area</child_name> - <name>dialog-action_area2</name> - <layout_style>GTK_BUTTONBOX_END</layout_style> - <spacing>0</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - <pack>GTK_PACK_END</pack> - </child> - - <widget> - <class>GtkButton</class> - <name>button12</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>button14</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> - </widget> - </widget> </widget> </widget> diff --git a/widgets/e-table/e-table-sort-info.c b/widgets/e-table/e-table-sort-info.c index 9e8d6e8228..bf90a13602 100644 --- a/widgets/e-table/e-table-sort-info.c +++ b/widgets/e-table/e-table-sort-info.c @@ -11,10 +11,11 @@ #include <gtk/gtksignal.h> #include <gnome-xml/tree.h> #include "e-table-sort-info.h" +#include "e-util/e-util.h" #define ETM_CLASS(e) ((ETableSortInfoClass *)((GtkObject *)e)->klass) -#define PARENT_TYPE gtk_object_get_type (); +#define PARENT_TYPE gtk_object_get_type () static GtkObjectClass *e_table_sort_info_parent_class; @@ -81,31 +82,8 @@ e_table_sort_info_class_init (GtkObjectClass *object_class) GTK_ARG_READWRITE, ARG_GROUPING); } - -guint -e_table_sort_info_get_type (void) -{ - static guint type = 0; - - if (!type) - { - GtkTypeInfo info = - { - "ETableSortInfo", - sizeof (ETableSortInfo), - sizeof (ETableSortInfoClass), - (GtkClassInitFunc) e_table_sort_info_class_init, - NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} +E_MAKE_TYPE(e_table_sort_info, "ETableSortInfo", ETableSortInfo, + e_table_sort_info_class_init, NULL, PARENT_TYPE); void e_table_sort_info_changed (ETableSortInfo *e_table_sort_info) diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c index fbf0dbfa67..7360666d06 100644 --- a/widgets/e-table/e-table.c +++ b/widgets/e-table/e-table.c @@ -104,6 +104,7 @@ e_table_make_header (ETable *e_table, ETableHeader *full_header, xmlNode *xmlCol const int max_cols = e_table_header_count (full_header); nh = e_table_header_new (); + for (column = xmlColumns->childs; column; column = column->next) { int col = atoi (column->childs->content); @@ -881,6 +882,7 @@ e_table_get_specification (ETable *e_table) xmlDoc *doc = et_build_tree (e_table); xmlChar *buffer; gint size; + xmlDocDumpMemory (doc, &buffer, &size); @@ -892,6 +894,7 @@ void e_table_save_specification (ETable *e_table, gchar *filename) { xmlDoc *doc = et_build_tree (e_table); + xmlSaveFile (filename, doc); xmlFreeDoc (doc); } diff --git a/widgets/table/e-table-config.c b/widgets/table/e-table-config.c index da7dde1990..8367a727c1 100644 --- a/widgets/table/e-table-config.c +++ b/widgets/table/e-table-config.c @@ -9,7 +9,7 @@ */ #include <config.h> #include <gnome.h> -#inclued <glade/glade.h> +#include <glade/glade.h> #include "e-util/e-util.h" #include "e-util/e-xml-utils.h" #include "e-util/e-canvas.h" @@ -19,6 +19,112 @@ #include "e-table-item.h" #include "e-table-group.h" +typedef struct { + GladeXML *gui; + char *old_spec; +} ConfigData; + +static void +load_data (GladeXML *xml, char *label_widget, const char *content) +{ + GtkLabel *label = GTK_LABEL (glade_xml_get_widget (xml, label_widget)); + + gtk_label_set_text (label, content); +} + +static char * +get_fields (ETable *etable) +{ + xmlNode *xmlRoot, *xmlColumns; + xmlNode *column; + GString *res; + char *s; + + res = g_string_new (""); + xmlRoot = xmlDocGetRootElement (xmlSpec); + xmlColumns = e_xml_get_child_by_name (xmlRoot, "columns-shown"); + + for (column = xmlColumns->childs; column; column = column->next){ + ETableCol *ecol; + int col = atoi (colum->childs->content); + + ecol = e_table_header_get_column (etable->header, col); + + g_string_append (res, text); + if (column->next) + g_string_appen (res, ", "); + } + s = res->str; + g_string_free (res, FALSE); + + return s; +} + +static char * +get_grouping (ETable *etable) +{ + return g_strdup ("None"); +} + +static char * +get_sort (ETable *etable) +{ + return g_strdup ("None"); +} + +static char * +get_filter (ETable *etable) +{ + return g_strdup ("None"); +} + +/* + * Loads a user-readable definition of the various e-table parameters + * into the dialog for configuring it + */ +static void +load_label_data (GladeXML *gui, ETabel *etable) +{ + GtkWidget *l; + char *s; + + s = get_fields (etable); + load_data (gui, "label1", s); + g_free (s); + + s = get_grouping (etable); + load_data (gui, "label2", s); + g_free (s); + + s = get_sort (etable); + load_data (gui, "label3", s); + g_free (s); + + s = get_filter (etable); + load_data (gui, "label4", s); + g_free (s); +} + +static void +cb_button_fields (GtkWidget *widget, ETable *etable) +{ +} + +static void +cb_button_grouping (GtkWidget *widget, ETable *etable) +{ +} + +static void +cb_button_sort (GtkWidget *widget, ETable *etable) +{ +} + +static void +cb_button_filter (GtkWidget *widget, ETable *etable) +{ +} + GtkWidget * e_table_gui_config (ETable *etable) { @@ -30,12 +136,70 @@ e_table_gui_config (ETable *etable) return NULL; dialog = GNOME_DIALOG (glade_xml_get_widget (gui, "e-table-config")); + + gtk_signal_connect ( + GTK_OBJECT (glade_xml_get_widget (gui, "button-fields")), + "clicked", GTK_SIGNAL_FUNC (cb_button_fields), etable); + gtk_signal_connect ( + GTK_OBJECT (glade_xml_get_widget (gui, "button-grouping")), + "clicked", GTK_SIGNAL_FUNC (cb_button_grouping), etable); + gtk_signal_connect ( + GTK_OBJECT (glade_xml_get_widget (gui, "button-sort")), + "clicked", GTK_SIGNAL_FUNC (cb_button_sort), etable); + gtk_signal_connect ( + GTK_OBJECT (glade_xml_get_widget (gui, "button-filter")), + "clicked", GTK_SIGNAL_FUNC (cb_button_filter), etable); + + load_label_data (etable); + + gtk_object_set_data ( + GTK_OBJECT (dialog), "config-data", + config_data); + + return dialog; +} + +static void +e_table_gui_destroy_config_data (GtkWidget *widget) +{ + ConfigData *cd = gtk_object_get_data (GTK_OBJECT (widget), "config-data"); + + g_free (cd->old_spec); + gtk_object_destroy (cd->gui); + g_free (cd); +} + +void +e_table_gui_config_accept (GtkWidget *widget, ETable *etable) +{ + e_table_gui_destroy_config_data (widget); } +void +e_table_gui_config_cancel (GtkWidget *widget, ETable *etable) +{ + e_table_gui_destroy_config_data (widget); +} void -e_table_do_gui_config (ETable *etable) +e_table_do_gui_config (GtkWidget *parent, ETable *etable) { + GnomeDialog *dialog; + int r; + + dialog = GNOME_DIALOG (e_table_gui_config (etable)); + if (!dialog) + return; + + if (parent) + gnome_dialog_set_parent (dialog, parent); + + r = gnome_dialog_run (GNOME_DIALOG (dialog)); + + if (r == -1 || r == 1) + e_table_gui_config_cancel (GTK_WIDGET (dialog), etable); + else + e_table_gui_config_accept (GTK_WIDGET (dialog), etable); } diff --git a/widgets/table/e-table-config.glade b/widgets/table/e-table-config.glade index 176a8c3ab7..8affa8cefa 100644 --- a/widgets/table/e-table-config.glade +++ b/widgets/table/e-table-config.glade @@ -10,17 +10,9 @@ <language>C</language> <gnome_support>True</gnome_support> <gettext_support>True</gettext_support> - <use_widget_names>False</use_widget_names> <output_main_file>False</output_main_file> <output_support_files>False</output_support_files> <output_build_files>False</output_build_files> - <backup_source_files>True</backup_source_files> - <main_source_file>interface.c</main_source_file> - <main_header_file>interface.h</main_header_file> - <handler_source_file>callbacks.c</handler_source_file> - <handler_header_file>callbacks.h</handler_header_file> - <support_source_file>support.c</support_source_file> - <support_header_file>support.h</support_header_file> <output_translatable_strings>True</output_translatable_strings> <translatable_strings_file>e-table-config.glade.h</translatable_strings_file> </project> @@ -51,6 +43,40 @@ </child> <widget> + <class>GtkHButtonBox</class> + <child_name>GnomeDialog:action_area</child_name> + <name>dialog-action_area2</name> + <layout_style>GTK_BUTTONBOX_END</layout_style> + <spacing>0</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + <pack>GTK_PACK_END</pack> + </child> + + <widget> + <class>GtkButton</class> + <name>button12</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> + </widget> + + <widget> + <class>GtkButton</class> + <name>button14</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> + </widget> + </widget> + + <widget> <class>GtkFrame</class> <name>top-frame</name> <border_width>2</border_width> @@ -75,7 +101,7 @@ <widget> <class>GtkButton</class> - <name>button3</name> + <name>button-fields</name> <can_focus>True</can_focus> <label>Fields</label> <child> @@ -96,7 +122,7 @@ <widget> <class>GtkButton</class> - <name>button4</name> + <name>button-groups</name> <can_focus>True</can_focus> <label>Grouping</label> <child> @@ -117,7 +143,7 @@ <widget> <class>GtkButton</class> - <name>button5</name> + <name>button-sort</name> <can_focus>True</can_focus> <label>Sort</label> <child> @@ -138,7 +164,7 @@ <widget> <class>GtkButton</class> - <name>button6</name> + <name>button-filter</name> <can_focus>True</can_focus> <label>Filter</label> <child> @@ -262,40 +288,6 @@ </widget> </widget> </widget> - - <widget> - <class>GtkHButtonBox</class> - <child_name>GnomeDialog:action_area</child_name> - <name>dialog-action_area2</name> - <layout_style>GTK_BUTTONBOX_END</layout_style> - <spacing>0</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - <pack>GTK_PACK_END</pack> - </child> - - <widget> - <class>GtkButton</class> - <name>button12</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>button14</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> - </widget> - </widget> </widget> </widget> diff --git a/widgets/table/e-table-sort-info.c b/widgets/table/e-table-sort-info.c index 9e8d6e8228..bf90a13602 100644 --- a/widgets/table/e-table-sort-info.c +++ b/widgets/table/e-table-sort-info.c @@ -11,10 +11,11 @@ #include <gtk/gtksignal.h> #include <gnome-xml/tree.h> #include "e-table-sort-info.h" +#include "e-util/e-util.h" #define ETM_CLASS(e) ((ETableSortInfoClass *)((GtkObject *)e)->klass) -#define PARENT_TYPE gtk_object_get_type (); +#define PARENT_TYPE gtk_object_get_type () static GtkObjectClass *e_table_sort_info_parent_class; @@ -81,31 +82,8 @@ e_table_sort_info_class_init (GtkObjectClass *object_class) GTK_ARG_READWRITE, ARG_GROUPING); } - -guint -e_table_sort_info_get_type (void) -{ - static guint type = 0; - - if (!type) - { - GtkTypeInfo info = - { - "ETableSortInfo", - sizeof (ETableSortInfo), - sizeof (ETableSortInfoClass), - (GtkClassInitFunc) e_table_sort_info_class_init, - NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} +E_MAKE_TYPE(e_table_sort_info, "ETableSortInfo", ETableSortInfo, + e_table_sort_info_class_init, NULL, PARENT_TYPE); void e_table_sort_info_changed (ETableSortInfo *e_table_sort_info) diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index fbf0dbfa67..7360666d06 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -104,6 +104,7 @@ e_table_make_header (ETable *e_table, ETableHeader *full_header, xmlNode *xmlCol const int max_cols = e_table_header_count (full_header); nh = e_table_header_new (); + for (column = xmlColumns->childs; column; column = column->next) { int col = atoi (column->childs->content); @@ -881,6 +882,7 @@ e_table_get_specification (ETable *e_table) xmlDoc *doc = et_build_tree (e_table); xmlChar *buffer; gint size; + xmlDocDumpMemory (doc, &buffer, &size); @@ -892,6 +894,7 @@ void e_table_save_specification (ETable *e_table, gchar *filename) { xmlDoc *doc = et_build_tree (e_table); + xmlSaveFile (filename, doc); xmlFreeDoc (doc); } |