root.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <gtk/gtk.h>
00033
00034 #include "ergtk-keyb.h"
00035
00036
00037 #include "logging.h"
00038
00039
00040
00041
00042
00043
00044
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
00052
00053 static GtkWidget* g_dialog = NULL ;
00054
00055
00056
00057
00058
00059
00060
00061
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
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
00131
00132
00133
00134
00135
00136
00137
00138
00139
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
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
00179
00180 static gboolean focus_in_callback(void)
00181 {
00182 DBG_ENTRY;
00183 DBG("==========================>>>>>>>>>> FOCUS IN CALLBACK <<<<<<<<<<<<===================== \n");
00184 DBG_EXIT;
00185 return TRUE;
00186 return FALSE;
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;
00195 return FALSE;
00196 }
00197