Started work on the GUI for the wordblox player
authorHarishankar <v.harishankar@gmail.com>
Sat, 2 May 2020 12:13:30 +0000 (17:43 +0530)
committerHarishankar <v.harishankar@gmail.com>
Sat, 2 May 2020 12:13:30 +0000 (17:43 +0530)
Started work on GTK+ GUI for the wordblox player.

Makefile
constantstrings.h
wordblox.gresource.xml [new file with mode: 0644]
wordblox.svg [new file with mode: 0644]
wordblox_player.c [new file with mode: 0644]

index 90cbb91..23de2da 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,6 @@
 wordblox: wordblox.c wordblox.h constantstrings.h
        clang wordblox.c -lgd -lz -lcrypt -o wordblox
 
+wordblox_player: wordblox_player.c wordblox_resource.c wordblox.gresource.xml wordblox_player.glade constantstrings.h
+               glib-compile-resources wordblox.gresource.xml --target wordblox_resource.c --generate-source
+               clang -rdynamic -o wordblox_player wordblox_player.c -Wall `pkg-config --cflags --libs gtk+-3.0`
index 6b8a0bb..1c0dd49 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __CONSTANTSTRINGS_H
 #define __CONSTANTSTRINGS_H
 
+#define VERSION  "0.1a"
 #define FROZEN_GRID "Grid is frozen. Unfreeze grid first!"
 #define UNFROZEN_GRID "Grid is unfrozen. Freeze grid first!"
 #define EXCEED_GRID_SIZE "Row/col exceeded grid size!"
@@ -38,6 +39,18 @@ and is irreversible (y/N): "
 #define USAGE_LINE_3 "new <nn> - create new puzzle with <nn> grid \
 columns (warning: existing file name may be overwritten)\n"
 
+/* for wordblox_player */
+#define ERROR_ICON "Unable to load icon!"
+#define ERROR_WINDOW "Error loading Window!"
+
+/* about box info */
+const char *AUTHOR[] = { "V. Harishankar", NULL};
+const char *COPYRIGHT = "Copyright 2020 V.Harishankar";
+const char *COMMENTS = "A player for wordblox (crossword puzzles)";
+const char *PROGRAM_NAME = "Wordblox Player";
+const char *WEBSITE = "http://harishankar.org/";
+const char *WEBSITE_LABEL = "Author's HomePage";
+
 char *MAIN_MENU[] = 
                                        {"1. New puzzle",
                                         "2. Open existing puzzle", 
diff --git a/wordblox.gresource.xml b/wordblox.gresource.xml
new file mode 100644 (file)
index 0000000..ae2f5f0
--- /dev/null
@@ -0,0 +1,8 @@
+
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/harishankar/wordblox">
+    <file preprocess="xml-stripblanks">wordblox_player.glade</file>
+    <file>wordblox.svg</file>
+  </gresource>
+</gresources>
diff --git a/wordblox.svg b/wordblox.svg
new file mode 100644 (file)
index 0000000..d7e6745
--- /dev/null
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="64px"
+   height="64px"
+   id="svg2985"
+   version="1.1"
+   inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
+   sodipodi:docname="wordblox.svg"
+   inkscape:export-filename="/home/hari/Projects/GetAClue/resources/getaclue.png"
+   inkscape:export-xdpi="96"
+   inkscape:export-ydpi="96">
+  <defs
+     id="defs2987" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="0.6875"
+     inkscape:cx="373.4413"
+     inkscape:cy="-67.966563"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:document-units="px"
+     inkscape:grid-bbox="true"
+     inkscape:window-width="1366"
+     inkscape:window-height="704"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata2990">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="layer1"
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer">
+    <rect
+       style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.50000000000000000;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
+       id="rect2993"
+       width="60.18182"
+       height="60.363636"
+       x="2.1818182"
+       y="2" />
+    <path
+       style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
+       d="m 22.727273,2.5454545 0,59.6363635"
+       id="path2995"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
+       d="M 42.545455,2.3636367 42.545455,62"
+       id="path2995-2"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
+       d="M 2.5454545,22.363636 62,22.363636"
+       id="path3022"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
+       d="m 3.2727273,42.545455 58.9840237,0"
+       id="path3024"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       d="M 42.909095,11.727272 V 2 h 9.727272 9.727273 v 9.727272 9.727273 h -9.727273 -9.727272 z"
+       id="path3032"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       d="M 3.2727282,11.818181 V 2.5454545 h 9.7272728 9.727272 v 9.2727265 9.272727 H 13.000001 3.2727282 Z"
+       id="path3032-3"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       d="M 3.2727273,51.818181 V 42.545455 H 13 22.727272 v 9.272726 9.272727 H 13 3.2727273 Z"
+       id="path3032-3-7"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       d="M 42.545455,52.727273 V 43.454547 H 52.272728 62 V 52.727273 62 h -9.727272 -9.727273 z"
+       id="path3032-3-5"
+       inkscape:connector-curvature="0" />
+  </g>
+</svg>
diff --git a/wordblox_player.c b/wordblox_player.c
new file mode 100644 (file)
index 0000000..cf9e0bc
--- /dev/null
@@ -0,0 +1,69 @@
+#include <gtk/gtk.h>
+
+#include "constantstrings.h"
+#include "wordblox_resource.c"
+
+/* slot for exit menu */
+void on_menu_exit_activate (GtkMenuItem *item, gpointer data)
+{
+       gtk_main_quit ();
+}
+
+/* slot for about menu */
+void on_menu_about_activate (GtkMenuItem *item, gpointer data)
+{      
+       const char *AUTHOR[] =  {"V.Harishankar", NULL};
+       gtk_show_about_dialog (NULL, "authors",AUTHOR, 
+                                                       "program-name", PROGRAM_NAME,
+                                                       "copyright", COPYRIGHT,
+                                                       "comments", COMMENTS,
+                                                       "website", WEBSITE,
+                                                       "website-label", WEBSITE_LABEL,
+                                                       "license-type", GTK_LICENSE_GPL_2_0,
+                                                       "version", VERSION,
+                                                       (char*)NULL);
+}
+
+int main (int argc, char *argv [])
+{
+       gtk_init (&argc, &argv);
+       GtkBuilder *builder;
+       GtkWindow *window; 
+       GdkPixbuf *icon;
+       
+       icon = gdk_pixbuf_new_from_resource 
+                               ("/org/harishankar/wordblox/wordblox.svg", NULL);
+       if (icon == NULL)
+               fprintf (stderr, ERROR_ICON);
+       
+       builder = gtk_builder_new ();
+       guint ret = gtk_builder_add_from_resource (builder, 
+               "/org/harishankar/wordblox/wordblox_player.glade", NULL);
+       
+       if (ret == 0)
+       {
+               fprintf (stderr, ERROR_WINDOW);
+               g_object_unref (builder);
+               return 1;       
+       }
+       else 
+       {
+               window = GTK_WINDOW (gtk_builder_get_object (builder, "main_window") );
+               if (window != NULL)
+               {
+                       gtk_window_set_default_icon (icon);             
+               
+                       gtk_builder_connect_signals (builder, NULL);
+                       g_object_unref (builder);
+                       gtk_widget_show (GTK_WIDGET(window));
+                       gtk_main ();
+                       return 0;
+               }
+               else
+               {
+                       g_object_unref (builder);
+                       fprintf (stderr, ERROR_WINDOW);
+                       return 1;
+               }
+       } 
+}