summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b96b33a)
raw | patch | inline | side by side (parent: b96b33a)
author | Subhajit Paul <subhajit_paul@ti.com> | |
Thu, 18 Oct 2012 18:46:12 +0000 (00:16 +0530) | ||
committer | Subhajit Paul <subhajit_paul@ti.com> | |
Thu, 18 Oct 2012 18:46:12 +0000 (00:16 +0530) |
The common macros for all the GUI widgets is placed in
include/gui-frontend/gui-common.h
This file will be modified when code for other GUI elements
will be added to the tree
The Help window functions are exported in
include/gui-frontend/help-window.h
The Help window exported functions and the static callback
functions for the widgets are defined in
src/gui-frontend/help-window.h
In the Glade generated XML file, pauseImage Widget is added.
include/gui-frontend/gui-common.h
This file will be modified when code for other GUI elements
will be added to the tree
The Help window functions are exported in
include/gui-frontend/help-window.h
The Help window exported functions and the static callback
functions for the widgets are defined in
src/gui-frontend/help-window.h
In the Glade generated XML file, pauseImage Widget is added.
include/gui-frontend/gui-common.h | [new file with mode: 0644] | patch | blob |
include/gui-frontend/help-window.h | [new file with mode: 0644] | patch | blob |
src/gui-frontend/UI_design.glade | patch | blob | history | |
src/gui-frontend/help-window.c | [new file with mode: 0644] | patch | blob |
diff --git a/include/gui-frontend/gui-common.h b/include/gui-frontend/gui-common.h
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2010-2011, Texas Instruments Incorporated
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contact information for paper mail:
+ * Texas Instruments
+ * Post Office Box 655303
+ * Dallas, Texas 75265
+ * Contact information:
+ * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm
+ * ?DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
+ * ============================================================================
+ *
+ */
+
+/**
+ * @file gui-common.h
+ *
+ * @brief Defines utility macros for widget creation.
+ *
+ */
+
+#ifndef __GUI_COMMON_H__
+#define __GUI_COMMON_H__
+
+#include <gtk/gtk.h>
+#include <gui-frontend/help-window.h>
+/*TODO: other files include*/
+
+#define GLADE_FILE "src/gui-frontend/UI_design.glade"
+
+static GError *error = NULL;
+static GtkBuilder *builder = NULL;
+
+/*report and then free the error, if error is not NULL*/
+#define check_error() ({\
+ if(NULL == error){\
+ g_printerr("GError Report : Unknown error\n");\
+ }else{\
+ g_printerr("GError Report : %s\n",error->message);\
+ g_error_free(error);\
+ error = NULL;\
+ }\
+})
+
+/*create and close a static GtkBuilder*/
+#define builder_close() ({\
+ g_object_unref(G_OBJECT(builder));\
+ builder = NULL;\
+})
+#define builder_create() ({\
+ builder = gtk_builder_new();\
+ if(0 == gtk_builder_add_from_file(builder,GLADE_FILE,&error)){\
+ check_error();\
+ builder_close();\
+ }\
+})
+
+/*get a widget from the builder*/
+#define get_widget(widget) ({\
+ GtkWidget *retWidget = NULL;\
+ if(NULL == builder){\
+ retWidget = NULL;\
+ }else{\
+ retWidget = (GtkWidget *)gtk_builder_get_object(builder,#widget);\
+ }\
+ retWidget;\
+})
+
+/* get a widget exclusively from the builder */
+/* this will let the application create two instances */
+/* of a widget defined in the glade file. */
+/* */
+/* For example : this macro can be used like - */
+/* */
+/* widget0 = get_widget_exclusive(applicationWindow) */
+/* widget1 = get_widget_exclusive(applicationWindow) */
+/* */
+/* this will create two different widgets with the same*/
+/* look and feel */
+
+#define get_widget_exclusive(widget) ({\
+ builder_create();\
+ get_widget(widget);\
+ builder_close();\
+})
+
+#endif /*__GUI_COMMON_H__*/
diff --git a/include/gui-frontend/help-window.h b/include/gui-frontend/help-window.h
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2010-2011, Texas Instruments Incorporated
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contact information for paper mail:
+ * Texas Instruments
+ * Post Office Box 655303
+ * Dallas, Texas 75265
+ * Contact information:
+ * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm
+ * ?DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
+ * ============================================================================
+ *
+ */
+
+/**
+ * @file help-window.h
+ *
+ * @brief Defines all the functions exported by the help window
+ *
+ */
+
+#ifndef __HELP_WINDOW_H__
+#define __HELP_WINDOW_H__
+
+#include <gtk/gtk.h>
+
+/*****************************************************************************
+* @brief Show the help window.
+*
+* Called from: application-window.c helpButton clicked signal handler.
+*****************************************************************************/
+void show_help_window();
+
+/*****************************************************************************
+* @brief Hide the help window.
+*
+* Called from: help-window.c closeButton clicked signal handler.
+* help-window.c helpWindow delete-event signal handler.
+*****************************************************************************/
+void hide_help_window();
+
+/*****************************************************************************
+* @brief destroy the help window.
+*
+* Called from: TODO: GUI deinitialize function name
+*****************************************************************************/
+void destroy_help_window();
+
+/*****************************************************************************
+* @brief create the help window.
+*
+* Called from: TODO: GUI initialize function name
+*****************************************************************************/
+gboolean create_help_window_new();
+
+#endif /*__HELP_WINDOW_H__*/
index 11da973c6bd6228fee07673a8652db9dfcce1145..e5fc348fdced6689055d108940f08f0f00a10fd1 100644 (file)
</object>
</child>
</object>
+ <object class="GtkImage" id="pauseImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixbuf">../../icons/pause.png</property>
+ </object>
<object class="GtkImage" id="playImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
diff --git a/src/gui-frontend/help-window.c b/src/gui-frontend/help-window.c
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2010-2011, Texas Instruments Incorporated
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contact information for paper mail:
+ * Texas Instruments
+ * Post Office Box 655303
+ * Dallas, Texas 75265
+ * Contact information:
+ * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm
+ * ?DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
+ * ============================================================================
+ *
+ */
+
+/**
+ * @file help-window.c
+ *
+ * @brief The interface functions to the help window
+ */
+
+#include <gtk/gtk.h>
+#include <gui-frontend/gui-common.h>
+
+static GtkWindow *helpWindow = NULL;
+
+/******************************************************************************
+ * static callback functions
+ ******************************************************************************/
+static gboolean cb_close_button_clicked(GtkWidget *widget, gpointer data){
+ hide_help_window();
+}
+
+static gboolean cb_help_window_closed(GtkWidget *widget, gpointer data){
+ hide_help_window();
+}
+
+/******************************************************************************
+ * See help-window.h
+ ******************************************************************************/
+void show_help_window(){
+ gtk_widget_show_all(GTK_WIDGET(helpWindow));
+}
+
+void hide_help_window(){
+ gtk_widget_hide_all(GTK_WIDGET(helpWindow));
+}
+
+void destroy_help_window(){
+ gtk_widget_destroy(GTK_WIDGET(helpWindow));
+ helpWindow = NULL;
+}
+
+gboolean create_help_window_new(){
+ gboolean ret = TRUE;
+ GtkWidget *closeButton = NULL;
+
+ /*only one instance of help window is allowed*/
+ if(NULL != helpWindow){
+ return ret;
+ }
+
+ /*create the window*/
+ builder_create();
+ helpWindow = GTK_WINDOW(get_widget(helpWindow));
+ if(NULL == helpWindow){
+ check_error();
+ ret = FALSE;
+ goto last;
+ }
+
+ closeButton = get_widget(closeButton);
+ if(NULL == closeButton){
+ check_error();
+ ret = FALSE;
+ goto winDestroy;
+ }
+
+ /*connect the signals*/
+ gtk_signal_connect(GTK_OBJECT(closeButton), "clicked",
+ G_CALLBACK(cb_close_button_clicked), NULL);
+ gtk_signal_connect(GTK_OBJECT(helpWindow), "delete-event",
+ G_CALLBACK(cb_help_window_closed), NULL);
+ ret = TRUE;
+ goto last;
+
+winDestroy:
+ gtk_widget_destroy(GTK_WIDGET(helpWindow));
+last:
+ builder_close();
+ return ret;
+}