From 5d5b324c12dc799e6e4dc3230e93edaa7d0a0272 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Fri, 30 Mar 2007 23:39:32 +0000 Subject: [PATCH] Numerous GUI enhancements. --- glade/ChangeLog | 6 + glade/automake.mk | 21 +- glade/dialog.c | 12 +- glade/icons/16x16/psppire-buttonbox.png | Bin 0 -> 124 bytes glade/icons/16x16/psppire-dialog.png | Bin 0 -> 212 bytes glade/icons/16x16/psppire-keypad.png | Bin 0 -> 112 bytes glade/icons/16x16/psppire-selector.png | Bin 0 -> 124 bytes glade/icons/22x22/psppire-buttonbox.png | Bin 0 -> 134 bytes glade/icons/22x22/psppire-dialog.png | Bin 0 -> 283 bytes glade/icons/22x22/psppire-keypad.png | Bin 0 -> 120 bytes glade/icons/22x22/psppire-selector.png | Bin 0 -> 134 bytes glade/psppire.xml | 155 +++-- po/de.po | 64 +- po/pspp.pot | 64 +- src/ui/gui/ChangeLog | 17 + src/ui/gui/automake.mk | 14 +- src/ui/gui/data-editor.c | 22 + src/ui/gui/data-editor.glade | 4 +- src/ui/gui/data-editor.h | 1 + src/ui/gui/dialog-common.c | 138 +++++ src/ui/gui/dialog-common.h | 62 ++ src/ui/gui/psppire-keypad.c | 454 ++++++++++++++ src/ui/gui/psppire-keypad.h | 117 ++++ src/ui/gui/psppire-selector.c | 133 ++++- src/ui/gui/psppire-selector.h | 18 + src/ui/gui/psppire.glade | 759 +++++++++++++++++++++++- src/ui/gui/split-file-dialog.c | 201 +++++++ src/ui/gui/split-file-dialog.h | 31 + src/ui/gui/transpose-dialog.c | 98 +-- 29 files changed, 2167 insertions(+), 224 deletions(-) create mode 100644 glade/ChangeLog create mode 100644 glade/icons/16x16/psppire-buttonbox.png create mode 100644 glade/icons/16x16/psppire-dialog.png create mode 100644 glade/icons/16x16/psppire-keypad.png create mode 100644 glade/icons/16x16/psppire-selector.png create mode 100644 glade/icons/22x22/psppire-buttonbox.png create mode 100644 glade/icons/22x22/psppire-dialog.png create mode 100644 glade/icons/22x22/psppire-keypad.png create mode 100644 glade/icons/22x22/psppire-selector.png create mode 100644 src/ui/gui/dialog-common.c create mode 100644 src/ui/gui/dialog-common.h create mode 100644 src/ui/gui/psppire-keypad.c create mode 100644 src/ui/gui/psppire-keypad.h create mode 100644 src/ui/gui/split-file-dialog.c create mode 100644 src/ui/gui/split-file-dialog.h diff --git a/glade/ChangeLog b/glade/ChangeLog new file mode 100644 index 00000000..d7d46775 --- /dev/null +++ b/glade/ChangeLog @@ -0,0 +1,6 @@ +Sat Mar 31 07:09:33 WST 2007 John Darrington + + * Added icons directory and its contents. + + * Re-wrote psppire.xml to work with glade 3.2.0, and to know about the + keypad widget. diff --git a/glade/automake.mk b/glade/automake.mk index 5d5a6583..e9af9aeb 100644 --- a/glade/automake.mk +++ b/glade/automake.mk @@ -4,18 +4,35 @@ module_LTLIBRARIES = libglade-psppire.la moduledir = `pkg-config --variable=moduledir libgladeui-1.0` catalogdir = `pkg-config --variable=catalogdir libgladeui-1.0` +pixmapdir = `pkg-config --variable=pixmapdir libgladeui-1.0` + +small_pixmapdir = $(pixmapdir)/16x16 +large_pixmapdir = $(pixmapdir)/22x22 libglade_psppire_la_SOURCES = \ glade/dialog.c \ glade/bbox.c \ glade/selector.c \ - src/ui/gui/psppire-dialog.c \ src/ui/gui/psppire-buttonbox.c \ + src/ui/gui/psppire-dialog.c \ + src/ui/gui/psppire-keypad.c \ src/ui/gui/psppire-selector.c nodist_catalog_DATA = \ glade/psppire.xml +nodist_small_pixmap_DATA = \ + glade/icons/16x16/psppire-buttonbox.png \ + glade/icons/16x16/psppire-dialog.png \ + glade/icons/16x16/psppire-keypad.png \ + glade/icons/16x16/psppire-selector.png + +nodist_large_pixmap_DATA = \ + glade/icons/22x22/psppire-buttonbox.png \ + glade/icons/22x22/psppire-dialog.png \ + glade/icons/22x22/psppire-keypad.png \ + glade/icons/16x16/psppire-selector.png + libglade_psppire_la_CFLAGS = $(GLADE_UI_CFLAGS) $(GLADE_CFLAGS) \ - -I src/ui/gui + -I src/ui/gui -DDEBUGGING diff --git a/glade/dialog.c b/glade/dialog.c index ab38c706..ac6f2a22 100644 --- a/glade/dialog.c +++ b/glade/dialog.c @@ -4,6 +4,7 @@ #include "psppire-dialog.h" #include +#include void GLADEGTK_API @@ -26,7 +27,7 @@ glade_psppire_dialog_post_create (GladeWidgetAdaptor *adaptor, if (reason == GLADE_CREATE_USER) { - /* HIG complient border-width defaults on dialogs */ + /* HIG compliant border-width defaults on dialogs */ glade_widget_property_set (widget, "border-width", 5); } @@ -44,17 +45,12 @@ glade_psppire_dialog_post_create (GladeWidgetAdaptor *adaptor, if (reason == GLADE_CREATE_USER) { - /* HIG complient spacing defaults on dialogs */ + /* HIG compliant spacing defaults on dialogs */ glade_widget_property_set (box_widget, "spacing", 2); glade_widget_property_set (box_widget, "size", 2); } - - - /* set a reasonable default size for a dialog */ - gtk_window_set_default_size (GTK_WINDOW (dialog), 320, 260); - } @@ -86,6 +82,8 @@ glade_psppire_dialog_set_property (GladeWidgetAdaptor *adaptor, id); #endif + assert ( GWA_GET_CLASS (GTK_TYPE_WINDOW)->set_property ); + GWA_GET_CLASS (GTK_TYPE_WINDOW)->set_property (adaptor, object, id, value); } diff --git a/glade/icons/16x16/psppire-buttonbox.png b/glade/icons/16x16/psppire-buttonbox.png new file mode 100644 index 0000000000000000000000000000000000000000..d37d4df5fd9a40f399524adcf978b8c9b53343c3 GIT binary patch literal 124 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`&YmugAr_~TQw}g5I(+!DgoH$z z)6SRL;p^rcb>QOQ=l{>o{P5w!|Ai})lNJbUcrekszoVm}x-szr)3J*Y61}aCg4_&G X=2#`i3g-#|jbre1^>bP0l+XkK@X9HS literal 0 HcmV?d00001 diff --git a/glade/icons/16x16/psppire-dialog.png b/glade/icons/16x16/psppire-dialog.png new file mode 100644 index 0000000000000000000000000000000000000000..0d5cf63b6a2b8a290826bb49d5f61f7c45312e9d GIT binary patch literal 212 zcmV;_04x8AP)K z5$E#tF*}RIm{k>QZ2s6=aq#p1_xF$&X6`+3!FWb1hv`c}K|zU$#|_>vJkGF^^F6-! hWrc|>|LGDQhV}VD;p&>&9YBK_JYD@<);T3K0RTapCy@XE literal 0 HcmV?d00001 diff --git a/glade/icons/22x22/psppire-dialog.png b/glade/icons/22x22/psppire-dialog.png new file mode 100644 index 0000000000000000000000000000000000000000..575ebf5daa3dc72a527dfce4d21d082a9bf4a3ad GIT binary patch literal 283 zcmV+$0p$LPP)#1Z^AK2d?}oBXqpDr+672T3C=kHe1%zPY;28MFMrT1%cdY} zEwt7jG2Z5NUFU5GA!PEkZ96+}PQ_VXP!xr?%#lP&38j=5vr5c4pOxdYG)*@#<7&E6 huzTRubc;1@cmb*>Q=8g}K#>3d002ovPDHLkV1iaJY`Opd literal 0 HcmV?d00001 diff --git a/glade/icons/22x22/psppire-keypad.png b/glade/icons/22x22/psppire-keypad.png new file mode 100644 index 0000000000000000000000000000000000000000..be61044bf907410584ce50df3d6238e156ba50ca GIT binary patch literal 120 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1|*Mc$*~4f_MR?|Ar_~TdHDJLlM@nVoOFnt za85u@?w`E)0++tdMz@433Ad!rNB~9VtEu&?Z4YdApL{!GmBfoDZj(=mFsR=75m}#Q Rkq9)3!PC{xWt~$(699;UCNcm3 literal 0 HcmV?d00001 diff --git a/glade/icons/22x22/psppire-selector.png b/glade/icons/22x22/psppire-selector.png new file mode 100644 index 0000000000000000000000000000000000000000..ea1330960d1ba1428cb619a7ecff876aaaf22119 GIT binary patch literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1|*Mc$*~4fzMd|QAr`0KPTI-KV8Frbe57yQ zL`~1xY7YfVV%#5YW?5s(lgFUJaQ4|t^?m7r3&jezDCm3>TXHn);5#e3^yX_?JEA1S i-0%0UZaw_r8N*8{8UC=vVUj?D89ZJ6T-G@yGywn<%PfTe literal 0 HcmV?d00001 diff --git a/glade/psppire.xml b/glade/psppire.xml index da6f0137..45902b56 100644 --- a/glade/psppire.xml +++ b/glade/psppire.xml @@ -1,69 +1,150 @@ + - my_catalog_init - - - glade_psppire_dialog_post_create - glade_psppire_dialog_get_internal_child + + + glade_psppire_dialog_post_create + glade_psppire_dialog_get_internal_child + + glade_psppire_dialog_get_children + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - glade_psppire_dialog_get_children + - glade_psppire_dialog_set_property + - - - - + glade_psppire_button_box_post_create + glade_psppire_button_box_get_children - + glade_psppire_button_box_get_internal_child - + + + + + + + + + + - + - glade_psppire_button_box_post_create - glade_psppire_button_box_get_children - glade_psppire_button_box_get_internal_child - glade_psppire_button_box_set_property + - - - - - - - + + + + + + + - + - glade_psppire_selector_post_create - glade_psppire_selector_get_children + glade_psppire_selector_post_create + glade_psppire_selector_get_children glade_psppire_selector_get_internal_child - glade_psppire_selector_set_property + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + - + diff --git a/po/de.po b/po/de.po index 0ac19a43..f894269d 100644 --- a/po/de.po +++ b/po/de.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.4.2\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2007-03-25 18:00+0800\n" +"POT-Creation-Date: 2007-03-26 18:17+0800\n" "PO-Revision-Date: 2006-05-26 17:49+0800\n" "Last-Translator: John Darrington \n" "Language-Team: German \n" @@ -4134,105 +4134,105 @@ msgstr "" msgid "Style of bevel around the custom entry button" msgstr "" -#: src/ui/gui/data-editor.c:160 +#: src/ui/gui/data-editor.c:159 #, fuzzy msgid "Weights" msgstr "Rechts" -#: src/ui/gui/data-editor.c:161 +#: src/ui/gui/data-editor.c:160 msgid "Weight cases by variable" msgstr "" -#: src/ui/gui/data-editor.c:170 src/ui/gui/data-editor.glade:294 +#: src/ui/gui/data-editor.c:169 src/ui/gui/data-editor.glade:294 msgid "Transpose" msgstr "" -#: src/ui/gui/data-editor.c:171 +#: src/ui/gui/data-editor.c:170 msgid "Transpose the cases with the variables" msgstr "" -#: src/ui/gui/data-editor.c:495 +#: src/ui/gui/data-editor.c:494 msgid "Font Selection" msgstr "Schriftwahlung" -#: src/ui/gui/data-editor.c:673 +#: src/ui/gui/data-editor.c:672 msgid "No Split" msgstr "" -#: src/ui/gui/data-editor.c:681 +#: src/ui/gui/data-editor.c:680 #, fuzzy msgid "Split by " msgstr "Alle Datei" -#: src/ui/gui/data-editor.c:706 +#: src/ui/gui/data-editor.c:705 msgid "Filter off" msgstr "" -#: src/ui/gui/data-editor.c:719 +#: src/ui/gui/data-editor.c:718 #, c-format msgid "Filter by %s" msgstr "" -#: src/ui/gui/data-editor.c:737 +#: src/ui/gui/data-editor.c:736 msgid "Weights off" msgstr "" -#: src/ui/gui/data-editor.c:750 +#: src/ui/gui/data-editor.c:749 #, c-format msgid "Weight by %s" msgstr "" -#: src/ui/gui/data-editor.c:773 src/ui/gui/data-editor.c:984 +#: src/ui/gui/data-editor.c:772 src/ui/gui/data-editor.c:983 #: src/ui/gui/data-editor.glade:414 msgid "Open" msgstr "Öffen" -#: src/ui/gui/data-editor.c:774 +#: src/ui/gui/data-editor.c:773 msgid "Open a data file" msgstr "" -#: src/ui/gui/data-editor.c:782 src/ui/gui/data-editor.c:889 +#: src/ui/gui/data-editor.c:781 src/ui/gui/data-editor.c:888 #: src/ui/gui/data-editor.glade:424 msgid "Save" msgstr "Speichen" -#: src/ui/gui/data-editor.c:783 src/ui/gui/data-editor.c:793 +#: src/ui/gui/data-editor.c:782 src/ui/gui/data-editor.c:792 #, fuzzy msgid "Save data to file" msgstr "Speichern unter" -#: src/ui/gui/data-editor.c:792 +#: src/ui/gui/data-editor.c:791 #, fuzzy msgid "Save As" msgstr "Speichern unter" -#: src/ui/gui/data-editor.c:801 +#: src/ui/gui/data-editor.c:800 msgid "New" msgstr "" -#: src/ui/gui/data-editor.c:802 +#: src/ui/gui/data-editor.c:801 msgid "New data file" msgstr "" -#: src/ui/gui/data-editor.c:897 src/ui/gui/data-editor.c:992 +#: src/ui/gui/data-editor.c:896 src/ui/gui/data-editor.c:991 msgid "System Files (*.sav)" msgstr "Systemedatein (*.sav)" -#: src/ui/gui/data-editor.c:903 src/ui/gui/data-editor.c:998 +#: src/ui/gui/data-editor.c:902 src/ui/gui/data-editor.c:997 msgid "Portable Files (*.por) " msgstr "Tragbardatein (*.por)" -#: src/ui/gui/data-editor.c:909 src/ui/gui/data-editor.c:1004 -#: src/ui/gui/syntax-editor.c:141 src/ui/gui/syntax-editor.c:525 +#: src/ui/gui/data-editor.c:908 src/ui/gui/data-editor.c:1003 +#: src/ui/gui/syntax-editor.c:141 src/ui/gui/syntax-editor.c:524 msgid "All Files" msgstr "Alle Datei" -#: src/ui/gui/data-editor.c:917 +#: src/ui/gui/data-editor.c:916 #, fuzzy msgid "System File" msgstr "Systemedatein (*.sav)" -#: src/ui/gui/data-editor.c:922 +#: src/ui/gui/data-editor.c:921 #, fuzzy msgid "Portable File" msgstr "Tragbardatein (*.por)" @@ -4537,7 +4537,7 @@ msgid "Sort Order" msgstr "" #: src/ui/gui/dict-display.c:92 src/ui/gui/sort-cases-dialog.c:339 -#: src/ui/gui/transpose-dialog.c:124 +#: src/ui/gui/transpose-dialog.c:123 msgid "Var" msgstr "" @@ -4677,12 +4677,12 @@ msgstr "" msgid "Save Syntax" msgstr "Speichern unter" -#: src/ui/gui/syntax-editor.c:135 src/ui/gui/syntax-editor.c:519 +#: src/ui/gui/syntax-editor.c:135 src/ui/gui/syntax-editor.c:518 #, fuzzy msgid "Syntax Files (*.sps) " msgstr "Systemedatein (*.sav)" -#: src/ui/gui/syntax-editor.c:511 +#: src/ui/gui/syntax-editor.c:510 msgid "Open Syntax" msgstr "" @@ -4759,22 +4759,22 @@ msgstr "Ordinalwert" msgid "Scale" msgstr "Skalwert" -#: src/ui/gui/window-manager.c:139 +#: src/ui/gui/window-manager.c:141 #, fuzzy, c-format msgid "Syntax%d" msgstr "Speichern unter" -#: src/ui/gui/window-manager.c:140 src/ui/gui/window-manager.c:171 +#: src/ui/gui/window-manager.c:142 src/ui/gui/window-manager.c:173 #, fuzzy, c-format msgid "%s --- PSPP Syntax Editor" msgstr "PSPP Dateiaufbereiter" -#: src/ui/gui/window-manager.c:143 +#: src/ui/gui/window-manager.c:145 #, fuzzy, c-format msgid "Untitled%d" msgstr "Unbetitelt" -#: src/ui/gui/window-manager.c:144 src/ui/gui/window-manager.c:174 +#: src/ui/gui/window-manager.c:146 src/ui/gui/window-manager.c:176 #, fuzzy, c-format msgid "%s --- PSPP Data Editor" msgstr "PSPP Dateiaufbereiter" diff --git a/po/pspp.pot b/po/pspp.pot index e51a7d0c..81f892fe 100644 --- a/po/pspp.pot +++ b/po/pspp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2007-03-25 18:00+0800\n" +"POT-Creation-Date: 2007-03-26 18:17+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -4128,100 +4128,100 @@ msgstr "" msgid "Style of bevel around the custom entry button" msgstr "" -#: src/ui/gui/data-editor.c:160 +#: src/ui/gui/data-editor.c:159 msgid "Weights" msgstr "" -#: src/ui/gui/data-editor.c:161 +#: src/ui/gui/data-editor.c:160 msgid "Weight cases by variable" msgstr "" -#: src/ui/gui/data-editor.c:170 src/ui/gui/data-editor.glade:294 +#: src/ui/gui/data-editor.c:169 src/ui/gui/data-editor.glade:294 msgid "Transpose" msgstr "" -#: src/ui/gui/data-editor.c:171 +#: src/ui/gui/data-editor.c:170 msgid "Transpose the cases with the variables" msgstr "" -#: src/ui/gui/data-editor.c:495 +#: src/ui/gui/data-editor.c:494 msgid "Font Selection" msgstr "" -#: src/ui/gui/data-editor.c:673 +#: src/ui/gui/data-editor.c:672 msgid "No Split" msgstr "" -#: src/ui/gui/data-editor.c:681 +#: src/ui/gui/data-editor.c:680 msgid "Split by " msgstr "" -#: src/ui/gui/data-editor.c:706 +#: src/ui/gui/data-editor.c:705 msgid "Filter off" msgstr "" -#: src/ui/gui/data-editor.c:719 +#: src/ui/gui/data-editor.c:718 #, c-format msgid "Filter by %s" msgstr "" -#: src/ui/gui/data-editor.c:737 +#: src/ui/gui/data-editor.c:736 msgid "Weights off" msgstr "" -#: src/ui/gui/data-editor.c:750 +#: src/ui/gui/data-editor.c:749 #, c-format msgid "Weight by %s" msgstr "" -#: src/ui/gui/data-editor.c:773 src/ui/gui/data-editor.c:984 +#: src/ui/gui/data-editor.c:772 src/ui/gui/data-editor.c:983 #: src/ui/gui/data-editor.glade:414 msgid "Open" msgstr "" -#: src/ui/gui/data-editor.c:774 +#: src/ui/gui/data-editor.c:773 msgid "Open a data file" msgstr "" -#: src/ui/gui/data-editor.c:782 src/ui/gui/data-editor.c:889 +#: src/ui/gui/data-editor.c:781 src/ui/gui/data-editor.c:888 #: src/ui/gui/data-editor.glade:424 msgid "Save" msgstr "" -#: src/ui/gui/data-editor.c:783 src/ui/gui/data-editor.c:793 +#: src/ui/gui/data-editor.c:782 src/ui/gui/data-editor.c:792 msgid "Save data to file" msgstr "" -#: src/ui/gui/data-editor.c:792 +#: src/ui/gui/data-editor.c:791 msgid "Save As" msgstr "" -#: src/ui/gui/data-editor.c:801 +#: src/ui/gui/data-editor.c:800 msgid "New" msgstr "" -#: src/ui/gui/data-editor.c:802 +#: src/ui/gui/data-editor.c:801 msgid "New data file" msgstr "" -#: src/ui/gui/data-editor.c:897 src/ui/gui/data-editor.c:992 +#: src/ui/gui/data-editor.c:896 src/ui/gui/data-editor.c:991 msgid "System Files (*.sav)" msgstr "" -#: src/ui/gui/data-editor.c:903 src/ui/gui/data-editor.c:998 +#: src/ui/gui/data-editor.c:902 src/ui/gui/data-editor.c:997 msgid "Portable Files (*.por) " msgstr "" -#: src/ui/gui/data-editor.c:909 src/ui/gui/data-editor.c:1004 -#: src/ui/gui/syntax-editor.c:141 src/ui/gui/syntax-editor.c:525 +#: src/ui/gui/data-editor.c:908 src/ui/gui/data-editor.c:1003 +#: src/ui/gui/syntax-editor.c:141 src/ui/gui/syntax-editor.c:524 msgid "All Files" msgstr "" -#: src/ui/gui/data-editor.c:917 +#: src/ui/gui/data-editor.c:916 msgid "System File" msgstr "" -#: src/ui/gui/data-editor.c:922 +#: src/ui/gui/data-editor.c:921 msgid "Portable File" msgstr "" @@ -4515,7 +4515,7 @@ msgid "Sort Order" msgstr "" #: src/ui/gui/dict-display.c:92 src/ui/gui/sort-cases-dialog.c:339 -#: src/ui/gui/transpose-dialog.c:124 +#: src/ui/gui/transpose-dialog.c:123 msgid "Var" msgstr "" @@ -4649,11 +4649,11 @@ msgstr "" msgid "Save Syntax" msgstr "" -#: src/ui/gui/syntax-editor.c:135 src/ui/gui/syntax-editor.c:519 +#: src/ui/gui/syntax-editor.c:135 src/ui/gui/syntax-editor.c:518 msgid "Syntax Files (*.sps) " msgstr "" -#: src/ui/gui/syntax-editor.c:511 +#: src/ui/gui/syntax-editor.c:510 msgid "Open Syntax" msgstr "" @@ -4729,22 +4729,22 @@ msgstr "" msgid "Scale" msgstr "" -#: src/ui/gui/window-manager.c:139 +#: src/ui/gui/window-manager.c:141 #, c-format msgid "Syntax%d" msgstr "" -#: src/ui/gui/window-manager.c:140 src/ui/gui/window-manager.c:171 +#: src/ui/gui/window-manager.c:142 src/ui/gui/window-manager.c:173 #, c-format msgid "%s --- PSPP Syntax Editor" msgstr "" -#: src/ui/gui/window-manager.c:143 +#: src/ui/gui/window-manager.c:145 #, c-format msgid "Untitled%d" msgstr "" -#: src/ui/gui/window-manager.c:144 src/ui/gui/window-manager.c:174 +#: src/ui/gui/window-manager.c:146 src/ui/gui/window-manager.c:176 #, c-format msgid "%s --- PSPP Data Editor" msgstr "" diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index 9a4a95ce..03d6a8ee 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,20 @@ +2007-03-31 John Darrington + + * data-editor.c: Added hooks for the split-file-dialog + + * psppire.glade: Added the split file dialog box. + + * split-file-dialog.c split-file-dialog.h: New files. + + * dialog-common.c dialog-common.h: New files containing functions + which seem to be used a lot in dialog box implementations. + + * psppire-keypad.c psppire-keypad.h: New files. Implements keypad + thingumy widget. + + * psppire-selector.c: Made the orientation of the arrow a property + of the widget, so that it can be selected from glade. + 2007-03-18 Ben Pfaff * syntax-editor-source.c (close): Rename do_close to avoid naming diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 3777672a..18ba45a0 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -70,6 +70,8 @@ src_ui_gui_psppire_SOURCES = \ src/ui/gui/data-sheet.h \ src/ui/gui/data-editor.c \ src/ui/gui/data-editor.h \ + src/ui/gui/dialog-common.c \ + src/ui/gui/dialog-common.h \ src/ui/gui/dict-display.c \ src/ui/gui/dict-display.h \ src/ui/gui/flexifile-factory.h \ @@ -81,22 +83,26 @@ src_ui_gui_psppire_SOURCES = \ src/ui/gui/helper.h \ src/ui/gui/missing-val-dialog.c \ src/ui/gui/missing-val-dialog.h \ + src/ui/gui/psppire-buttonbox.c \ + src/ui/gui/psppire-buttonbox.h \ src/ui/gui/psppire-case-file.c \ src/ui/gui/psppire-case-file.h \ src/ui/gui/psppire-data-store.c \ src/ui/gui/psppire-data-store.h \ - src/ui/gui/psppire-dict.c \ - src/ui/gui/psppire-dict.h \ src/ui/gui/psppire-dialog.c \ src/ui/gui/psppire-dialog.h \ - src/ui/gui/psppire-buttonbox.c \ - src/ui/gui/psppire-buttonbox.h \ + src/ui/gui/psppire-dict.c \ + src/ui/gui/psppire-dict.h \ + src/ui/gui/psppire-keypad.c \ + src/ui/gui/psppire-keypad.h \ src/ui/gui/psppire-selector.c \ src/ui/gui/psppire-selector.h \ src/ui/gui/psppire-var-store.c \ src/ui/gui/psppire-var-store.h \ src/ui/gui/sort-cases-dialog.c \ src/ui/gui/sort-cases-dialog.h \ + src/ui/gui/split-file-dialog.c \ + src/ui/gui/split-file-dialog.h \ src/ui/gui/syntax-editor.c \ src/ui/gui/syntax-editor.h \ src/ui/gui/syntax-editor-source.c \ diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c index c46cfa7a..d0433c64 100644 --- a/src/ui/gui/data-editor.c +++ b/src/ui/gui/data-editor.c @@ -32,6 +32,7 @@ #include "psppire-dialog.h" #include "psppire-selector.h" #include "weight-cases-dialog.h" +#include "split-file-dialog.h" #include "transpose-dialog.h" #include "dict-display.h" @@ -175,6 +176,18 @@ new_data_editor (void) G_CALLBACK (transpose_dialog), de); + + de->invoke_split_file_dialog = + gtk_action_new ("split-file-dialog", + _("Split"), + _("Split the active file"), + "pspp-split-file"); + + + g_signal_connect (de->invoke_split_file_dialog, "activate", + G_CALLBACK (split_file_dialog), de); + + e->window = GTK_WINDOW (get_widget_assert (de->xml, "data_editor")); g_signal_connect_swapped (get_widget_assert (de->xml,"file_new_data"), @@ -227,6 +240,11 @@ new_data_editor (void) get_widget_assert (de->xml, "data_transpose") ); + gtk_action_connect_proxy (de->invoke_split_file_dialog, + get_widget_assert (de->xml, "data_split-file") + ); + + g_signal_connect (get_widget_assert (de->xml,"help_about"), "activate", G_CALLBACK (about_new), @@ -317,6 +335,10 @@ new_data_editor (void) get_widget_assert (de->xml, "button-weight-cases") ); + gtk_action_connect_proxy (de->invoke_split_file_dialog, + get_widget_assert (de->xml, "button-split-file") + ); + g_signal_connect (get_widget_assert (de->xml, "file_quit"), "activate", G_CALLBACK (file_quit), de); diff --git a/src/ui/gui/data-editor.glade b/src/ui/gui/data-editor.glade index ffca7012..2d06312a 100644 --- a/src/ui/gui/data-editor.glade +++ b/src/ui/gui/data-editor.glade @@ -326,9 +326,8 @@ - + True - False Split File True @@ -567,7 +566,6 @@ True - False Split File True pspp-split-file diff --git a/src/ui/gui/data-editor.h b/src/ui/gui/data-editor.h index 7100e34e..e16e713b 100644 --- a/src/ui/gui/data-editor.h +++ b/src/ui/gui/data-editor.h @@ -36,6 +36,7 @@ struct data_editor GtkAction *invoke_weight_cases_dialog; GtkAction *invoke_transpose_dialog; + GtkAction *invoke_split_file_dialog; GladeXML *xml; diff --git a/src/ui/gui/dialog-common.c b/src/ui/gui/dialog-common.c new file mode 100644 index 00000000..42e2fbd4 --- /dev/null +++ b/src/ui/gui/dialog-common.c @@ -0,0 +1,138 @@ +/* + PSPPIRE --- A Graphical User Interface for PSPP + Copyright (C) 2007 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#include +#include "dialog-common.h" + +gint +append_variable_names (GString *string, + PsppireDict *dict, GtkTreeView *treeview) +{ + gint n_vars = 0; + GtkTreeIter iter; + + GtkTreeModel *list_store = + gtk_tree_view_get_model (treeview); + + if ( gtk_tree_model_get_iter_first (list_store, &iter) ) + { + do + { + GValue value = {0}; + struct variable *var; + GtkTreePath *path = gtk_tree_model_get_path (list_store, &iter); + + gtk_tree_model_get_value (list_store, &iter, 0, &value); + + var = psppire_dict_get_variable (dict, g_value_get_int (&value)); + g_value_unset (&value); + + g_string_append (string, " "); + g_string_append (string, var_get_name (var)); + + gtk_tree_path_free (path); + n_vars++; + } + while (gtk_tree_model_iter_next (list_store, &iter)); + } + + return n_vars; +} + + + +struct variable * +get_selected_variable (GtkTreeModel *treemodel, + GtkTreeIter *iter, + PsppireDict *dict) +{ + struct variable *var; + GValue value = {0}; + + GtkTreePath *path = gtk_tree_model_get_path (treemodel, iter); + + gtk_tree_model_get_value (treemodel, iter, 0, &value); + + gtk_tree_path_free (path); + + var = psppire_dict_get_variable (dict, g_value_get_int (&value)); + + g_value_unset (&value); + + return var; +} + + + + +/* A (*GtkTreeCellDataFunc) function. + This function expects TREEMODEL to hold G_TYPE_INT. The ints it holds + are the indices of the variables in the dictionary, which DATA points to. + It renders the name of the variable into CELL. +*/ +void +cell_var_name (GtkTreeViewColumn *tree_column, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data) +{ + PsppireDict *dict = data; + struct variable *var; + gchar *name; + + var = get_selected_variable (tree_model, iter, dict); + + name = pspp_locale_to_utf8 (var_get_name (var), -1, NULL); + g_object_set (cell, "text", name, NULL); + g_free (name); +} + + + +/* Set a model for DEST, which is an GtkListStore of g_int's + whose values are the indices into DICT */ +void +set_dest_model (GtkTreeView *dest, PsppireDict *dict) +{ + GtkTreeViewColumn *col; + GtkListStore *dest_list = gtk_list_store_new (1, G_TYPE_INT); + GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); + + gtk_tree_view_set_model (GTK_TREE_VIEW (dest), GTK_TREE_MODEL (dest_list)); + + col = gtk_tree_view_column_new_with_attributes ("Var", + renderer, + "text", + 0, + NULL); + + gtk_tree_view_column_set_cell_data_func (col, renderer, + cell_var_name, + dict, 0); + + /* FIXME: make this a value in terms of character widths */ + g_object_set (col, "min-width", 100, NULL); + + gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED); + + gtk_tree_view_append_column (GTK_TREE_VIEW(dest), col); +} + diff --git a/src/ui/gui/dialog-common.h b/src/ui/gui/dialog-common.h new file mode 100644 index 00000000..d6ee950b --- /dev/null +++ b/src/ui/gui/dialog-common.h @@ -0,0 +1,62 @@ +/* + PSPPIRE --- A Graphical User Interface for PSPP + Copyright (C) 2007 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +/* Some common routines used in the implementation of dialog boxes */ + + +#ifndef DIALOG_COMMON_H +#define DIALOG_COMMON_H + +#include +#include "psppire-dict.h" + +/* Append the names of selected variables to STRING. + TREEVIEW is the treeview containing the variables. + DICT is the dictionary for those variables. +*/ +gint append_variable_names (GString *, PsppireDict *, GtkTreeView *); + + +/* Returns the variable currently selected by the iterator + pointing to TREEMODEL */ +struct variable * get_selected_variable (GtkTreeModel *treemodel, + GtkTreeIter *iter, + PsppireDict *dict); + + + +/* A (*GtkTreeCellDataFunc) function. + This function expects TREEMODEL to hold G_TYPE_INT. The ints it holds + are the indices of the variables in the dictionary, which DATA points to. + It renders the name of the variable into CELL. +*/ +void cell_var_name (GtkTreeViewColumn *tree_column, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data); + + +/* Set a model for DEST, which is an GtkListStore of g_int's + whose values are the indices into DICT */ +void set_dest_model (GtkTreeView *dest, PsppireDict *dict); + + +#endif diff --git a/src/ui/gui/psppire-keypad.c b/src/ui/gui/psppire-keypad.c new file mode 100644 index 00000000..af0e5924 --- /dev/null +++ b/src/ui/gui/psppire-keypad.c @@ -0,0 +1,454 @@ +/* PSPP - computes sample statistics. + Copyright (C) 2007 Free Software Foundation, Inc. + + 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 the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include +#include +#include +#include +#include +#include "psppire-keypad.h" + +enum { + INSERT_SYNTAX, + n_SIGNALS +}; + +static void psppire_keypad_class_init (PsppireKeypadClass *klass); +static void psppire_keypad_init (PsppireKeypad *kp); + +static guint keypad_signals[n_SIGNALS] = { 0 }; + +GType +psppire_keypad_get_type (void) +{ + static GType kp_type = 0; + + if (!kp_type) + { + static const GTypeInfo kp_info = + { + sizeof (PsppireKeypadClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) psppire_keypad_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (PsppireKeypad), + 0, + (GInstanceInitFunc) psppire_keypad_init, + }; + + kp_type = g_type_register_static (GTK_TYPE_EVENT_BOX, "PsppireKeypad", + &kp_info, 0); + } + + return kp_type; +} + +static GObjectClass * parent_class = NULL; + +static void +psppire_keypad_dispose (GObject *obj) +{ + PsppireKeypad *kp = (PsppireKeypad *)obj; + + if (kp->dispose_has_run) + return; + + /* Make sure dispose does not run twice. */ + kp->dispose_has_run = TRUE; + + g_hash_table_unref (kp->frag_table); + + /* Chain up to the parent class */ + G_OBJECT_CLASS (parent_class)->dispose (obj); +} + +static void +psppire_keypad_finalize (GObject *obj) +{ + /* Chain up to the parent class */ + G_OBJECT_CLASS (parent_class)->finalize (obj); +} + +static void +psppire_keypad_class_init (PsppireKeypadClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + gobject_class->dispose = psppire_keypad_dispose; + gobject_class->finalize = psppire_keypad_finalize; + + keypad_signals[INSERT_SYNTAX] = g_signal_new ("insert-syntax", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (PsppireKeypadClass, + keypad), + NULL, + NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); +} + + +/* + These are the strings that will be arguments to + the emitted signals. + The order of these must correspond + to the order of the button declarations +*/ +static const char *keypad_insert_text[] = { + "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", + ".", "+", "-", "*", "**", "/", "=", "<>", "<", "<=", + ">", ">=", "&", "|", "~", "(", ")" +}; + + +/* Callback for any button click. + Emits the "insert-syntax" signal for the keypad, + with the string corresponding to the clicked button. +*/ +static void +button_click (GtkButton *b, PsppireKeypad *kp) +{ + const gchar *s = g_hash_table_lookup (kp->frag_table, b); + + g_signal_emit (kp, keypad_signals [INSERT_SYNTAX], 0, s); +} + +static const gint cols = 6; +static const gint rows = 5; + + + +/* Add BUTTON to KP. The top-left corner at X1,Y1, the + botton-right corner at X2,Y2 */ +static void +add_button (PsppireKeypad *kp, GtkWidget **button, + gint x1, gint x2, + gint y1, gint y2) +{ + g_object_set (G_OBJECT (*button), "focus-on-click", FALSE, NULL); + + gtk_table_attach_defaults (GTK_TABLE (kp->table), + *button, + x1, x2, + y1, y2); + + gtk_widget_set_size_request (*button, + 30 * rows / (float) cols, + 30 * cols / (float) rows); + + g_hash_table_insert (kp->frag_table, *button, + (void *) keypad_insert_text[(button - &kp->digit[0])] ); + + g_signal_connect (*button, "clicked", + G_CALLBACK (button_click), kp); + + gtk_widget_show (*button); +} + + +/* Return a new button with CODE as the unicode character for its label */ +static inline GtkWidget * +button_new_from_unicode (gunichar code) +{ + char s[6] = {0,0,0,0,0,0}; + + g_unichar_to_utf8 (code, s); + + return gtk_button_new_with_label (s); +} + + +/* Callback which occurs when the mouse enters the widget. + It sets or unsets the focus. +*/ +static gboolean +enter_leave_notify (GtkWidget *widget, + GdkEventCrossing *event, + gpointer user_data) +{ + /* Do nothing if we're just moving between the widget and + its children */ + if (event->detail == GDK_NOTIFY_INFERIOR) + return FALSE; + + if (event->type == GDK_ENTER_NOTIFY) + gtk_widget_grab_focus (widget); + + if (event->type == GDK_LEAVE_NOTIFY) + GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); + + return FALSE; +} + +static gboolean +key_release_callback (GtkWidget *widget, + GdkEventKey *event, + gpointer user_data) +{ + if ( ! (GTK_WIDGET_FLAGS (widget) & GTK_HAS_FOCUS) ) + return FALSE; + + switch (event->keyval) + { + case '(': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "("); + break; + case ')': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, ")"); + break; + case '>': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, ">"); + break; + case '<': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "<"); + break; + case GDK_KP_Equal : + case '=': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "="); + break; + case GDK_KP_Multiply : + case '*': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "*"); + break; + case GDK_KP_Add : + case '+': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "+"); + break; + case GDK_KP_Subtract : + case '-': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "-"); + break; + case GDK_KP_Decimal : + case '.': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "."); + break; + case GDK_KP_Divide : + case '/': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "/"); + break; + case GDK_KP_0 : + case '0': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "0"); + break; + case GDK_KP_1 : + case '1': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "1"); + break; + case GDK_KP_2 : + case '2': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "2"); + break; + case GDK_KP_3 : + case '3': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "3"); + break; + case GDK_KP_4 : + case '4': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "4"); + break; + case GDK_KP_5 : + case '5': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "5"); + break; + case GDK_KP_6 : + case '6': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "6"); + break; + case GDK_KP_7 : + case '7': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "7"); + break; + case GDK_KP_8 : + case '8': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "8"); + break; + case GDK_KP_9 : + case '9': + g_signal_emit (widget, keypad_signals [INSERT_SYNTAX], 0, "9"); + break; + default: + break; + }; + + return FALSE; +} + + +static void +psppire_keypad_init (PsppireKeypad *kp) +{ + gint i; + const int digit_voffset = 0; + const int digit_hoffset = 3; + + GTK_WIDGET_SET_FLAGS (kp, GTK_CAN_FOCUS); + GTK_WIDGET_UNSET_FLAGS (kp, GTK_HAS_FOCUS); + + kp->dispose_has_run = FALSE; + + g_signal_connect (kp, "enter-notify-event", G_CALLBACK (enter_leave_notify), + NULL); + + g_signal_connect (kp, "leave-notify-event", G_CALLBACK (enter_leave_notify), + NULL); + + g_signal_connect (kp, "key-release-event", G_CALLBACK (key_release_callback), + NULL); + + kp->frag_table = g_hash_table_new (g_direct_hash, g_direct_equal); + + kp->table = gtk_table_new (rows, cols, TRUE); + + /* Buttons for the digits */ + for (i = 0; i < 10; i++) + { + int j = i - 1; + char buf[5]; + snprintf (buf, 5, "%d", i); + kp->digit[i] = gtk_button_new_with_label (buf); + + if ( i == 0 ) + add_button (kp, &kp->digit[i], + digit_hoffset + 0, digit_hoffset + 2, + digit_voffset + 3, digit_voffset + 4); + else + add_button (kp, &kp->digit[i], + digit_hoffset + j % 3, digit_hoffset + j % 3 + 1, + digit_voffset + 2 - (j / 3), + digit_voffset + 2 - (j / 3) + 1); + } + + /* ... all the other buttons */ + + kp->dot = button_new_from_unicode (0xB7); /* MIDDLE DOT */ + add_button (kp, &kp->dot, digit_hoffset + 2, + digit_hoffset + 3, + digit_voffset + 3, + digit_voffset + 4); + + kp->plus = gtk_button_new_with_label ("+"); + add_button (kp, &kp->plus, 0, 1, + 0,1); + + kp->minus = button_new_from_unicode (0x2212); /* MINUS SIGN */ + add_button (kp, &kp->minus, 0, 1, + 1,2); + + kp->star = button_new_from_unicode (0xD7); /* MULTIPLICATION SIGN */ + add_button (kp, &kp->star, 0, 1, + 2,3); + + kp->slash = button_new_from_unicode (0xF7); /* DIVISION SIGN */ + add_button (kp, &kp->slash, 0, 1, + 3,4); + + { + GtkWidget *label; + char *markup = + g_markup_printf_escaped ("xy"); + + label = gtk_label_new ("**"); + gtk_label_set_markup (GTK_LABEL (label), markup); + g_free (markup); + + kp->star_star = gtk_button_new (); + gtk_container_add (GTK_CONTAINER (kp->star_star), label); + + add_button (kp, &kp->star_star, + 0, 1, + 4, 5); + } + + + kp->gt = button_new_from_unicode (0x3E); /* GREATER-THAN SIGN*/ + add_button (kp, &kp->gt, 2, 3, + 0,1); + + kp->lt = button_new_from_unicode (0x3C); /* LESS-THAN SIGN*/ + add_button (kp, &kp->lt, 1, 2, + 0,1); + + kp->ge = button_new_from_unicode (0x2265); /* GREATER-THAN OR EQUAL */ + add_button (kp, &kp->ge, 2, 3, + 1,2); + + kp->le = button_new_from_unicode (0x2264); /* LESS-THAN OR EQUAL */ + add_button (kp, &kp->le, 1, 2, + 1,2); + + kp->neq = button_new_from_unicode (0x2260); /* NOT EQUAL */ + add_button (kp, &kp->neq, 2, 3, + 2,3); + + kp->eq = gtk_button_new_with_label ("="); + add_button (kp, &kp->eq, 1, 2, + 2,3); + + kp->parentheses = gtk_button_new_with_label ("()"); + add_button (kp, &kp->parentheses, 2, 3, + 4,5); + + + kp->delete = gtk_button_new_with_label ("Delete"); + add_button (kp, &kp->delete, 3, 6, + 4,5); + + + + kp->and = button_new_from_unicode (0x2227); /* LOGICAL AND */ + add_button (kp, &kp->and, 1, 2, + 3,4); + + + kp->or = button_new_from_unicode (0x2228); /* LOGICAL OR */ + add_button (kp, &kp->or, 2, 3, + 3,4); + + + kp->not = button_new_from_unicode (0xAC); /* NOT SIGN */ + add_button (kp, &kp->not, 1, 2, + 4,5); + + + + g_object_set (G_OBJECT (kp->table), "row-spacing", 5, NULL); + g_object_set (G_OBJECT (kp->table), "column-spacing", 5, NULL); + + gtk_container_add (GTK_CONTAINER (kp), kp->table); + gtk_widget_show (kp->table); + + gtk_widget_add_events (GTK_WIDGET (kp), + GDK_KEY_RELEASE_MASK | + GDK_LEAVE_NOTIFY_MASK | + GDK_ENTER_NOTIFY_MASK | + GDK_FOCUS_CHANGE_MASK); + +} + + +GtkWidget* +psppire_keypad_new (void) +{ + return GTK_WIDGET (g_object_new (psppire_keypad_get_type (), NULL)); +} diff --git a/src/ui/gui/psppire-keypad.h b/src/ui/gui/psppire-keypad.h new file mode 100644 index 00000000..340696c6 --- /dev/null +++ b/src/ui/gui/psppire-keypad.h @@ -0,0 +1,117 @@ +/* PSPP - computes sample statistics. + Copyright (C) 2007 Free Software Foundation, Inc. + + 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 the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* + This module implements a keypad widget, similar to that dipicted + below: + + +---+---+---+---+---+ + | | + | + < 7 8 9 | + + + + | | + | - > 4 5 6 | + + + + | | + | * <= 1 2 3 | + + + + | | + | / >= 0 . | + + + + | y != = ( ) | + |x | + +---+---+---+---+---+ + + It's intended for dialog boxes which produce PSPP syntax. Thus, + a "insert-syntax" signal is emitted whenever a key is clicked. + The signal supports the following callback: + + void insert_syntax (Keypad *kp, const char *syntax, gpointer user_data); + +*/ + +#ifndef __PSPPIRE_KEYPAD_H__ +#define __PSPPIRE_KEYPAD_H__ + + +#include +#include +#include + + +G_BEGIN_DECLS + +#define PSPPIRE_KEYPAD_TYPE (psppire_keypad_get_type ()) +#define PSPPIRE_KEYPAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PSPPIRE_KEYPAD_TYPE, Psppire_Keypad)) +#define PSPPIRE_KEYPAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PSPPIRE_KEYPAD_TYPE, Psppire_KeypadClass)) +#define PSPPIRE_IS_KEYPAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_KEYPAD_TYPE)) +#define PSPPIRE_IS_KEYPAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_KEYPAD_TYPE)) + + +typedef struct _PsppireKeypad PsppireKeypad; +typedef struct _PsppireKeypadClass PsppireKeypadClass; + +/* All members are private. */ +struct _PsppireKeypad +{ + GtkEventBox parent; + + /* Hash of syntax fragments indexed by pointer to widget (button) */ + GHashTable *frag_table; + GtkWidget *table; + + /* The order of everything here is important */ + GtkWidget *digit[10]; + GtkWidget *dot; + GtkWidget *plus; + GtkWidget *minus; + GtkWidget *star; + GtkWidget *star_star; + GtkWidget *slash; + GtkWidget *eq; + GtkWidget *neq; + GtkWidget *lt; + GtkWidget *le; + GtkWidget *gt; + GtkWidget *ge; + GtkWidget *and; + GtkWidget *or; + GtkWidget *not; + + + GtkWidget *parentheses; + GtkWidget *delete; + + + gboolean dispose_has_run; +}; + + +struct _PsppireKeypadClass +{ + GtkTableClass parent_class; + void (*keypad)(PsppireKeypad*); +}; + + +GType psppire_keypad_get_type (void); +GtkWidget* psppire_keypad_new (void); + +G_END_DECLS + +#endif /* __PSPPIRE_KEYPAD_H__ */ diff --git a/src/ui/gui/psppire-selector.c b/src/ui/gui/psppire-selector.c index 453fee8c..68d8270d 100644 --- a/src/ui/gui/psppire-selector.c +++ b/src/ui/gui/psppire-selector.c @@ -75,6 +75,10 @@ static void psppire_selector_base_init (PsppireSelectorClass *class); static void psppire_selector_class_init (PsppireSelectorClass *class); static void psppire_selector_init (PsppireSelector *selector); + +static void set_direction (PsppireSelector *, enum psppire_selector_dir); + + enum {SELECTED, /* Emitted when an item is inserted into dest */ DE_SELECTED, /* Emitted when an item is removed from dest */ n_SIGNALS}; @@ -116,11 +120,76 @@ psppire_selector_finalize (GObject *object) { } +/* Properties */ +enum +{ + PROP_0, + PROP_ORIENTATION +}; + + +static void +psppire_selector_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + PsppireSelector *selector = PSPPIRE_SELECTOR (object); + + switch (prop_id) + { + case PROP_ORIENTATION: + selector->orientation = g_value_get_enum (value); + set_direction (selector, selector->direction); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + }; +} + + +static void +psppire_selector_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + PsppireSelector *selector = PSPPIRE_SELECTOR (object); + + switch (prop_id) + { + case PROP_ORIENTATION: + g_value_set_enum (value, selector->orientation); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + }; +} + static void psppire_selector_class_init (PsppireSelectorClass *class) { + GObjectClass *object_class = G_OBJECT_CLASS (class); + GParamSpec *orientation_spec = + g_param_spec_enum ("orientation", + "Orientation", + "Where the selector is relative to its subjects", + G_TYPE_PSPPIRE_SELECTOR_ORIENTATION, + PSPPIRE_SELECT_SOURCE_BEFORE_DEST /* default value */, + G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE); + + + object_class->set_property = psppire_selector_set_property; + object_class->get_property = psppire_selector_get_property; + + g_object_class_install_property (object_class, + PROP_ORIENTATION, + orientation_spec); + signals [SELECTED] = g_signal_new ("selected", G_TYPE_FROM_CLASS (class), @@ -140,8 +209,6 @@ psppire_selector_class_init (PsppireSelectorClass *class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - } @@ -196,9 +263,48 @@ set_direction (PsppireSelector *selector, enum psppire_selector_dir d) /* FIXME: Need to reverse the arrow direction if an RTL locale is in effect */ if ( d == PSPPIRE_SELECTOR_SOURCE_TO_DEST ) - g_object_set (selector->arrow, "arrow-type", GTK_ARROW_RIGHT, NULL); + { + switch (selector->orientation) + { + case PSPPIRE_SELECT_SOURCE_BEFORE_DEST: + g_object_set (selector->arrow, "arrow-type", GTK_ARROW_RIGHT, NULL); + break; + case PSPPIRE_SELECT_SOURCE_AFTER_DEST: + g_object_set (selector->arrow, "arrow-type", GTK_ARROW_LEFT, NULL); + break; + case PSPPIRE_SELECT_SOURCE_ABOVE_DEST: + g_object_set (selector->arrow, "arrow-type", GTK_ARROW_DOWN, NULL); + break; + case PSPPIRE_SELECT_SOURCE_BELOW_DEST: + g_object_set (selector->arrow, "arrow-type", GTK_ARROW_UP, NULL); + break; + default: + g_assert_not_reached (); + break; + }; + } else - g_object_set (selector->arrow, "arrow-type", GTK_ARROW_LEFT, NULL); + { + switch (selector->orientation) + { + case PSPPIRE_SELECT_SOURCE_BEFORE_DEST: + g_object_set (selector->arrow, "arrow-type", GTK_ARROW_LEFT, NULL); + break; + case PSPPIRE_SELECT_SOURCE_AFTER_DEST: + g_object_set (selector->arrow, "arrow-type", GTK_ARROW_RIGHT, NULL); + break; + case PSPPIRE_SELECT_SOURCE_ABOVE_DEST: + g_object_set (selector->arrow, "arrow-type", GTK_ARROW_UP, NULL); + break; + case PSPPIRE_SELECT_SOURCE_BELOW_DEST: + g_object_set (selector->arrow, "arrow-type", GTK_ARROW_DOWN, NULL); + break; + default: + g_assert_not_reached (); + break; + }; + + } } /* Callback for when the source selection changes */ @@ -597,3 +703,22 @@ psppire_selector_set_subjects (PsppireSelector *selector, selector->select_items = select_func; } + + + +GType +psppire_selector_orientation_get_type (void) +{ + static GType etype = 0; + if (etype == 0) { + static const GEnumValue values[] = { + { PSPPIRE_SELECT_SOURCE_BEFORE_DEST, "PSPPIRE_SELECT_SOURCE_BEFORE_DEST", "source before destination" }, + { PSPPIRE_SELECT_SOURCE_AFTER_DEST, "PSPPIRE_SELECT_SOURCE_AFTER_DEST", "source after destination" }, + { PSPPIRE_SELECT_SOURCE_ABOVE_DEST, "PSPPIRE_SELECT_SOURCE_ABOVE_DEST", "source above destination" }, + { PSPPIRE_SELECT_SOURCE_BELOW_DEST, "PSPPIRE_SELECT_SOURCE_BELOW_DEST", "source below destination" }, + { 0, NULL, NULL } + }; + etype = g_enum_register_static (g_intern_static_string ("PsppireSelectorOrientation"), values); + } + return etype; +} diff --git a/src/ui/gui/psppire-selector.h b/src/ui/gui/psppire-selector.h index 7ba88a96..07213910 100644 --- a/src/ui/gui/psppire-selector.h +++ b/src/ui/gui/psppire-selector.h @@ -80,6 +80,8 @@ struct _PsppireSelector GtkWidget *dest; + gint orientation; + GtkTreeModelFilter *filtered_source; SelectItemsFunc *select_items; @@ -102,6 +104,22 @@ void psppire_selector_set_subjects (PsppireSelector *, GtkWidget *, SelectItemsFunc *, FilterItemsFunc * ); + +GType psppire_selector_orientation_get_type (void) G_GNUC_CONST; + + +typedef enum { + PSPPIRE_SELECT_SOURCE_BEFORE_DEST, + PSPPIRE_SELECT_SOURCE_AFTER_DEST, + PSPPIRE_SELECT_SOURCE_ABOVE_DEST, + PSPPIRE_SELECT_SOURCE_BELOW_DEST +} PsppireSelectorOrientation; + +#define G_TYPE_PSPPIRE_SELECTOR_ORIENTATION \ + (psppire_selector_orientation_get_type()) + + + G_END_DECLS #endif /* __PSPPIRE_SELECTOR_H__ */ diff --git a/src/ui/gui/psppire.glade b/src/ui/gui/psppire.glade index 0a4e6dfa..356d02ff 100644 --- a/src/ui/gui/psppire.glade +++ b/src/ui/gui/psppire.glade @@ -4,6 +4,8 @@ + True + GDK_WINDOW_TYPE_HINT_NORMAL PSPPire Free Software Foundation This is pre-alpha software. Use at your own risk. @@ -43,10 +45,8 @@ - 5 - Weight Case - 363 - 188 + Weight Cases + True True @@ -84,8 +84,7 @@ True 5 - + True Do not weight cases False @@ -202,10 +201,7 @@ - 5 - Transpose - 407 - 225 + True True @@ -370,4 +366,747 @@ + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Split File + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + GTK_SHADOW_IN + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + True + False + + + + + + + + label_item + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_BUTTONBOX_SPREAD + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Analyse all cases. Do not create groups. + True + True + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Compare groups. + True + split-radiobutton0 + + + 1 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Organise output by groups. + True + split-radiobutton0 + + + 2 + + + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0.5 + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + + + False + False + 18 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Groups based on: + + + False + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + 0 + GTK_SHADOW_IN + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + True + False + + + + + + + + label_item + + + + + 1 + + + + + 1 + + + + + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + GTK_BUTTONBOX_SPREAD + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Sort the file by grouping variables. + True + True + True + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + File is already sorted. + True + True + split-radiobutton3 + + + 1 + + + + + False + False + 2 + + + + + 5 + 1 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + False + False + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 1 + Current Status : + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Analysis by groups is off + + + 1 + + + + + False + False + 2 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + False + False + GTK_PACK_END + 1 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + GTK_SHADOW_IN + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + True + + + + + + + + label_item + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_BUTTONBOX_SPREAD + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + All Cases + True + True + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True + radiobutton1 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + If condition is satisfied + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + 0 + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + If... + + + + + + + False + False + 1 + + + + + + + 1 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True + radiobutton1 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Random Sample of cases + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Sample... + + + False + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Approximately 23% of cases + True + + + 1 + + + + + 1 + + + + + + + 2 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True + radiobutton1 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Based on time or case range + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Range... + + + False + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 thru 3 + + + 1 + + + + + 1 + + + + + + + 3 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True + radiobutton1 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Use filter variable + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + True + True + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + + + + + 1 + + + + + + + 4 + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Select + True + + + label_item + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_BUTTONBOX_SPREAD + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Filtered + True + True + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Deleted + True + True + radiobutton5 + + + 1 + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Unselected Cases Are + True + + + label_item + + + + + 1 + + + + + 1 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 1 + Curent Status : + + + False + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Do not filter cases + + + GTK_PACK_END + 1 + + + + + False + False + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_BUTTONBOX_SPREAD + + + + + + + + + + + + + + + + + + 2 + + + + + diff --git a/src/ui/gui/split-file-dialog.c b/src/ui/gui/split-file-dialog.c new file mode 100644 index 00000000..35aaf701 --- /dev/null +++ b/src/ui/gui/split-file-dialog.c @@ -0,0 +1,201 @@ +/* + PSPPIRE --- A Graphical User Interface for PSPP + Copyright (C) 2007 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include + +#include "split-file-dialog.h" +#include "psppire-selector.h" +#include "psppire-dialog.h" +#include "helper.h" +#include "data-editor.h" +#include "dict-display.h" +#include +#include "syntax-editor.h" + +#include +#include + + +#include "dialog-common.h" + +/* FIXME: These shouldn't be here */ +#include +#include "psppire-var-store.h" + + + +static gchar * +generate_syntax (GladeXML *xml, PsppireDict *dict) +{ + gchar *text; + GtkWidget *off = get_widget_assert (xml, "split-radiobutton0"); + + GtkWidget *vars = + get_widget_assert (xml, "split-file-grouping-vars"); + + GString *string = g_string_new ("SPLIT FILE OFF."); + + if ( ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (off))) + { + GString * varlist = g_string_sized_new (80); + GtkWidget *sort = get_widget_assert (xml, "split-radiobutton3"); + GtkWidget *layered = get_widget_assert (xml, "split-radiobutton1"); + gint n_vars = append_variable_names (varlist, + dict, GTK_TREE_VIEW (vars)); + + if ( n_vars > 0 ) + { + g_string_assign (string, ""); + + if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(sort))) + { + g_string_append (string, "SORT CASES BY"); + g_string_append (string, varlist->str); + g_string_append (string, ".\n"); + } + + g_string_append (string, "SPLIT FILE "); + + if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (layered))) + g_string_append (string, "LAYERED "); + else + g_string_append (string, "SEPARATE "); + + g_string_append (string, "BY "); + g_string_append (string, varlist->str); + g_string_append (string, "."); + } + g_string_free (varlist, TRUE); + } + + text = string->str; + + g_string_free (string, FALSE); + + return text; +}; + + +static void +on_off_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + GladeXML *xml = user_data; + GtkWidget *dest = get_widget_assert (xml, "split-file-grouping-vars"); + GtkWidget *selector = get_widget_assert (xml, "split-file-selector"); + GtkWidget *source = get_widget_assert (xml, "split-file-dict-treeview"); + GtkWidget *button3 = get_widget_assert (xml, "split-radiobutton3"); + GtkWidget *button4 = get_widget_assert (xml, "split-radiobutton4"); + + gboolean state = !gtk_toggle_button_get_active (togglebutton); + + gtk_widget_set_sensitive (dest, state); + gtk_widget_set_sensitive (selector, state); + gtk_widget_set_sensitive (source, state); + gtk_widget_set_sensitive (button3, state); + gtk_widget_set_sensitive (button4, state); +} + +static void +refresh (GladeXML *xml) +{ + GtkWidget *off = get_widget_assert (xml, "split-radiobutton0"); + + g_print ("%s\n", __FUNCTION__); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(off), TRUE); + gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON(off)); +} + + + +/* Pops up the Weight Cases dialog box */ +void +split_file_dialog (GObject *o, gpointer data) +{ + gint response; + struct data_editor *de = data; + PsppireDict *dict; + + GladeXML *xml = XML_NEW ("psppire.glade"); + + GtkWidget *dialog = get_widget_assert (xml, "split-file-dialog"); + GtkWidget *source = get_widget_assert (xml, "split-file-dict-treeview"); + GtkWidget *dest = get_widget_assert (xml, "split-file-grouping-vars"); + GtkWidget *selector = get_widget_assert (xml, "split-file-selector"); + GtkWidget *on_off = get_widget_assert (xml, "split-radiobutton0"); + + GtkSheet *var_sheet = + GTK_SHEET (get_widget_assert (de->xml, "variable_sheet")); + + PsppireVarStore *vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet)); + + dict = vs->dict; + + attach_dictionary_to_treeview (GTK_TREE_VIEW (source), + vs->dict, + GTK_SELECTION_MULTIPLE, NULL); + + + g_signal_connect (on_off, "toggled", G_CALLBACK(on_off_toggled), xml); + + + set_dest_model (GTK_TREE_VIEW (dest), vs->dict); + + psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector), + source, + dest, + insert_source_row_into_tree_view, + NULL); + + refresh (xml); + + response = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); + + + switch (response) + { + case GTK_RESPONSE_OK: + { + gchar *syntax = generate_syntax (xml, dict); + struct getl_interface *sss = create_syntax_string_source (syntax); + execute_syntax (sss); + + g_free (syntax); + } + break; + case PSPPIRE_RESPONSE_PASTE: + { + gchar *syntax = generate_syntax (xml, dict); + + struct syntax_editor *se = + (struct syntax_editor *) window_create (WINDOW_SYNTAX, NULL); + + gtk_text_buffer_insert_at_cursor (se->buffer, syntax, -1); + + g_free (syntax); + } + break; + default: + break; + } + + g_object_unref (xml); +} + diff --git a/src/ui/gui/split-file-dialog.h b/src/ui/gui/split-file-dialog.h new file mode 100644 index 00000000..72e1a19d --- /dev/null +++ b/src/ui/gui/split-file-dialog.h @@ -0,0 +1,31 @@ +/* + PSPPIRE --- A Graphical User Interface for PSPP + Copyright (C) 2007 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +#ifndef SPLIT_FILE_DIALOG_H +#define SPLIT_FILE_DIALOG_H + +#include +#include + +/* Pops up the Split File dialog box */ +void split_file_dialog (GObject *o, gpointer data); + + +#endif diff --git a/src/ui/gui/transpose-dialog.c b/src/ui/gui/transpose-dialog.c index 4a89ace5..14c1b3a2 100644 --- a/src/ui/gui/transpose-dialog.c +++ b/src/ui/gui/transpose-dialog.c @@ -28,6 +28,8 @@ #include #include "syntax-editor.h" +#include "dialog-common.h" + #include #include @@ -42,52 +44,6 @@ #include "psppire-var-store.h" - -static struct variable * -get_selected_variable (GtkTreeModel *treemodel, - GtkTreeIter *iter, - PsppireDict *dict) -{ - struct variable *var; - GValue value = {0}; - - GtkTreePath *path = gtk_tree_model_get_path (treemodel, iter); - - gtk_tree_model_get_value (treemodel, iter, 0, &value); - - gtk_tree_path_free (path); - - var = psppire_dict_get_variable (dict, g_value_get_int (&value)); - - g_value_unset (&value); - - return var; -} - - -/* A (*GtkTreeCellDataFunc) function. - This function expects TREEMODEL to hold G_TYPE_INT. The ints it holds - are the indices of the variables in the dictionary, which DATA points to. - It renders the name of the variable into CELL. -*/ -static void -cell_var_name (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data) -{ - PsppireDict *dict = data; - struct variable *var; - gchar *name; - - var = get_selected_variable (tree_model, iter, dict); - - name = pspp_locale_to_utf8 (var_get_name (var), -1, NULL); - g_object_set (cell, "text", name, NULL); - g_free (name); -} - static gchar * generate_syntax (PsppireDict *dict, GladeXML *xml); void @@ -113,31 +69,8 @@ transpose_dialog (GObject *o, gpointer data) attach_dictionary_to_treeview (GTK_TREE_VIEW (source), vs->dict, GTK_SELECTION_MULTIPLE, NULL); - { - GtkTreeViewColumn *col; - GtkListStore *dest_list = gtk_list_store_new (1, G_TYPE_INT); - GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - - gtk_tree_view_set_model (GTK_TREE_VIEW (dest), GTK_TREE_MODEL (dest_list)); - - col = gtk_tree_view_column_new_with_attributes (_("Var"), - renderer, - "text", - 0, - NULL); - - gtk_tree_view_column_set_cell_data_func (col, renderer, - cell_var_name, - vs->dict, 0); - - /* FIXME: make this a value in terms of character widths */ - g_object_set (col, "min-width", 100, NULL); - - gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED); - - gtk_tree_view_append_column (GTK_TREE_VIEW(dest), col); - } + set_dest_model (GTK_TREE_VIEW (dest), vs->dict); psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector1), source, dest, @@ -190,7 +123,6 @@ transpose_dialog (GObject *o, gpointer data) static gchar * generate_syntax (PsppireDict *dict, GladeXML *xml) { - GtkTreeIter iter; const gchar *text; GString *string = g_string_new ("FLIP"); gchar *syntax ; @@ -198,29 +130,9 @@ generate_syntax (PsppireDict *dict, GladeXML *xml) GtkWidget *dest = get_widget_assert (xml, "variables-treeview"); GtkWidget *entry = get_widget_assert (xml, "new-name-entry"); - GtkTreeModel *list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (dest)); - - if ( gtk_tree_model_get_iter_first (list_store, &iter) ) - { - g_string_append (string, " /VARIABLES ="); - do - { - GValue value = {0}; - struct variable *var; - GtkTreePath *path = gtk_tree_model_get_path (list_store, &iter); - - gtk_tree_model_get_value (list_store, &iter, 0, &value); + g_string_append (string, " /VARIABLES = "); - var = psppire_dict_get_variable (dict, g_value_get_int (&value)); - g_value_unset (&value); - - g_string_append (string, " "); - g_string_append (string, var_get_name (var)); - - gtk_tree_path_free (path); - } - while (gtk_tree_model_iter_next (list_store, &iter)); - } + append_variable_names (string, dict, GTK_TREE_VIEW (dest)); text = gtk_entry_get_text (GTK_ENTRY (entry)); -- 2.30.2