gtk port: make keypad allow menu/toolbar accel keys to work too

also: translate some french comments and remove some other
also: silence 2 glade warnings
This commit is contained in:
matusz 2009-03-31 21:40:37 +00:00
parent 7f0616d4ba
commit d1ccf402ad
2 changed files with 769 additions and 768 deletions

View File

@ -312,7 +312,7 @@ ARM7 cpu</property>
<widget class="GtkSpinButton" id="wtools_3_palnum"> <widget class="GtkSpinButton" id="wtools_3_palnum">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="adjustment">0 0 15 1 2 1</property> <property name="adjustment">0 0 15 1 2 0</property>
<property name="climb_rate">1</property> <property name="climb_rate">1</property>
<signal name="value_changed" handler="on_wtools_3_palnum_value_changed"/> <signal name="value_changed" handler="on_wtools_3_palnum_value_changed"/>
</widget> </widget>
@ -471,7 +471,7 @@ ARM7 cpu</property>
<widget class="GtkSpinButton" id="wtools_4_palnum"> <widget class="GtkSpinButton" id="wtools_4_palnum">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="adjustment">0 0 15 1 2 1</property> <property name="adjustment">0 0 15 1 2 0</property>
<property name="climb_rate">1</property> <property name="climb_rate">1</property>
<signal name="value_changed" handler="on_wtools_4_palnum_value_changed"/> <signal name="value_changed" handler="on_wtools_4_palnum_value_changed"/>
</widget> </widget>

View File

@ -453,7 +453,7 @@ static void Open_Select(GtkWidget* widget, gpointer data)
GtkFileFilter *pFilter_nds, *pFilter_dsgba, *pFilter_any; GtkFileFilter *pFilter_nds, *pFilter_dsgba, *pFilter_any;
GtkWidget *pFileSelection; GtkWidget *pFileSelection;
GtkWidget *pParent; GtkWidget *pParent;
gchar *sChemin; gchar *sPath;
if (desmume_running()) if (desmume_running())
Pause(); Pause();
@ -485,24 +485,23 @@ static void Open_Select(GtkWidget* widget, gpointer data)
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_OK, GTK_STOCK_OPEN, GTK_RESPONSE_OK,
NULL); NULL);
/* On limite les actions a cette fenetre */ /* Only the dialog window is accepting events: */
gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsgba); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsgba);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any);
/* Affichage fenetre */ /* Showing the window */
switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) {
case GTK_RESPONSE_OK: case GTK_RESPONSE_OK:
/* Recuperation du chemin */ sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection));
sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); if(Open((const char*)sPath, bad_glob_cflash_disk_image_file) < 0) {
if(Open((const char*)sChemin, bad_glob_cflash_disk_image_file) < 0) {
GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection),
GTK_DIALOG_MODAL, GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK, GTK_BUTTONS_OK,
"Unable to load :\n%s", sChemin); "Unable to load :\n%s", sPath);
gtk_dialog_run(GTK_DIALOG(pDialog)); gtk_dialog_run(GTK_DIALOG(pDialog));
gtk_widget_destroy(pDialog); gtk_widget_destroy(pDialog);
} else { } else {
@ -511,7 +510,7 @@ static void Open_Select(GtkWidget* widget, gpointer data)
//Launch(NULL, pWindow); //Launch(NULL, pWindow);
g_free(sChemin); g_free(sPath);
break; break;
default: default:
break; break;
@ -533,8 +532,6 @@ static void Reset()
pStatusBar_Change("Running ..."); pStatusBar_Change("Running ...");
} }
#ifdef GTKGLEXT_AVAILABLE #ifdef GTKGLEXT_AVAILABLE
static void static void
gtk_init_main_gl_area(GtkWidget *widget, gtk_init_main_gl_area(GtkWidget *widget,
@ -925,15 +922,17 @@ static gboolean Stylus_Move(GtkWidget *w, GdkEventMotion *e, gpointer data)
return TRUE; return TRUE;
} }
static gboolean Stylus_Press(GtkWidget *w, GdkEventButton *e, gpointer data)
static gboolean Stylus_Press(GtkWidget * w, GdkEventButton * e,
gpointer data)
{ {
GdkModifierType state; GdkModifierType state;
gint x,y; gint x, y;
s32 EmuX, EmuY; s32 EmuX, EmuY;
const int *opengl = (const int *)data; const int *opengl = (const int *) data;
if(desmume_running()) { if (desmume_running()) {
if(e->button == 1) { if (e->button == 1) {
int scaled_x, scaled_y; int scaled_x, scaled_y;
click = TRUE; click = TRUE;
@ -942,14 +941,14 @@ static gboolean Stylus_Press(GtkWidget *w, GdkEventButton *e, gpointer data)
scaled_x = x * nds_screen_size_ratio; scaled_x = x * nds_screen_size_ratio;
scaled_y = y * nds_screen_size_ratio; scaled_y = y * nds_screen_size_ratio;
if ( !(*opengl)) { if (!(*opengl)) {
scaled_y -= 192; scaled_y -= 192;
} }
if(scaled_y >= 0 && (state & GDK_BUTTON1_MASK)) { if (scaled_y >= 0 && (state & GDK_BUTTON1_MASK)) {
EmuX = scaled_x; EmuX = scaled_x;
EmuY = scaled_y; EmuY = scaled_y;
if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255; if (EmuX < 0) EmuX = 0; else if (EmuX > 255) EmuX = 255;
if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192; if (EmuY < 0) EmuY = 0; else if (EmuY > 192) EmuY = 192;
NDS_setTouchPos(EmuX, EmuY); NDS_setTouchPos(EmuX, EmuY);
} }
} }
@ -1003,16 +1002,26 @@ static gint Key_Press(GtkWidget *w, GdkEventKey *e, gpointer data)
savegame(e->keyval - GDK_F1 + 1); savegame(e->keyval - GDK_F1 + 1);
return 1; return 1;
} }
// FIXME: this is a hack to allow accels to work together with keypad emulation
// should be fixed by somebody who knows how to make key_press_event trigger AFTER all GtkAccels
guint mask;
mask = GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_MOD5_MASK; // shift,ctrl, both alts
if( (e->state & mask) == 0){
u16 Key = lookup_key(e->keyval); u16 Key = lookup_key(e->keyval);
if(Key){
ADD_KEY( Cur_Keypad, Key ); ADD_KEY( Cur_Keypad, Key );
if(desmume_running()) update_keypad(Cur_Keypad); if(desmume_running()) update_keypad(Cur_Keypad);
return 1;
}
}
#ifdef PROFILE_MEMORY_ACCESS #ifdef PROFILE_MEMORY_ACCESS
if ( e->keyval == GDK_Tab) { if ( e->keyval == GDK_Tab) {
print_memory_profiling(); print_memory_profiling();
return 1;
} }
#endif #endif
return 1; return 0;
} }
static gint Key_Release(GtkWidget *w, GdkEventKey *e, gpointer data) static gint Key_Release(GtkWidget *w, GdkEventKey *e, gpointer data)
@ -1281,7 +1290,7 @@ int SelectFirmwareFile_Load(GtkWidget *w, gpointer data)
GtkFileFilter *pFilter_nds, *pFilter_bin, *pFilter_any; GtkFileFilter *pFilter_nds, *pFilter_bin, *pFilter_any;
GtkWidget *pFileSelection; GtkWidget *pFileSelection;
GtkWidget *pParent; GtkWidget *pParent;
gchar *sChemin; gchar *sPath;
BOOL oldState = desmume_running(); BOOL oldState = desmume_running();
Pause(); Pause();
@ -1300,14 +1309,12 @@ int SelectFirmwareFile_Load(GtkWidget *w, gpointer data)
gtk_file_filter_add_pattern(pFilter_any, "*"); gtk_file_filter_add_pattern(pFilter_any, "*");
gtk_file_filter_set_name(pFilter_any, "All files"); gtk_file_filter_set_name(pFilter_any, "All files");
/* Creation de la fenetre de selection */
pFileSelection = gtk_file_chooser_dialog_new("Load firmware...", pFileSelection = gtk_file_chooser_dialog_new("Load firmware...",
GTK_WINDOW(pParent), GTK_WINDOW(pParent),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_OK, GTK_STOCK_OPEN, GTK_RESPONSE_OK,
NULL); NULL);
/* On limite les actions a cette fenetre */
gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds);
@ -1316,22 +1323,20 @@ int SelectFirmwareFile_Load(GtkWidget *w, gpointer data)
if(FirmwareFile[0]) gtk_file_chooser_select_uri(GTK_FILE_CHOOSER(pFileSelection), FirmwareFile); if(FirmwareFile[0]) gtk_file_chooser_select_uri(GTK_FILE_CHOOSER(pFileSelection), FirmwareFile);
/* Affichage fenetre */
switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) {
case GTK_RESPONSE_OK: case GTK_RESPONSE_OK:
/* Recuperation du chemin */ sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection));
sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); if(LoadFirmware((const char*)sPath) < 0) {
if(LoadFirmware((const char*)sChemin) < 0) { GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Unable to load :\n%s", sPath);
GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Unable to load :\n%s", sChemin);
gtk_dialog_run(GTK_DIALOG(pDialog)); gtk_dialog_run(GTK_DIALOG(pDialog));
gtk_widget_destroy(pDialog); gtk_widget_destroy(pDialog);
} else { } else {
GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Selected firmware :\n%s", sChemin); GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Selected firmware :\n%s", sPath);
gtk_dialog_run(GTK_DIALOG(pDialog)); gtk_dialog_run(GTK_DIALOG(pDialog));
gtk_widget_destroy(pDialog); gtk_widget_destroy(pDialog);
} }
g_free(sChemin); g_free(sPath);
break; break;
default: default:
break; break;
@ -1347,7 +1352,7 @@ int SelectFirmwareFile_Load(GtkWidget *w, gpointer data)
GtkFileFilter *pFilter_nds, *pFilter_bin, *pFilter_any; GtkFileFilter *pFilter_nds, *pFilter_bin, *pFilter_any;
GtkWidget *pFileSelection; GtkWidget *pFileSelection;
GtkWidget *pParent; GtkWidget *pParent;
gchar *sChemin; gchar *sPath;
BOOL oldState = desmume_running(); BOOL oldState = desmume_running();
Pause(); Pause();
@ -1366,14 +1371,12 @@ int SelectFirmwareFile_Load(GtkWidget *w, gpointer data)
gtk_file_filter_add_pattern(pFilter_any, "*"); gtk_file_filter_add_pattern(pFilter_any, "*");
gtk_file_filter_set_name(pFilter_any, "All files"); gtk_file_filter_set_name(pFilter_any, "All files");
/* Creation de la fenetre de selection */
pFileSelection = gtk_file_chooser_dialog_new("Save firmware...", pFileSelection = gtk_file_chooser_dialog_new("Save firmware...",
GTK_WINDOW(pParent), GTK_WINDOW(pParent),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_OK, GTK_STOCK_SAVE, GTK_RESPONSE_OK,
NULL); NULL);
/* On limite les actions a cette fenetre */
gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds);
@ -1382,22 +1385,20 @@ int SelectFirmwareFile_Load(GtkWidget *w, gpointer data)
if(FirmwareFile[0]) gtk_file_chooser_select_uri(GTK_FILE_CHOOSER(pFileSelection), FirmwareFile); if(FirmwareFile[0]) gtk_file_chooser_select_uri(GTK_FILE_CHOOSER(pFileSelection), FirmwareFile);
/* Affichage fenetre */
switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) {
case GTK_RESPONSE_OK: case GTK_RESPONSE_OK:
/* Recuperation du chemin */ sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection));
sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); if(LoadFirmware((const char*)sPath) < 0) {
if(LoadFirmware((const char*)sChemin) < 0) { GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Unable to load :\n%s", sPath);
GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Unable to load :\n%s", sChemin);
gtk_dialog_run(GTK_DIALOG(pDialog)); gtk_dialog_run(GTK_DIALOG(pDialog));
gtk_widget_destroy(pDialog); gtk_widget_destroy(pDialog);
} else { } else {
GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Selected firmware :\n%s", sChemin); GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Selected firmware :\n%s", sPath);
gtk_dialog_run(GTK_DIALOG(pDialog)); gtk_dialog_run(GTK_DIALOG(pDialog));
gtk_widget_destroy(pDialog); gtk_widget_destroy(pDialog);
} }
g_free(sChemin); g_free(sPath);
break; break;
default: default:
break; break;
@ -1899,7 +1900,7 @@ common_gtk_main( struct configured_features *my_config)
config_file = g_build_filename(g_get_home_dir(), ".desmume.ini", NULL); config_file = g_build_filename(g_get_home_dir(), ".desmume.ini", NULL);
Read_ConfigFile(config_file); Read_ConfigFile(config_file);
/* Creation de la fenetre */ /* Create the window */
pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(pWindow), "Desmume"); gtk_window_set_title(GTK_WINDOW(pWindow), "Desmume");
@ -1911,7 +1912,7 @@ common_gtk_main( struct configured_features *my_config)
g_signal_connect(G_OBJECT(pWindow), "key_press_event", G_CALLBACK(Key_Press), NULL); g_signal_connect(G_OBJECT(pWindow), "key_press_event", G_CALLBACK(Key_Press), NULL);
g_signal_connect(G_OBJECT(pWindow), "key_release_event", G_CALLBACK(Key_Release), NULL); g_signal_connect(G_OBJECT(pWindow), "key_release_event", G_CALLBACK(Key_Release), NULL);
/* Creation de la GtkVBox */ /* Create the GtkVBox */
pVBox = gtk_vbox_new(FALSE, 0); pVBox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(pWindow), pVBox); gtk_container_add(GTK_CONTAINER(pWindow), pVBox);
@ -1941,7 +1942,7 @@ common_gtk_main( struct configured_features *my_config)
desmume_gtk_toolbar(pVBox); desmume_gtk_toolbar(pVBox);
/* Création de l'endroit pour l'affichage des écrans */ /* Creating the place for showing DS screens */
#ifdef GTKGLEXT_AVAILABLE #ifdef GTKGLEXT_AVAILABLE
if ( my_config->opengl_2d) { if ( my_config->opengl_2d) {
/* /*
@ -2099,7 +2100,7 @@ common_gtk_main( struct configured_features *my_config)
} }
} }
/* Boucle principale */ /* Main loop */
// gtk_idle_add(&EmuLoop, pWindow); // gtk_idle_add(&EmuLoop, pWindow);
// g_idle_add(&EmuLoop, pWindow); // g_idle_add(&EmuLoop, pWindow);