Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2000:
[Freeciv-Dev] PATCH: Unit City Button (GTK Only)
Home

[Freeciv-Dev] PATCH: Unit City Button (GTK Only)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] PATCH: Unit City Button (GTK Only)
From: Richard Herrell <herrell@xxxxxxxxxxx>
Date: Sat, 07 Oct 2000 20:06:13 -0400
Reply-to: herrell@xxxxxxxxxxx

This small patch converts the city name in the unit info section from a
bit of text into a button.  Players can simply click the button to get
the city screen for the active unit, rather than searching around the
map to find the city.

Regards,

Richard Herrell


-- 
Richard Herrell
http://www.provide.net/~herrell/index.html
e-mail: herrell@xxxxxxxxxxx
--- gui_main.c.orig     Sat Oct  7 19:49:40 2000
+++ gui_main.c  Sat Oct  7 19:33:37 2000
@@ -128,6 +128,7 @@
 gint           gtk_interval_id;
 
 GtkWidget *    unit_info_label, *unit_info_frame;
+GtkWidget *     unit_city_button, *unit_city_frame, *unit_city_label;
 GtkWidget *    text_scrollbar;
 GtkWidget *    inputline;
 
@@ -144,7 +145,7 @@
 
 static gint show_info_popup(GtkWidget *w, GdkEventButton *ev);
 static gint timer_callback(gpointer data);
-
+static void unit_city_callback( GtkWidget *w, gpointer data );
 
 /**************************************************************************
   Print extra usage information, including one line help on each option,
@@ -454,13 +455,24 @@
   { /* selected unit status */
     GtkWidget *ubox;
 
-
     unit_info_frame = gtk_frame_new(NULL);
     gtk_box_pack_start(GTK_BOX(avbox), unit_info_frame, FALSE, FALSE, 0);
-    
-    unit_info_label = gtk_label_new("\n\n\n");
+
+    unit_info_label = gtk_label_new("\n\n");
     gtk_container_add(GTK_CONTAINER(unit_info_frame), unit_info_label);
 
+    unit_city_frame = gtk_frame_new(NULL);
+    gtk_box_pack_start(GTK_BOX(avbox), unit_city_frame, FALSE, FALSE, 0);
+
+    unit_city_label = gtk_label_new( _("") );
+    unit_city_button = gtk_button_new();
+    gtk_signal_connect( GTK_OBJECT(unit_city_button), "clicked",
+                        GTK_SIGNAL_FUNC(unit_city_callback),
+                        NULL );
+    gtk_container_add( GTK_CONTAINER(unit_city_button), 
+                       GTK_WIDGET(unit_city_label) );
+    gtk_container_add(GTK_CONTAINER(unit_city_frame), unit_city_button);
+    
     ubox = gtk_hbox_new(FALSE,0);
     gtk_box_pack_start(GTK_BOX(avbox), ubox, FALSE, FALSE, 0);
 
@@ -920,3 +932,17 @@
     showing = 0;
   }
 }
+
+
+static void unit_city_callback( GtkWidget *w, gpointer data )
+{
+  extern void popup_city_dialog(struct city *pcity, int make_modal);
+  struct unit * punit;
+  if((punit=get_unit_in_focus())) {
+    struct city * pcity;
+    if((pcity=player_find_city_by_id(game.player_ptr, punit->homecity))) {
+      popup_city_dialog( pcity, 0 );
+    }
+  }
+}
+
--- mapview.c.orig      Sat Oct  7 19:49:52 2000
+++ mapview.c   Sat Oct  7 19:34:45 2000
@@ -79,6 +79,7 @@
 extern GtkWidget *     turn_done_button;
 
 extern GtkWidget *     unit_info_frame, *unit_info_label;
+extern GtkWidget *      unit_city_frame, *unit_city_button, *unit_city_label;
 
 extern GtkWidget *     map_canvas;                     /* GtkDrawingArea */
 extern GtkWidget *     overview_canvas;                /* GtkDrawingArea */
@@ -335,13 +336,16 @@
             (punit->veteran) ? _("(veteran)") : "" );
     gtk_frame_set_label( GTK_FRAME(unit_info_frame), buffer);
 
-    my_snprintf(buffer, sizeof(buffer), "%s\n%s\n%s", 
+    my_snprintf(buffer, sizeof(buffer), "%s\n%s", 
             (goto_state==punit->id) ? 
             _("Select destination") : unit_activity_text(punit), 
-            map_get_tile_info_text(punit->x, punit->y),
-            pcity ? pcity->name : "");
+            map_get_tile_info_text(punit->x, punit->y));
     gtk_set_label( unit_info_label, buffer);
 
+    my_snprintf(buffer, sizeof(buffer), "%s", 
+            pcity ? pcity->name : "" );
+    gtk_label_set_text( GTK_LABEL( unit_city_label ), buffer );
+    gtk_widget_show( GTK_WIDGET(unit_city_button) );
     if ((goto_cursor != NULL) && (drop_cursor != NULL)) {
       if (goto_state==punit->id) {
        if (paradrop_state)
@@ -360,6 +364,7 @@
     gtk_frame_set_label( GTK_FRAME(unit_info_frame),"");
     gtk_set_label(unit_info_label,"\n\n");
     gdk_window_set_cursor (root_window, 0);
+    gtk_widget_hide( GTK_WIDGET(unit_city_button) );
   }
   update_unit_pix_label(punit);
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] PATCH: Unit City Button (GTK Only), Richard Herrell <=