X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=src%2Fui%2Fgui%2Fvar-type-dialog.c;h=514d983c3d719529f776c19d257212d2557dfa3f;hb=2bbf5d66eeeffdbcded913145f05b9a6046056fa;hp=8ca7b1c92d98735e6fc8e6ea29c117154ef699ee;hpb=8de0368d4ec642662fdff99aefc5fbf19ce5afc9;p=pspp diff --git a/src/ui/gui/var-type-dialog.c b/src/ui/gui/var-type-dialog.c index 8ca7b1c92d..514d983c3d 100644 --- a/src/ui/gui/var-type-dialog.c +++ b/src/ui/gui/var-type-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2005, 2006, 2010, 2011, 2012 Free Software Foundation + Copyright (C) 2005, 2006, 2010, 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 @@ -51,7 +51,9 @@ static const struct fmt_spec date_format[] = {FMT_WKYR, 10, 0}, {FMT_WKYR, 8, 0}, {FMT_DATETIME, 17, 0}, - {FMT_DATETIME, 20, 0} + {FMT_DATETIME, 20, 0}, + {FMT_YMDHMS, 16, 0}, + {FMT_YMDHMS, 20, 0} }; @@ -84,6 +86,9 @@ static GObject *psppire_var_type_dialog_constructor (GType type, guint, GObjectConstructParam *); static void psppire_var_type_dialog_set_state (PsppireVarTypeDialog *); +static void psppire_var_type_dialog_set_format (PsppireVarTypeDialog *dialog, + const struct fmt_spec *format); + static int find_format (const struct fmt_spec *target, const struct fmt_spec formats[], int n_formats); static int find_format_type (int target, const int types[], int n_types); @@ -145,7 +150,7 @@ psppire_var_type_dialog_get_property (GObject *object, } } -void +static void psppire_var_type_dialog_set_format (PsppireVarTypeDialog *dialog, const struct fmt_spec *format) { @@ -153,7 +158,7 @@ psppire_var_type_dialog_set_format (PsppireVarTypeDialog *dialog, psppire_var_type_dialog_set_state (dialog); } -const struct fmt_spec * +static const struct fmt_spec * psppire_var_type_dialog_get_format (const PsppireVarTypeDialog *dialog) { return &dialog->fmt_l; @@ -194,12 +199,11 @@ psppire_var_type_dialog_new (const struct fmt_spec *format) { return PSPPIRE_VAR_TYPE_DIALOG ( g_object_new (PSPPIRE_TYPE_VAR_TYPE_DIALOG, - "orientation", PSPPIRE_HORIZONTAL, "format", format, NULL)); } -void +gint psppire_var_type_dialog_run (GtkWindow *parent_window, struct fmt_spec *format) { @@ -210,10 +214,13 @@ psppire_var_type_dialog_run (GtkWindow *parent_window, gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); gtk_widget_show (GTK_WIDGET (dialog)); - if (psppire_dialog_run (PSPPIRE_DIALOG (dialog)) == GTK_RESPONSE_OK) + gint result = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); + if (result == GTK_RESPONSE_OK) *format = *psppire_var_type_dialog_get_format (dialog); gtk_widget_destroy (GTK_WIDGET (dialog)); + + return result; } @@ -454,6 +461,9 @@ get_index_from_treeview (GtkTreeView *treeview) GtkTreeIter iter; gint index; + if (selection == NULL) + return -1; + gtk_tree_selection_get_selected (selection, &model, &iter); path = gtk_tree_model_get_path (model, &iter); if (!path || gtk_tree_path_get_depth (path) < 1) @@ -471,7 +481,11 @@ static void set_date_format_from_treeview (GtkTreeView *treeview, PsppireVarTypeDialog *dialog) { - dialog->fmt_l = date_format[get_index_from_treeview (treeview)]; + gint idx = get_index_from_treeview (treeview); + if (idx < 0) + return; + + dialog->fmt_l = date_format[idx]; } /* Callback for when a dollar treeview row is changed. @@ -480,7 +494,11 @@ static void set_dollar_format_from_treeview (GtkTreeView *treeview, PsppireVarTypeDialog *dialog) { - dialog->fmt_l = dollar_format[get_index_from_treeview (treeview)]; + gint idx = get_index_from_treeview (treeview); + if (idx < 0) + return; + + dialog->fmt_l = dollar_format[idx]; } /* Callback for when a treeview row is changed. @@ -489,7 +507,11 @@ static void set_custom_format_from_treeview (GtkTreeView *treeview, PsppireVarTypeDialog *dialog) { - dialog->fmt_l.type = cc_format[get_index_from_treeview (treeview)]; + gint idx = get_index_from_treeview (treeview); + if (idx < 0) + return; + + dialog->fmt_l.type = cc_format[idx]; update_adj_ranges (dialog); fmt_fix_output (&dialog->fmt_l); update_width_decimals (dialog); @@ -513,7 +535,7 @@ psppire_var_type_dialog_constructor (GType type, xml = builder_new ("var-type-dialog.ui"); - content_area = GTK_CONTAINER (PSPPIRE_DIALOG (dialog)->box); + content_area = GTK_CONTAINER (PSPPIRE_DIALOG (dialog)); gtk_container_add (GTK_CONTAINER (content_area), get_widget_assert (xml, "var-type-dialog")); @@ -809,6 +831,8 @@ psppire_var_type_dialog_set_state (PsppireVarTypeDialog *dialog) case FMT_MOYR: case FMT_WKYR: case FMT_DATETIME: + case FMT_YMDHMS: + case FMT_MTIME: case FMT_TIME: case FMT_DTIME: case FMT_WKDAY: