root.c

Go to the documentation of this file.
00001 /*
00002  * File Name: root.c
00003  */
00004 
00005 /*
00006  * This file is part of erkeyb.
00007  *
00008  * erkeyb is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * erkeyb is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2009 iRex Technologies B.V.
00024  * All rights reserved.
00025  */
00026 
00027 //----------------------------------------------------------------------------
00028 // Include Files
00029 //----------------------------------------------------------------------------
00030 
00031 // system include files, between < >
00032 #include <gtk/gtk.h>
00033 /* local include files */
00034 #include "ergtk-keyb.h"
00035 
00036 /* logging */
00037 #include "logging.h"
00038 
00039 //----------------------------------------------------------------------------
00040 // Type Declarations
00041 //----------------------------------------------------------------------------
00042 
00043 //----------------------------------------------------------------------------
00044 // Function Prototypes
00045 //----------------------------------------------------------------------------
00046 
00047 static void button_clicked_callback(GtkButton* button, GtkWindow* parent);
00048 static void button_redraw_clicked_callback(GtkButton* button, GtkWindow* parent);
00049 static gboolean  focus_in_callback(void);
00050 static gboolean  focus_out_callback(void);
00051 // static void focus_in_callback(void);
00052 
00053 static GtkWidget* g_dialog = NULL ; 
00054 
00055 //----------------------------------------------------------------------------
00056 // Function Implementations
00057 //----------------------------------------------------------------------------
00058 
00059 
00060 /* this creates a dialog mockup which is used to test and try a couple
00061  * of embedded vs im-context keyboard concepts
00062  */
00063 
00064 int main (int argc, char** argv ) 
00065 {
00066 
00067     GtkWidget* window = NULL;
00068     GtkWidget* button = NULL;
00069     GtkWidget* button_redraw = NULL;
00070     GtkWidget* hbox = NULL ; 
00071 
00072     gtk_init(&argc, &argv);
00073 
00074     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
00075     gtk_window_set_title(GTK_WINDOW(window), "KEYBOARD FIND DIALOG TEST");
00076     gtk_container_set_border_width(GTK_CONTAINER(window), 10);
00077 
00078     button = gtk_button_new_with_mnemonic("_Create Dialog");
00079     button_redraw = gtk_button_new_with_mnemonic("_Redraw Dialog");
00080 
00081 
00082     g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked_callback), (gpointer) window);
00083     g_signal_connect(G_OBJECT(button_redraw), "clicked", G_CALLBACK(button_redraw_clicked_callback), (gpointer) window);
00084 
00085 
00086     hbox = gtk_hbox_new(3, FALSE );
00087 
00088 
00089     g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL );
00090 
00091     gtk_container_add(GTK_CONTAINER(hbox), button);
00092     gtk_container_add(GTK_CONTAINER(hbox), button_redraw);
00093     gtk_container_add(GTK_CONTAINER(window), hbox);
00094 
00095     gtk_widget_show_all(window);
00096 
00097     gtk_main();
00098 
00099 
00100     return 0;
00101 
00102 }
00103 
00104 
00105 /* create a custom dialog */
00106 
00107 static void button_clicked_callback(GtkButton* button, GtkWindow* parent)
00108 {
00109     GtkWidget* dialog;
00110     GtkWidget* dialog_hbox;
00111     GtkWidget* dialog_keyboard;
00112     GtkWidget* dialog_entry;
00113     GtkWidget* dialog_search_button;
00114 
00115     dialog = gtk_dialog_new_with_buttons(
00116             "Destroy?",
00117             parent,
00118             GTK_DIALOG_DESTROY_WITH_PARENT, 
00119             "_Destroy", GTK_RESPONSE_ACCEPT,
00120             "_Abort",   GTK_RESPONSE_REJECT,
00121             NULL);
00122 
00123     g_dialog = GTK_WIDGET(dialog);
00124 
00125     gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_REJECT);
00126 
00127     dialog_hbox = gtk_hbox_new(TRUE,3);
00128     dialog_entry = gtk_entry_new();
00129 
00130     // only supported from gtk+ >= 2.16 
00131     //dialog_entry = GTK_WIDGET( gtk_object_new(GTK_TYPE_ENTRY, 
00132     //            "im-module", "Xander!", 
00133     //            NULL));
00134    
00135 
00136     /* connect own callbacks to focus events */
00137     /* use the TRUE return value to prevent further calling
00138      * of focus-in and focus-out callbacks that are registered
00139      * in the input method context
00140      */
00141     g_signal_connect(G_OBJECT(dialog_entry), "focus-in-event", G_CALLBACK(focus_in_callback), NULL);
00142     g_signal_connect(G_OBJECT(dialog_entry), "focus-out-event", G_CALLBACK(focus_out_callback), NULL);
00143     dialog_search_button = gtk_button_new_with_label("Search");
00144     
00145     gtk_container_add(GTK_CONTAINER(dialog_hbox), dialog_entry);
00146     gtk_widget_show(dialog_entry);
00147     gtk_container_add(GTK_CONTAINER(dialog_hbox), dialog_search_button);
00148     gtk_widget_show(dialog_search_button);
00149 
00150 
00151     gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), dialog_hbox);
00152     gtk_widget_show(dialog_hbox);
00153 
00154     dialog_keyboard = ergtk_keyb_new();
00155 
00156     gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), dialog_keyboard);
00157     gtk_widget_show(dialog_keyboard);
00158     
00159     gtk_widget_show(dialog);
00160     //gtk_widget_show_all(dialog);
00161 }
00162 
00163 
00164 static void button_redraw_clicked_callback(GtkButton* button, GtkWindow* parent)
00165 {
00166     if ( NULL  != g_dialog )
00167     {
00168         gtk_widget_queue_draw(g_dialog);
00169     }
00170     else 
00171     {
00172         return;
00173     }
00174 }
00175 
00176 
00177 /*
00178  * The home grown focus event callbacks
00179  */
00180 static gboolean focus_in_callback(void)
00181 {
00182     DBG_ENTRY;
00183     DBG("==========================>>>>>>>>>> FOCUS IN CALLBACK <<<<<<<<<<<<===================== \n");
00184     DBG_EXIT;
00185     return TRUE; // prevents docked keyboard from showing
00186     return FALSE; // makes docked keyboard show also 
00187 }
00188 
00189 static gboolean focus_out_callback(void)
00190 {
00191     DBG_ENTRY;
00192     DBG("==========================>>>>>>>>>> FOCUS OUT CALLBACK <<<<<<<<<<<<===================== \n");
00193     DBG_EXIT;
00194     return TRUE; // prevents docked keyboard from showing
00195     return FALSE; // makes docked keyboard show also 
00196 }
00197 
Generated by  doxygen 1.6.2-20100208