X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fvar-type-dialog.c;h=7f1d4aeccdc6e187332045965438a54f537f2170;hb=43f0e5bf6c53ee0ba31b259aab230861baa4eb7e;hp=a44b04465b475cd014aa68324d1558e52bd3787f;hpb=b2b2b0a29f80de89d96bcceea90f117930ab47b9;p=pspp diff --git a/src/ui/gui/var-type-dialog.c b/src/ui/gui/var-type-dialog.c index a44b04465b..7f1d4aeccd 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 @@ -197,7 +197,6 @@ 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)); } @@ -457,6 +456,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) @@ -474,7 +476,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. @@ -483,7 +489,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. @@ -492,7 +502,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); @@ -516,7 +530,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"));