Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] (PR#6409) overview goto for gtk2
Home

[Freeciv-Dev] (PR#6409) overview goto for gtk2

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#6409) overview goto for gtk2
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 6 Oct 2003 07:29:05 -0700
Reply-to: rt@xxxxxxxxxxxxxx

This is the gtk code needed for overview-goto (PR#6381).  Something 
similar should work for gtk2.

jason

Index: gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.138
diff -u -r1.138 gui_main.c
--- gui_main.c  2003/07/23 13:46:01     1.138
+++ gui_main.c  2003/10/06 14:27:19
@@ -554,8 +554,9 @@
 
   overview_canvas = gtk_drawing_area_new();
 
-  gtk_widget_set_events(overview_canvas, GDK_EXPOSURE_MASK
-                                      | GDK_BUTTON_PRESS_MASK );
+  gtk_widget_set_events(overview_canvas, (GDK_EXPOSURE_MASK
+                                         | GDK_BUTTON_PRESS_MASK
+                                         | GDK_POINTER_MOTION_MASK));
 
   gtk_drawing_area_size(GTK_DRAWING_AREA(overview_canvas), 160, 100);
   gtk_box_pack_start(GTK_BOX(avbox), overview_canvas, FALSE, FALSE, 0);
@@ -565,6 +566,9 @@
 
   gtk_signal_connect(GTK_OBJECT(overview_canvas), "button_press_event",
                      (GtkSignalFunc) butt_down_overviewcanvas, NULL);
+
+  gtk_signal_connect(GTK_OBJECT(overview_canvas), "motion_notify_event",
+                    GTK_SIGNAL_FUNC(move_overviewcanvas), NULL);
 
   /* The Rest */
 
Index: mapctrl.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapctrl.c,v
retrieving revision 1.89
diff -u -r1.89 mapctrl.c
--- mapctrl.c   2003/09/19 12:39:37     1.89
+++ mapctrl.c   2003/10/06 14:27:19
@@ -234,8 +234,17 @@
   int x, y;
 
   gdk_window_get_pointer(map_canvas->window, &x, &y, 0);
-
-  update_line(x, y);
+  if (x >= 0 && y >= 0
+      && x < mapview_canvas.width && y < mapview_canvas.width) {
+    update_line(x, y);
+  } else {
+    gdk_window_get_pointer(overview_canvas->window, &x, &y, 0);
+    if (x >= 0 && y >= 0
+       && x < OVERVIEW_TILE_WIDTH * map.xsize
+       && y < OVERVIEW_TILE_WIDTH * map.ysize) {
+      overview_update_line(x, y);
+    }
+  }
 }
 
 /**************************************************************************
@@ -244,6 +253,15 @@
 gint move_mapcanvas(GtkWidget *widget, GdkEventButton *event)
 {
   update_line(event->x, event->y);
+  return TRUE;
+}
+
+/**************************************************************************
+  Draw a goto line when the mouse moves over the overview canvas.
+**************************************************************************/
+gint move_overviewcanvas(GtkWidget *widget, GdkEventButton *event)
+{
+  overview_update_line(event->x, event->y);
   return TRUE;
 }
 
Index: mapctrl.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapctrl.h,v
retrieving revision 1.13
diff -u -r1.13 mapctrl.h
--- mapctrl.h   2003/07/02 16:40:18     1.13
+++ mapctrl.h   2003/10/06 14:27:19
@@ -26,6 +26,7 @@
 gint butt_down_wakeup(GtkWidget *w, GdkEventButton *ev);
 gint butt_down_overviewcanvas(GtkWidget *w, GdkEventButton *ev);
 gint move_mapcanvas(GtkWidget *widget, GdkEventButton *event);
+gint move_overviewcanvas(GtkWidget *widget, GdkEventButton *event);
 
 void center_on_unit(void);
 void popupinfo_popdown_callback(GtkWidget *w, gpointer data);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#6409) overview goto for gtk2, Jason Short <=