Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] [patch] Message windows (report, science ...)
Home

[Freeciv-Dev] [patch] Message windows (report, science ...)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: FreeCiv <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] [patch] Message windows (report, science ...)
From: Francois Taiani <francois.taiani@xxxxxxxx>
Date: Mon, 10 Sep 2001 23:10:37 +0200

Hi everybody,

here is a new version of the patch I proposed 2 days ago. 

---8<---
based on a suggestion by  Trent Piepho, here is a proposal
to prevent "info" windows (like message and science window) from
obscuring the map when you most need to be able to look at it.

The patch sligthly rearranges the gui in order to be able to add "event"
buttons in the righ vertical box. In the present state, there is a
button for messages and for the science dialog. Each time one of these
windows used to pop up before, the corresponding button starts blinking,
and the window does not appear untill you explicitely click the button.
Clicking the button again once the window is up has the window get
hidden again.
--->8---

The new patch adds a button for broadcast reports. I've taken into
account the improvement suggestions of Karl-Ingo Friese and Christian
Knoke. In particular the bugs reported by Christian should have been
fixed. A new snapshot of the gui layout is available at
ftp://ftp.freeciv.org/pub/freeciv/incoming/info_button_2.png.

Francois

-------------
TECHNICAL DETAILS

From a technical point of view, this patch is far less intrusive in the
core client code than the preceding one. It should be easy to add it to
CVS. In particular, it only modifies the gtk client, leaving the core
client code intact, but for a few exceptions. Those few other changes
outside GTK should not interfere with the other clients. In the
gtk-client the modified files are the following:

Makefile.am

dialogs.[c|h]
gui_main.[c|h]
menu.c
messagewin.[c|h]
repodlgs.[c|h]

The added buttons are defined in the gtk-client by the 2 new files:

info_buttons.h
info_buttons.c

For the report button a slight interface modification was necessary in

./client/include/dialogs_g.h

It adds a fourth parameter "is_broadcast" to the function
"popup_notify_dialog":

void popup_notify_dialog(char *caption, 
                         char *headline, 
                         char *lines, 
                         int is_broadcast);

In order for the other clients to compile correctly, I've modified them
accordinly: The new parameter is simply ignored:

./client/gui-mui/dialogs.c
./client/gui-mui/repodlgs.c
./client/gui-stub/dialogs.c
./client/gui-xaw/dialogs.c
./client/gui-xaw/repodlgs.c

Last but not least, a few small modifs in packhand.c were necessay.

The patch works by wrapping the popup_something functions of the
message, report, and science windows. The normal popup functions were
renamed "actually_popup_...". The new wrapped "popup_something" sets the
button to blinking. "actually_popup_something" is called in the
corresponding button call back.
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/Makefile.am 
./client/gui-gtk/Makefile.am
--- ../freeciv-cvs-Sep-09/client/gui-gtk/Makefile.am    Sat Apr  8 12:53:52 2000
+++ ./client/gui-gtk/Makefile.am        Mon Sep 10 21:53:38 2001
@@ -72,5 +72,7 @@
        spaceshipdlg.c  \
        spaceshipdlg.h  \
        wldlg.c         \
-       wldlg.h
+       wldlg.h         \
+       info_buttons.c  \
+       info_buttons.h
 
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/dialogs.c 
./client/gui-gtk/dialogs.c
--- ../freeciv-cvs-Sep-09/client/gui-gtk/dialogs.c      Mon Aug  6 13:58:21 2001
+++ ./client/gui-gtk/dialogs.c  Mon Sep 10 21:53:38 2001
@@ -41,6 +41,7 @@
 #include "control.h"
 #include "gui_main.h"
 #include "gui_stuff.h"
+#include "info_buttons.h"
 #include "mapview.h"
 #include "options.h"
 #include "tilespec.h"
@@ -50,6 +51,7 @@
 /******************************************************************/
 static gint popup_mes_del_callback(GtkWidget *widget, GdkEvent *event,
                                   gpointer data);
+GtkWidget * create_notify_dialog(char *caption, char *headline, char *lines);
 
 /******************************************************************/
 static GtkWidget  *races_dialog_shell=NULL;
@@ -156,11 +158,58 @@
   return FALSE;
 }
 
+static char * static_caption  = NULL ; 
+static char * static_headline = NULL ;
+static char * static_lines    = NULL ;
+
+/****************************************************************
+Does no imnediately popup the notify dialog. Instead the message
+is stored in static variables and the report button is set to
+blinking. Clicking the button will call popup_delayed_notify_dialog()
+which will actually pop up the dialog.
+*****************************************************************/
+void popup_notify_dialog(char *caption, char *headline, char *lines, 
+                         int is_broadcast)
+{
+  if (!is_broadcast)
+    { /* The notify dialog has been called by the user himself
+       * so we don't want to delay it. */
+      actually_popup_notify_dialog(caption,headline,lines);
+      return ;
+    }
+  if (static_caption)  free(static_caption) ;
+  if (static_headline) free(static_headline) ;
+  if (static_lines)    free(static_lines) ;
+  static_caption  = strdup(caption)  ;
+  static_headline = strdup(headline) ;
+  static_lines    = strdup(lines) ;
+  make_info_button_blink  (BUTTON_REPORT);
+}
+
+/****************************************************************
+See popup_notify_dialog(..)
+*****************************************************************/
+void popup_delayed_notify_dialog()
+{
+  actually_popup_notify_dialog(static_caption,static_headline,static_lines) ;
+  stop_info_button_blink(BUTTON_REPORT);
+}
 
 /****************************************************************
 ...
 *****************************************************************/
-void popup_notify_dialog(char *caption, char *headline, char *lines)
+void actually_popup_notify_dialog(char *caption, char *headline, char *lines)
+{
+  GtkWidget *notify_dialog_shell;
+  notify_dialog_shell = create_notify_dialog(caption,headline,lines);
+  gtk_widget_show( notify_dialog_shell );
+  gtk_widget_set_sensitive( top_vbox, FALSE );
+}
+
+/****************************************************************
+...
+*****************************************************************/
+GtkWidget * create_notify_dialog(char *caption, char *headline, char *lines)
 {
   GtkWidget *notify_dialog_shell, *notify_command;
   GtkWidget *notify_label, *notify_headline, *notify_scrolled;
@@ -218,9 +267,7 @@
 
   gtk_widget_set_usize(notify_dialog_shell, 0, 265);
   gtk_set_relative_position (toplevel, notify_dialog_shell, 10, 10);
-  gtk_widget_show( notify_dialog_shell );
-
-  gtk_widget_set_sensitive( top_vbox, FALSE );
+  return notify_dialog_shell ;
 }
 
 /****************************************************************
@@ -313,7 +360,7 @@
   GtkWidget *notify_label;
   
   if (y < 0 || y >= map.ysize) {
-    popup_notify_dialog(_("Message:"), headline, lines);
+    actually_popup_notify_dialog(_("Message:"), headline, lines);
     return;
   }
   notify_dialog_shell = gtk_dialog_new();
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/dialogs.h 
./client/gui-gtk/dialogs.h
--- ../freeciv-cvs-Sep-09/client/gui-gtk/dialogs.h      Sat Apr  8 12:53:53 2000
+++ ./client/gui-gtk/dialogs.h  Mon Sep 10 21:53:38 2001
@@ -29,5 +29,7 @@
 void taxrates_callback(GtkWidget *w, GdkEventButton *ev, gpointer data);
 
 gint deleted_callback(GtkWidget *w, GdkEvent *ev, gpointer data);
+void actually_popup_notify_dialog(char *caption, char *headline, char *lines);
+void popup_delayed_notify_dialog();
 
 #endif  /* FC__DIALOGS_H */
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/gui_main.c 
./client/gui-gtk/gui_main.c
--- ../freeciv-cvs-Sep-09/client/gui-gtk/gui_main.c     Wed Aug 29 13:58:32 2001
+++ ./client/gui-gtk/gui_main.c Mon Sep 10 21:53:38 2001
@@ -51,6 +51,7 @@
 #include "graphics.h"
 #include "gui_stuff.h"
 #include "helpdata.h"          /* boot_help_texts() */
+#include "info_buttons.h"
 #include "mapctrl.h"
 #include "mapview.h"
 #include "menu.h"
@@ -403,11 +404,8 @@
   GtkStyle           *text_style;
   int                 i;
 
-  paned = gtk_vpaned_new();
-  gtk_container_add(GTK_CONTAINER(toplevel), paned);
-
   top_vbox = gtk_vbox_new(FALSE, 5);
-  gtk_paned_pack1(GTK_PANED(paned), top_vbox, TRUE, FALSE);
+  gtk_container_add(GTK_CONTAINER(toplevel), top_vbox);
   
   setup_menus(toplevel, &menubar);
   gtk_box_pack_start(GTK_BOX(top_vbox), menubar, FALSE, FALSE, 0);
@@ -526,8 +524,24 @@
       turn_done_button = gtk_button_new_with_label( _("Turn Done") );
       gtk_widget_set_style(turn_done_button, 
gtk_style_copy(turn_done_button->style));
       gtk_table_attach_defaults(GTK_TABLE(table), turn_done_button, 0, 10, 2, 
3);
+      gtk_signal_connect(GTK_OBJECT(turn_done_button), "clicked",
+                         GTK_SIGNAL_FUNC(end_turn_callback), NULL);
+      /* moved from ui_main - fta */
   }
  
+  { /* Info buttons */
+    GtkWidget *info_button_box ;
+    GtkWidget *info_button_frame ;
+
+    info_button_frame = gtk_frame_new(NULL);
+    gtk_box_pack_start(GTK_BOX(avbox), info_button_frame, FALSE, FALSE, 0);
+    
+    info_button_box = gtk_vbox_new(FALSE,0);
+    gtk_container_add(GTK_CONTAINER(info_button_frame), info_button_box);
+
+    add_info_buttons(GTK_BOX(info_button_box));
+  } /* End Info buttons */
+
   { /* selected unit status */
     GtkWidget *ubox;
 
@@ -579,8 +593,11 @@
     gtk_table_attach_defaults(GTK_TABLE(table), more_arrow_pixmap, 4, 5, 1, 2);
   }
 
+  paned = gtk_vpaned_new();
+  gtk_box_pack_start( GTK_BOX( hbox ), paned, TRUE, TRUE, 0 );
+  
   table = gtk_table_new( 2, 2, FALSE );
-  gtk_box_pack_start( GTK_BOX( hbox ), table, TRUE, TRUE, 0 );
+  gtk_paned_pack1(GTK_PANED(paned), table, TRUE, TRUE);
 
   frame = gtk_frame_new( NULL );
   gtk_table_attach(GTK_TABLE(table), frame,
@@ -628,7 +645,7 @@
 
       text = gtk_text_new(NULL, NULL);
       gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 0);
-      gtk_widget_set_usize(text, 600, 100);
+      gtk_widget_set_usize(text, 550, 100);
       gtk_text_set_editable (GTK_TEXT (text), FALSE);
 
       text_scrollbar = gtk_vscrollbar_new (GTK_TEXT(text)->vadj);
@@ -661,7 +678,7 @@
                     GTK_SIGNAL_FUNC(keyboard_handler), NULL);
   /*  gtk_key_snooper_install(keyboard_handler, NULL);*/
 
-  gtk_widget_show_all(paned);
+  gtk_widget_show_all(top_vbox);
   gtk_widget_hide(more_arrow_pixmap);
 }
 
@@ -797,9 +814,6 @@
        GTK_SIGNAL_FUNC(inputline_return), NULL);
 
 
-  gtk_signal_connect(GTK_OBJECT(turn_done_button), "clicked",
-                     GTK_SIGNAL_FUNC(end_turn_callback), NULL);
-
   gtk_widget_show(toplevel);
 
   gtk_interval_id=gtk_timeout_add(500, timer_callback, NULL);
@@ -999,6 +1013,7 @@
     }
     
     blink_active_unit();
+    blink_info_buttons();
     
     if(flip) {
       update_timeout_label();
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/gui_main.h 
./client/gui-gtk/gui_main.h
--- ../freeciv-cvs-Sep-09/client/gui-gtk/gui_main.h     Sun Apr 22 13:33:07 2001
+++ ./client/gui-gtk/gui_main.h Mon Sep 10 21:53:38 2001
@@ -17,7 +17,7 @@
 
 #include "gui_main_g.h"
 
-void end_turn_callback(GtkWidget *w, gpointer data);
+void end_turn_callback      (GtkWidget *w, gpointer data);
 
 extern GdkFont *        main_font;
 extern GdkFont *        city_productions_font;
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/info_buttons.c 
./client/gui-gtk/info_buttons.c
--- ../freeciv-cvs-Sep-09/client/gui-gtk/info_buttons.c Thu Jan  1 01:00:00 1970
+++ ./client/gui-gtk/info_buttons.c     Mon Sep 10 21:53:38 2001
@@ -0,0 +1,229 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "fcintl.h"
+#include "dialogs.h"
+#include "gui_stuff.h"
+#include "mapview.h"
+#include "messagewin.h"
+#include "repodlgs.h"
+
+#include "info_buttons.h"
+
+unsigned short is_blicking  [BUTTON_LAST] ;
+unsigned short flip_state   [BUTTON_LAST] ;
+GtkWidget *    button       [BUTTON_LAST] ;
+unsigned short is_modal     [BUTTON_LAST] ; /* 1 = window to be created modal 
when button blinks. */
+unsigned short is_permanent [BUTTON_LAST] ; /* 0 = button disabled unless it 
blinks */
+
+/* File scope functions. Forward declarations - fta */
+
+void  meswin_button_callback( GtkWidget * widget, gpointer data);
+void science_button_callback( GtkWidget * widget, gpointer data);
+void  report_button_callback( GtkWidget * widget, gpointer data);
+
+void restore_flipped_widget( GtkWidget * widget_to_restore, unsigned short* 
flip_state );
+void flip_widget           ( GtkWidget * widget_to_flip   , unsigned short* 
flip_state );
+void create_and_add_info_button( int            button_ID    ,
+                                 char*          button_name  ,
+                                 GtkSignalFunc  call_back    ,
+                                 unsigned short is_permanent ) ;
+
+/**************************************************************************
+Adds info buttons to the right control panel of the gui. The passed
+vertical box is the main box of that panel. This function is
+called at gui initialization.
+**************************************************************************/
+GtkBox* avbox ;
+
+void  add_info_buttons(GtkBox* vbox)
+{ 
+  avbox = vbox ;
+  create_and_add_info_button(BUTTON_MESSAGES,"Messages", 
meswin_button_callback, 1);
+  create_and_add_info_button(BUTTON_SCIENCE ,"Science" 
,science_button_callback, 1);
+  create_and_add_info_button(BUTTON_REPORT  ,"Report"  , 
report_button_callback, 0);
+} /* EndFunc add_info_buttons */
+
+
+/**************************************************************************
+Is used in add_info_buttons to add each info button individually.
+**************************************************************************/
+void create_and_add_info_button( int            button_ID   ,
+                                 char*          button_name ,
+                                 GtkSignalFunc  call_back   ,
+                                 unsigned short is_permanent_ ) 
+{
+  GtkWidget *  new_button ;
+
+  new_button = gtk_button_new_with_label( _(button_name) );
+  gtk_widget_set_style(new_button, gtk_style_copy(new_button->style));
+  gtk_box_pack_end(GTK_BOX(avbox), new_button, FALSE, FALSE, 0);
+  gtk_signal_connect(GTK_OBJECT(new_button), "clicked",
+                     GTK_SIGNAL_FUNC(call_back), NULL);
+  is_blicking  [button_ID] = 0 ;
+  flip_state   [button_ID] = 0 ;
+  is_modal     [button_ID] = 0 ;
+  is_permanent [button_ID] = is_permanent_ ;
+  button       [button_ID] = new_button ;
+
+  disable_info_button (button_ID); /* by default everything is disabled */
+} /* EndFunc create_and_add_info_button */
+
+/**************************************************************************
+Makes all info buttons unsensitive. Is needed in connectdlg.c during the set
+up of the client-server connection.
+**************************************************************************/
+void desactivate_info_button()
+{
+  int i ;
+  for (i=0; i<BUTTON_LAST; i++)
+    disable_info_button (i);
+
+} /* EndFunction desactivate_info_button */
+
+/**************************************************************************
+Restore default sensitivity of info buttons. Use it after 
desactivate_info_button()
+has been called to re-activate info-buttons.
+**************************************************************************/
+void activate_info_button()
+{
+  int i ;
+  for (i=0; i<BUTTON_LAST; i++) 
+    {
+      if (is_permanent [i]) 
+        enable_info_button (i);
+    } /* EndFor */
+
+} /* EndFunction desactivate_info_button */
+
+/**************************************************************************
+...
+**************************************************************************/
+void make_info_button_blink(int button_ID)
+{
+  make_info_button_blink_modal (button_ID,0) ;
+} /* EndFunc make_info_button_blink */
+
+/**************************************************************************
+As make_info_button_blink except for the second arg make_modal.
+make_modal==1 specifies that when the button is clicked 
+the corresponding windows should be made modal (for instance: for the
+science dialog, after a new technology has been found.)
+**************************************************************************/
+void  make_info_button_blink_modal (int button_ID, unsigned short make_modal)
+{
+  enable_info_button (button_ID);
+  is_blicking[button_ID]=1 ;
+  is_modal   [button_ID]=make_modal ;
+} /* make_info_button_blink_modal */
+
+/**************************************************************************
+...
+**************************************************************************/
+void stop_info_button_blink(int button_ID)
+{
+  is_blicking[button_ID]=0 ;
+  is_modal   [button_ID]=0 ;
+  restore_flipped_widget (  button     [button_ID] ,
+                           &flip_state [button_ID] );
+
+  if (!is_permanent[button_ID]) disable_info_button (button_ID);
+
+} /* EndFunc stop_info_button_blink */
+
+/**************************************************************************
+...
+**************************************************************************/
+void blink_info_buttons()
+{
+  int i ;
+  for (i=0; i<BUTTON_LAST; i++)
+      if (is_blicking[i])
+        flip_widget(   button     [i] ,
+                      &flip_state [i] );
+
+} /* EndFunc blink_info_buttons */
+
+/**************************************************************************
+Switches the forground and the background colors of a wigdet, in order
+to create a blink effect. The parameter flip_state is used to
+remember the state of the widget (flipped or not flipped), in order
+to be able to restore it to its normal state.
+**************************************************************************/
+void flip_widget(GtkWidget * widget_to_flip, unsigned short* flip_state)
+{
+   GdkGC      *fore, *back;
+ 
+   fore = widget_to_flip->style->   bg_gc[GTK_STATE_NORMAL];
+   back = widget_to_flip->style->light_gc[GTK_STATE_NORMAL];
+   
+   widget_to_flip->style->   bg_gc[GTK_STATE_NORMAL] = back;
+   widget_to_flip->style->light_gc[GTK_STATE_NORMAL] = fore;
+   
+   gtk_expose_now(widget_to_flip);
+   
+   *flip_state=!*flip_state;
+} /* EndFunction flip_widget */
+
+/**************************************************************************
+Takes a possibly flipped widget back to its normal state
+**************************************************************************/
+void restore_flipped_widget(GtkWidget * widget_to_restore,unsigned short* 
flip_state)
+{
+  if (*flip_state) flip_widget(widget_to_restore,flip_state);
+} // EndFunction restore_flipped_widget
+
+/**************************************************************************
+...
+**************************************************************************/
+void enable_info_button(int button_ID)
+{
+  gtk_widget_set_sensitive(button[button_ID],TRUE);
+}
+
+/**************************************************************************
+...
+**************************************************************************/
+void disable_info_button(int button_ID)
+{
+  gtk_widget_set_sensitive(button[button_ID],FALSE);
+}
+
+/**************************************************************************
+This method is called back when the message button is pressed.
+**************************************************************************/
+void meswin_button_callback(GtkWidget *widget, gpointer data)
+{
+  toggle_meswin() ;
+}
+
+
+/**************************************************************************
+This method is called back when the science button is pressed.
+**************************************************************************/
+void science_button_callback(GtkWidget *widget, gpointer data)
+{
+  toggle_science(is_modal[BUTTON_SCIENCE]) ;
+}
+ 
+/**************************************************************************
+This method is called back when the report button is pressed.
+**************************************************************************/
+void report_button_callback(GtkWidget *widget, gpointer data)
+{
+  popup_delayed_notify_dialog();
+}
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/info_buttons.h 
./client/gui-gtk/info_buttons.h
--- ../freeciv-cvs-Sep-09/client/gui-gtk/info_buttons.h Thu Jan  1 01:00:00 1970
+++ ./client/gui-gtk/info_buttons.h     Mon Sep 10 21:53:38 2001
@@ -0,0 +1,38 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+#ifndef INFO_BUTTONS_H
+#define INFO_BUTTONS_H
+
+#include <gtk/gtk.h>
+
+enum info_button_ID {
+  BUTTON_MESSAGES,
+  BUTTON_SCIENCE,
+  BUTTON_REPORT,
+  BUTTON_LAST     /* leave it last */
+} ; /* End info_button_ID */
+
+void   add_info_buttons(GtkBox* avbox);
+void blink_info_buttons();
+
+void  stop_info_button_blink       (int button_ID);
+void  make_info_button_blink       (int button_ID);
+void  make_info_button_blink_modal (int button_ID, unsigned short is_modal);
+
+void  enable_info_button           (int button_ID);
+void disable_info_button           (int button_ID);
+
+void desactivate_info_button();
+void    activate_info_button();
+
+#endif /* INFO_BUTTONS_H */
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/menu.c 
./client/gui-gtk/menu.c
--- ../freeciv-cvs-Sep-09/client/gui-gtk/menu.c Fri Sep  7 07:56:00 2001
+++ ./client/gui-gtk/menu.c     Mon Sep 10 21:53:39 2001
@@ -38,6 +38,7 @@
 #include "gotodlg.h"
 #include "gui_stuff.h"
 #include "helpdlg.h"
+#include "info_buttons.h"
 #include "mapctrl.h"   /* center_on_unit */
 #include "messagedlg.h"
 #include "messagewin.h"
@@ -424,7 +425,7 @@
     popup_economy_report_dialog(0);
     break;
    case MENU_REPORT_SCIENCE:
-    popup_science_dialog(0);
+    actually_popup_science_dialog(0);
     break;
    case MENU_REPORT_WOW:
     send_report_request(REPORT_WONDERS_OF_THE_WORLD);
@@ -433,7 +434,7 @@
     send_report_request(REPORT_TOP_5_CITIES);
     break;
   case MENU_REPORT_MESSAGES:
-    popup_meswin_dialog();
+    actually_popup_meswin_dialog();
     break;
    case MENU_REPORT_DEMOGRAPHIC:
     send_report_request(REPORT_DEMOGRAPHIC);
@@ -954,12 +955,14 @@
     menus_set_sensitive("<main>/_Kingdom", FALSE);
     menus_set_sensitive("<main>/_View", FALSE);
     menus_set_sensitive("<main>/_Orders", FALSE);
+    desactivate_info_button();
   } else {
     struct unit *punit;
     menus_set_sensitive("<main>/_Reports", TRUE);
     menus_set_sensitive("<main>/_Kingdom", TRUE);
     menus_set_sensitive("<main>/_View", TRUE);
     menus_set_sensitive("<main>/_Orders", TRUE);
+    activate_info_button();
   
     menus_set_sensitive("<main>/_Reports/S_paceship",
                        (game.player_ptr->spaceship.state!=SSHIP_NONE));
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/messagewin.c 
./client/gui-gtk/messagewin.c
--- ../freeciv-cvs-Sep-09/client/gui-gtk/messagewin.c   Tue Jan 30 13:59:51 2001
+++ ./client/gui-gtk/messagewin.c       Mon Sep 10 22:37:28 2001
@@ -35,6 +35,7 @@
 #include "colors.h"
 #include "gui_main.h"
 #include "gui_stuff.h"
+#include "info_buttons.h"
 #include "mapview.h"
 #include "options.h"
 
@@ -80,7 +80,7 @@
 /****************************************************************
 popup the dialog 10% inside the main-window 
 *****************************************************************/
-void popup_meswin_dialog(void)
+void actually_popup_meswin_dialog(void)
 {
   int updated = 0;
   
@@ -89,12 +89,23 @@
     updated = 1;              /* create_ calls update_ */
   }
 
-  gtk_set_relative_position(toplevel, meswin_dialog_shell, 25, 25);
   gtk_widget_show(meswin_dialog_shell);
+  gdk_window_show(meswin_dialog_shell->window) ;
   if(!updated) 
     update_meswin_dialog();
   
   meswin_scroll_down();
+  stop_info_button_blink(BUTTON_MESSAGES);
+
+}
+
+/****************************************************************
+We defer the popping up of the message dialog until the user
+clicks on the button.
+*****************************************************************/
+void popup_meswin_dialog(void)
+{
+  make_info_button_blink(BUTTON_MESSAGES);
 }
 
 
@@ -198,6 +209,7 @@
 
   gtk_widget_show_all( GTK_DIALOG(meswin_dialog_shell)->vbox );
   gtk_widget_show_all( GTK_DIALOG(meswin_dialog_shell)->action_area );
+  gtk_set_relative_position(toplevel, meswin_dialog_shell, 25, 25);
 }
 
 /**************************************************************************
@@ -326,8 +338,8 @@
   if (!meswin_dialog_shell) { 
     if (messages_total > 0 &&
         (!game.player_ptr->ai.control || ai_popup_windows)) {
-      popup_meswin_dialog();
-      /* Can return here because popup_meswin_dialog will call
+          create_meswin_dialog();
+      /* Can return here because create_meswin_dialog will call
        * this very function again.
        */
       return;
@@ -349,6 +361,27 @@
      gtk_widget_show_all(meswin_list);
    }
 
+  if (messages_total > 0) 
+    make_info_button_blink(BUTTON_MESSAGES);
+  else
+    stop_info_button_blink(BUTTON_MESSAGES);
+}
+
+/**************************************************************************
+...
+**************************************************************************/
+void toggle_meswin() 
+{
+   stop_info_button_blink(BUTTON_MESSAGES);
+   if(meswin_dialog_shell) 
+       if (meswin_dialog_shell->window)
+           if (gdk_window_is_visible (meswin_dialog_shell->window)) 
+             {
+               gdk_window_hide(meswin_dialog_shell->window) ;
+               return ;
+             } /* EndIf gdk_window_is_visible */
+
+   actually_popup_meswin_dialog();
 }
 
 /**************************************************************************
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/messagewin.h 
./client/gui-gtk/messagewin.h
--- ../freeciv-cvs-Sep-09/client/gui-gtk/messagewin.h   Tue Jul 20 13:43:15 1999
+++ ./client/gui-gtk/messagewin.h       Mon Sep 10 21:53:39 2001
@@ -15,6 +15,9 @@
 
 #include "messagewin_g.h"
 
+void toggle_meswin() ;
+void actually_popup_meswin_dialog(void);
+
 /* nothing else */
 
 #endif  /* FC__MESSAGEWIN_H */
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/repodlgs.c 
./client/gui-gtk/repodlgs.c
--- ../freeciv-cvs-Sep-09/client/gui-gtk/repodlgs.c     Fri Sep  7 07:56:00 2001
+++ ./client/gui-gtk/repodlgs.c Mon Sep 10 21:53:39 2001
@@ -26,6 +26,7 @@
 #include "fcintl.h"
 #include "game.h"
 #include "government.h"
+#include "info_buttons.h"
 #include "packets.h"
 #include "shared.h"
 #include "support.h"
@@ -141,12 +142,18 @@
 
   return buf;
 }
-
+/****************************************************************
+Delay actual popup until the user presses the info button.
+*****************************************************************/
+void popup_science_dialog(int make_modal)
+{
+  make_info_button_blink_modal(BUTTON_SCIENCE,make_modal);
+}
 
 /****************************************************************
 ...
 *****************************************************************/
-void popup_science_dialog(int make_modal)
+void actually_popup_science_dialog(int make_modal)
 {
   if(!science_dialog_shell) {
     science_dialog_shell_is_modal=make_modal;
@@ -159,6 +166,24 @@
 
     gtk_widget_show( science_dialog_shell );
   }
+  gdk_window_show( science_dialog_shell->window ) ;
+}
+
+/**************************************************************************
+...
+**************************************************************************/
+void toggle_science(int make_modal) 
+{
+   stop_info_button_blink(BUTTON_SCIENCE);
+   if(science_dialog_shell) 
+       if (science_dialog_shell->window)
+           if (gdk_window_is_visible (science_dialog_shell->window)) 
+             {
+               gdk_window_hide(science_dialog_shell->window) ;
+               return ;
+             } /* EndIf gdk_window_is_visible */
+
+   actually_popup_science_dialog(make_modal);
 }
 
 
@@ -734,7 +759,7 @@
                get_improvement_name(i));
   }
   gtk_clist_unselect_row(GTK_CLIST(economy_list),row,0);
-  popup_notify_dialog(_("Sell-Off:"),_("Results"),str);
+  actually_popup_notify_dialog(_("Sell-Off:"),_("Results"),str);
   }
   return;
 }
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-gtk/repodlgs.h 
./client/gui-gtk/repodlgs.h
--- ../freeciv-cvs-Sep-09/client/gui-gtk/repodlgs.h     Tue Jan 30 13:59:52 2001
+++ ./client/gui-gtk/repodlgs.h Mon Sep 10 21:53:39 2001
@@ -16,5 +16,7 @@
 #include "repodlgs_g.h"
 
 extern int delay_report_update;
+void toggle_science(int make_modal) ;
+void actually_popup_science_dialog(int make_modal);
 
 #endif  /* FC__REPODLGS_H */
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-mui/dialogs.c 
./client/gui-mui/dialogs.c
--- ../freeciv-cvs-Sep-09/client/gui-mui/dialogs.c      Mon Aug  6 13:58:27 2001
+++ ./client/gui-mui/dialogs.c  Mon Sep 10 21:53:39 2001
@@ -109,7 +109,8 @@
 /****************************************************************
  Popup the notify window
 *****************************************************************/
-void popup_notify_dialog(char *caption, char *headline, char *lines)
+void popup_notify_dialog(char *caption, char *headline, char *lines, 
+                         int is_broadcast)
 {
   Object *wnd;
   Object *listview;
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-mui/repodlgs.c 
./client/gui-mui/repodlgs.c
--- ../freeciv-cvs-Sep-09/client/gui-mui/repodlgs.c     Mon Aug  6 13:58:31 2001
+++ ./client/gui-mui/repodlgs.c Mon Sep 10 21:53:39 2001
@@ -548,7 +548,7 @@
     {
       my_snprintf(str, sizeof(str), _("No %s could be sold"), 
get_improvement_name(i));
     }
-    popup_notify_dialog(_("Sell-Off:"), _("Results"), str);
+    popup_notify_dialog(_("Sell-Off:"), _("Results"), str, 0);
   }
 }
 
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-stub/dialogs.c 
./client/gui-stub/dialogs.c
--- ../freeciv-cvs-Sep-09/client/gui-stub/dialogs.c     Mon Apr 17 12:53:06 2000
+++ ./client/gui-stub/dialogs.c Mon Sep 10 21:53:39 2001
@@ -10,7 +10,8 @@
 }
 
 void
-popup_notify_dialog(char *caption, char *headline, char *lines)
+popup_notify_dialog(char *caption, char *headline, char *lines, 
+                    int is_broadcast)
 {
        /* PORTME */
 }
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-xaw/dialogs.c 
./client/gui-xaw/dialogs.c
--- ../freeciv-cvs-Sep-09/client/gui-xaw/dialogs.c      Sat Jun 30 13:37:50 2001
+++ ./client/gui-xaw/dialogs.c  Mon Sep 10 21:53:40 2001
@@ -183,7 +183,8 @@
 /****************************************************************
 ...
 *****************************************************************/
-void popup_notify_dialog(char *caption, char *headline, char *lines)
+void popup_notify_dialog(char *caption, char *headline, char *lines, 
+                         int is_broadcast)
 {
   Widget notify_dialog_shell, notify_form, notify_command;
   Widget notify_headline, notify_label;
@@ -312,7 +313,7 @@
   Dimension width, width2, width_1, width_2;
   
   if (y < 0 || y >= map.ysize) {
-    popup_notify_dialog("Message:", headline, lines);
+    popup_notify_dialog("Message:", headline, lines, 0);
     return;
   }
   notify_dialog_shell = XtCreatePopupShell("Message:",
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/gui-xaw/repodlgs.c 
./client/gui-xaw/repodlgs.c
--- ../freeciv-cvs-Sep-09/client/gui-xaw/repodlgs.c     Wed Jan 31 13:35:48 2001
+++ ./client/gui-xaw/repodlgs.c Mon Sep 10 21:53:40 2001
@@ -773,7 +773,7 @@
     my_snprintf(str, sizeof(str), _("No %s could be sold"),
                get_improvement_name(i));
   }
-  popup_notify_dialog(_("Sell-Off:"), _("Results"), str);
+  popup_notify_dialog(_("Sell-Off:"), _("Results"), str, 0);
   return;
 }
 
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/include/dialogs_g.h 
./client/include/dialogs_g.h
--- ../freeciv-cvs-Sep-09/client/include/dialogs_g.h    Mon Apr 17 12:53:08 2000
+++ ./client/include/dialogs_g.h        Mon Sep 10 21:53:40 2001
@@ -18,7 +18,8 @@
 struct city;
 
 void popup_notify_goto_dialog(char *headline, char *lines, int x, int y);
-void popup_notify_dialog(char *caption, char *headline, char *lines);
+void popup_notify_dialog(char *caption, char *headline, char *lines, 
+                         int is_broadcast);
 
 void popup_races_dialog(void);
 void popdown_races_dialog(void);
diff -urBbNX diff_ignore ../freeciv-cvs-Sep-09/client/packhand.c 
./client/packhand.c
--- ../freeciv-cvs-Sep-09/client/packhand.c     Sun Sep  9 22:15:27 2001
+++ ./client/packhand.c Mon Sep 10 21:53:40 2001
@@ -722,7 +722,11 @@
 
   if (!game.player_ptr->ai.control || ai_popup_windows || 
        packet->event != BROADCAST_EVENT)
-    popup_notify_dialog(caption, headline, lines);
+    popup_notify_dialog( caption,
+                         headline,
+                         lines, 
+                         (packet->event == BROADCAST_EVENT)
+                         );
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]