<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39927 >

Unfortunately, SDL is using F10 already, and there is a long translation
that describes F1.  So, the only thing open is F4.  So, here's some code
to use F4.

I'm not totally satisfied, as it won't switch from a dialog to the main
window (so I commented that part out for now).

The focus unit still has the circling cursor when the map isn't "in focus"
-- but that's an issue for another report....

Changed the tag and menu item to View to avoid shortcut conflicts.  It
makes some sense, as the _View menu item controls the View tag.

Index: client/gui-gtk-2.0/gui_main.c
===================================================================
--- client/gui-gtk-2.0/gui_main.c       (revision 14163)
+++ client/gui-gtk-2.0/gui_main.c       (working copy)
@@ -385,6 +385,17 @@
 /**************************************************************************
 ...
 **************************************************************************/
+gboolean map_canvas_focus(void)
+{
+  gtk_window_present(GTK_WINDOW(toplevel));
+  gtk_notebook_set_current_page(GTK_NOTEBOOK(top_notebook), 0);
+  gtk_widget_grab_focus(map_canvas);
+  return TRUE;
+}
+
+/**************************************************************************
+...
+**************************************************************************/
 gboolean inputline_handler(GtkWidget *w, GdkEventKey *ev)
 {
   void *data = NULL;
@@ -632,7 +643,8 @@
     return FALSE;
   }
 
-  if ((ev->state & GDK_SHIFT_MASK)) {
+  if ((ev->state & GDK_CONTROL_MASK)) {
+  } else if ((ev->state & GDK_SHIFT_MASK)) {
     switch (ev->keyval) {
 
     case GDK_Return:
@@ -643,6 +655,7 @@
     default:
       break;
     };
+  } else {
   }
 
   switch (ev->keyval) {
@@ -665,6 +678,23 @@
     return keyboard_map_canvas(w, ev, data);
   }
 
+  /* We are focused some other dialog, tab, or widget. */
+  if ((ev->state & GDK_CONTROL_MASK)) {
+  } else if ((ev->state & GDK_SHIFT_MASK)) {
+  } else {
+    switch (ev->keyval) {
+
+#if 0
+    case GDK_F4:
+      map_canvas_focus();
+      return TRUE;
+#endif
+
+    default:
+      break;
+    };
+  }
+
   return FALSE;
 }
 
@@ -1161,7 +1191,7 @@
 
   map_widget = gtk_table_new(2, 2, FALSE);
 
-  label = gtk_label_new_with_mnemonic(_("_Map"));
+  label = gtk_label_new(_("View"));
   gtk_notebook_append_page(GTK_NOTEBOOK(top_notebook), map_widget, label);
 
   frame = gtk_frame_new(NULL);
Index: client/gui-gtk-2.0/gui_main.h
===================================================================
--- client/gui-gtk-2.0/gui_main.h       (revision 14163)
+++ client/gui-gtk-2.0/gui_main.h       (working copy)
@@ -76,6 +76,8 @@
 
 void enable_menus(bool enable);
 
+gboolean map_canvas_focus(void);
+
 gboolean inputline_handler(GtkWidget *w, GdkEventKey *ev);
 
 void reset_unit_table(void);
Index: client/gui-gtk-2.0/menu.c
===================================================================
--- client/gui-gtk-2.0/menu.c   (revision 14163)
+++ client/gui-gtk-2.0/menu.c   (working copy)
@@ -156,6 +156,7 @@
   MENU_REPORT_CITIES,
   MENU_REPORT_UNITS,
   MENU_REPORT_PLAYERS,
+  MENU_REPORT_VIEW,
   MENU_REPORT_ECONOMY,
   MENU_REPORT_SCIENCE,
   MENU_REPORT_WOW,
@@ -573,6 +574,9 @@
   case MENU_REPORT_PLAYERS:
     popup_players_dialog(TRUE);
     break;
+  case MENU_REPORT_VIEW:
+    map_canvas_focus();
+    break;
    case MENU_REPORT_ECONOMY:
     popup_economy_report_dialog(TRUE);
     break;
@@ -946,6 +950,8 @@
        reports_menu_callback,  MENU_REPORT_UNITS                               
        },
   { "/" N_("Reports") "/" N_("_Players"),              "F3",
        reports_menu_callback,  MENU_REPORT_PLAYERS                             
        },
+  { "/" N_("Reports") "/" N_("_View"),                 "F4",
+       reports_menu_callback,  MENU_REPORT_VIEW                                
        },
   { "/" N_("Reports") "/" N_("_Economy"),              "F5",
        reports_menu_callback,  MENU_REPORT_ECONOMY                             
        },
   { "/" N_("Reports") "/" N_("_Science"),              "F6",
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to