Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] (PR#13622) Easier city rename
Home

[Freeciv-Dev] (PR#13622) Easier city rename

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13622) Easier city rename
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 6 Aug 2005 10:42:12 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This patch changes the city name label into a frameless entry box, so that
you can click on the city name to rename it - no edit dialog or anything,
just edit it directly in the city dialog.

The 'number of inhabitants' info part was lost. The window title and the
city name then became the same, and looks rather odd. Screenshot attached.
Once we make the city dialog a tab, this concern would go away, though.

I do not miss the number of inhabitants info, either. It was always rather
useless fluff which was of doubtful realism in the default rules and would
be outright wrong in some mods.

I could not find a way to add the info in the entry box only before it is
clicked.

  - Per

PNG image

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.541
diff -u -r1.541 packhand.c
--- client/packhand.c   1 Aug 2005 22:38:23 -0000       1.541
+++ client/packhand.c   6 Aug 2005 17:32:49 -0000
@@ -545,6 +545,7 @@
   /* Update focus unit info label if necessary. */
   if (name_changed && pfocus_unit && pfocus_unit->homecity == pcity->id) {
     update_unit_info_label(pfocus_unit);
+    refresh_city_dialog(pcity);
   }
 
   /* Update the units dialog if necessary. */
Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.139
diff -u -r1.139 citydlg.c
--- client/gui-gtk-2.0/citydlg.c        4 Aug 2005 17:45:24 -0000       1.139
+++ client/gui-gtk-2.0/citydlg.c        6 Aug 2005 17:32:51 -0000
@@ -155,7 +155,6 @@
   struct cma_dialog *cma_editor;
 
   struct {
-    GtkWidget *rename_command;
     GtkWidget *new_citizens_radio[3];
     GtkWidget *disband_on_settler;
     GtkWidget *whichtab_radio[NUM_PAGES];
@@ -165,7 +164,6 @@
   GtkWidget *buy_shell, *sell_shell;
   GtkWidget *change_shell;
   GtkTreeSelection *change_selection;
-  GtkWidget *rename_shell, *rename_input;
 
   GtkWidget *show_units_command;
   GtkWidget *prev_command, *next_command;
@@ -262,10 +260,6 @@
                                 gpointer data);
 
 static void rename_callback(GtkWidget * w, gpointer data);
-static gboolean rename_callback_delete(GtkWidget * widget, GdkEvent * event,
-                                      gpointer data);
-static void rename_callback_no(GtkWidget * w, gpointer data);
-static void rename_callback_yes(GtkWidget * w, gpointer data);
 static void set_cityopt_values(struct city_dialog *pdialog);
 static void cityopt_callback(GtkWidget * w, gpointer data);
 static void misc_whichtab_callback(GtkWidget * w, gpointer data);
@@ -1104,7 +1098,7 @@
     group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
   }
 
-  /* now we go back and fill the hbox rename */
+  /* now we go back and fill the hbox */
   frame = gtk_frame_new(_("City"));
   gtk_table_attach(GTK_TABLE(page), frame, 0, 1, 1, 2,
                   GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 12);
@@ -1112,14 +1106,6 @@
   vbox2 = gtk_vbox_new(TRUE, 0);
   gtk_container_add(GTK_CONTAINER(frame), vbox2);
 
-  button = gtk_button_new_with_mnemonic(_("_Rename..."));
-  pdialog->misc.rename_command = button;
-  gtk_container_add(GTK_CONTAINER(vbox2), button);
-  g_signal_connect(button, "clicked",
-                  G_CALLBACK(rename_callback), pdialog);
-
-  gtk_widget_set_sensitive(button, can_client_issue_orders());
-  
   /* the disband-if-size-1 button */
   button = gtk_check_button_new_with_mnemonic(_(disband_label));
   pdialog->misc.disband_on_settler = button;
@@ -1167,7 +1153,6 @@
   pdialog->change_shell = NULL;
   pdialog->buy_shell = NULL;
   pdialog->sell_shell = NULL;
-  pdialog->rename_shell = NULL;
   pdialog->happiness.map_canvas = NULL;         /* make sure NULL if spy */
   pdialog->happiness.map_canvas_pixmap = NULL;  /* ditto */
   pdialog->map_canvas_store = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8,
@@ -1210,8 +1195,14 @@
 
   vbox = GTK_DIALOG(pdialog->shell)->vbox;
 
-  pdialog->name_label = gtk_label_new(NULL);
+  pdialog->name_label = gtk_entry_new();
+  gtk_entry_set_text(GTK_ENTRY(pdialog->name_label), pcity->name);
+  gtk_entry_set_max_length(GTK_ENTRY(pdialog->name_label), MAX_LEN_NAME);
+  gtk_entry_set_alignment(GTK_ENTRY(pdialog->name_label), 0.5f);
+  gtk_entry_set_has_frame(GTK_ENTRY(pdialog->name_label), FALSE);
   gtk_box_pack_start(GTK_BOX(vbox), pdialog->name_label, FALSE, FALSE, 2);
+  g_signal_connect(pdialog->name_label, "changed",
+                  G_CALLBACK(rename_callback), pdialog);
 
   /**** -Start of Notebook- ****/
 
@@ -1312,9 +1303,12 @@
   char buf[512];
   const gchar *now;
 
-  my_snprintf(buf, sizeof(buf), _("<b>%s</b> - %s citizens"),
+/*
+  my_snprintf(buf, sizeof(buf), _("%s - %s citizens"),
              pdialog->pcity->name,
              population_to_text(city_population(pdialog->pcity)));
+*/
+  sz_strlcpy(buf, pdialog->pcity->name);
 
   if (city_unhappy(pdialog->pcity)) {
     mystrlcat(buf, _(" - DISORDER"), sizeof(buf));
@@ -1324,10 +1318,13 @@
     mystrlcat(buf, _(" - happy"), sizeof(buf));
   }
 
-  now = gtk_label_get_text(GTK_LABEL(pdialog->name_label));
+  now = gtk_window_get_title(GTK_WINDOW(pdialog->shell));
   if (strcmp(now, buf) != 0) {
     gtk_window_set_title(GTK_WINDOW(pdialog->shell), pdialog->pcity->name);
-    gtk_label_set_markup(GTK_LABEL(pdialog->name_label), buf);
+  }
+  now = gtk_entry_get_text(GTK_ENTRY(pdialog->name_label));
+  if (strcmp(now, buf) != 0) {
+    gtk_entry_set_text(GTK_ENTRY(pdialog->name_label), buf);
   }
 }
 
@@ -2565,72 +2562,22 @@
 {
 }
 
-/******* Callbacks for stuff on the Misc. Settings page *********/
 /****************************************************************
 ...
 *****************************************************************/
-static void rename_callback(GtkWidget * w, gpointer data)
+static void rename_callback(GtkWidget *w, gpointer data)
 {
   struct city_dialog *pdialog;
 
   pdialog = (struct city_dialog *) data;
-
-  pdialog->rename_shell = input_dialog_create(GTK_WINDOW(pdialog->shell),
-                                             /*"shellrenamecity" */
-                                             _("Rename City"),
-                                             _
-                                             ("What should we rename the city 
to?"),
-                                             pdialog->pcity->name,
-                                             G_CALLBACK(rename_callback_yes),
-                                             pdialog,
-                                             G_CALLBACK(rename_callback_no),
-                                             pdialog);
-
-  g_signal_connect(pdialog->rename_shell, "delete_event",
-                  G_CALLBACK(rename_callback_delete), data);
-}
-
-/****************************************************************
-...
-*****************************************************************/
-static gboolean rename_callback_delete(GtkWidget * widget, GdkEvent * event,
-                                      gpointer data)
-{
-  struct city_dialog *pdialog = (struct city_dialog *) data;
-  pdialog->rename_shell = NULL;
-  return FALSE;
-}
-
-/****************************************************************
-...
-*****************************************************************/
-static void rename_callback_no(GtkWidget * w, gpointer data)
-{
-  struct city_dialog *pdialog = (struct city_dialog *) data;
-
   if (pdialog) {
-    pdialog->rename_shell = NULL;
+    city_rename(pdialog->pcity, 
+                gtk_entry_get_text(GTK_ENTRY(pdialog->name_label)));
   }
-
-  input_dialog_destroy(w);
 }
 
-/****************************************************************
-...
-*****************************************************************/
-static void rename_callback_yes(GtkWidget * w, gpointer data)
-{
-  struct city_dialog *pdialog = data;
-
-  if (pdialog) {
-    city_rename(pdialog->pcity, input_dialog_get_input(w));
-
-    pdialog->rename_shell = NULL;
-  }
-
-  input_dialog_destroy(w);
-}
 
+/******* Callbacks for stuff on the Misc. Settings page *********/
 /****************************************************************
  Sets which page will be set on reopen of dialog
 *****************************************************************/
@@ -2748,8 +2695,6 @@
     gtk_widget_destroy(pdialog->buy_shell);
   if (pdialog->sell_shell)
     gtk_widget_destroy(pdialog->sell_shell);
-  if (pdialog->rename_shell)
-    gtk_widget_destroy(pdialog->rename_shell);
 
   g_object_unref(pdialog->map_canvas_store);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13622) Easier city rename, Per I. Mathisen <=