Started work on the GUI for the wordblox player
[wordblah.git] / wordblox_player.c
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;
+               }
+       } 
+}