adonthell-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-commits] CVS: adonthell/src/tools/dlgedit cfg_data.cc,1.3,1.4


From: Kai Sterker <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src/tools/dlgedit cfg_data.cc,1.3,1.4 cfg_data.h,1.2,1.3 cfg_io.cc,1.2,1.3 cfg_project.cc,1.2,1.3 cfg_project.h,1.3,1.4 dlg_cmdline.cc,1.5,1.6 dlg_types.h,1.5,1.6 gui_dlgedit.cc,1.6,1.7 gui_dlgedit.h,1.5,1.6 gui_dlgedit_events.cc,1.3,1.4 gui_dlgedit_events.h,1.3,1.4 gui_file.cc,1.2,1.3 gui_settings.cc,1.7,1.8 gui_settings.h,1.5,1.6 kb_traverse.h,1.1,1.2
Date: Tue, 22 Oct 2002 11:20:43 -0400

Update of /cvsroot/adonthell/adonthell/src/tools/dlgedit
In directory subversions:/tmp/cvs-serv4352

Modified Files:
        cfg_data.cc cfg_data.h cfg_io.cc cfg_project.cc cfg_project.h 
        dlg_cmdline.cc dlg_types.h gui_dlgedit.cc gui_dlgedit.h 
        gui_dlgedit_events.cc gui_dlgedit_events.h gui_file.cc 
        gui_settings.cc gui_settings.h kb_traverse.h 
Log Message:
ADDED 'Load Previous' menu item to quickly access recently opened files
FIEXD compilation with gcc 3.2
FIXED redefinition of SAVE with different value


Index: cfg_data.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/cfg_data.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** cfg_data.cc 21 Oct 2002 20:10:30 -0000      1.3
--- cfg_data.cc 22 Oct 2002 15:20:40 -0000      1.4
***************
*** 71,74 ****
--- 71,86 ----
  }
  
+ // get list of previously opened files
+ std::list<std::string> CfgData::getFiles ()
+ {
+     // copy contents of Files into the list
+     std::list<std::string> files (Files.begin (), Files.end ());
+ 
+     // sort the list
+     files.sort ();
+ 
+     return files;
+ }
+ 
  // add entry to list of projects
  void CfgData::addProject (std::string &project)
***************
*** 127,131 ****
  
  // save configuration data
! void CfgData::save (ofstream &out)
  {
      // save list of files
--- 139,143 ----
  
  // save configuration data
! void CfgData::save (std::ofstream &out)
  {
      // save list of files

Index: cfg_data.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/cfg_data.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** cfg_data.h  21 Oct 2002 20:10:30 -0000      1.2
--- cfg_data.h  22 Oct 2002 15:20:40 -0000      1.3
***************
*** 25,28 ****
--- 25,29 ----
  #include <vector>
  #include <deque>
+ #include <list>
  #include "cfg_project.h"
  
***************
*** 57,60 ****
--- 58,67 ----
      void addFile (std::string & file);
      /**
+      * Get the list of files, sorted alphabetically.
+      * @return list of previously opened files.                               
             
+      */
+     std::list<std::string> getFiles ();
+     
+     /**
       * Adds a project to the list of projects and loads all project
       * specific data. The number of projects isn't limited.
***************
*** 81,85 ****
       * @param file file to save data to.
       */
!     void save (ofstream & file);
      
      /**
--- 88,92 ----
       * @param file file to save data to.
       */
!     void save (std::ofstream & file);
      
      /**

Index: cfg_io.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/cfg_io.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** cfg_io.cc   17 Oct 2002 20:42:59 -0000      1.2
--- cfg_io.cc   22 Oct 2002 15:20:40 -0000      1.3
***************
*** 94,98 ****
      
      // write header
!     out << "# Adonthell Dialogue Editor configuration file\n" << endl;
              
      // save data
--- 94,98 ----
      
      // write header
!     out << "# Adonthell Dialogue Editor configuration file\n" << std::endl;
              
      // save data

Index: cfg_project.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/cfg_project.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** cfg_project.cc      21 Oct 2002 20:10:30 -0000      1.2
--- cfg_project.cc      22 Oct 2002 15:20:40 -0000      1.3
***************
*** 60,67 ****
  
  // save project data
! void CfgProject::save (ofstream &out)
  {
      out << "\nProject [" << Name << "]\n"
          << "  BaseDir [" << BaseDir << "]\n"
!         << "End" << endl;
  }
--- 60,67 ----
  
  // save project data
! void CfgProject::save (std::ofstream &out)
  {
      out << "\nProject [" << Name << "]\n"
          << "  BaseDir [" << BaseDir << "]\n"
!         << "End" << std::endl;
  }

Index: cfg_project.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/cfg_project.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** cfg_project.h       21 Oct 2002 20:10:30 -0000      1.3
--- cfg_project.h       22 Oct 2002 15:20:40 -0000      1.4
***************
*** 50,54 ****
       * @param file file to save data to.
       */
!     void save (ofstream & file);
      
      /**
--- 50,54 ----
       * @param file file to save data to.
       */
!     void save (std::ofstream & file);
      
      /**

Index: dlg_cmdline.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/dlg_cmdline.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** dlg_cmdline.cc      21 Oct 2002 20:10:30 -0000      1.5
--- dlg_cmdline.cc      22 Oct 2002 15:20:40 -0000      1.6
***************
*** 20,24 ****
   */
   
! #include <iostream.h> 
  #include <dirent.h>
  #include <getopt.h>
--- 20,24 ----
   */
   
! #include <iostream> 
  #include <dirent.h>
  #include <getopt.h>
***************
*** 49,53 ****
              case 'd':
              {
!                 cout << datadir << std::endl;
                  return false;
              }
--- 49,53 ----
              case 'd':
              {
!                 std::cout << datadir << std::endl;
                  return false;
              }
***************
*** 55,59 ****
              case 'v':
              {
!                 cout << _VERSION_ << std::endl;
                  return false; 
              }
--- 55,59 ----
              case 'v':
              {
!                 std::cout << _VERSION_ << std::endl;
                  return false; 
              }
***************
*** 83,87 ****
                  if (!mydir) 
                  {
!                     cerr << "No such directory " << datadir << "!" << endl;
                      return false;
                  }
--- 83,87 ----
                  if (!mydir) 
                  {
!                     std::cerr << "No such directory " << datadir << "!" << 
std::endl;
                      return false;
                  }
***************
*** 107,118 ****
  void DlgCmdline::help (const std::string &program)
  {
!     cout << "Usage: " << program << " [OPTIONS] [SOURCES]" << endl;
!     cout << endl;
!     cout << "Where [OPTIONS] can be:\n";
!     cout << "-h         print this help message and exit" << endl; 
!     cout << "-d         print the project directory and exit" << endl; 
!     cout << "-v         print version and exit" << endl; 
!     cout << "-c         compile all SOURCES and exit" << endl;
!     cout << "-p dir     specify a custom project directory" << endl;
!     cout << "-j project specify a default project" << endl;   
  }
--- 107,118 ----
  void DlgCmdline::help (const std::string &program)
  {
!     std::cout << "Usage: " << program << " [OPTIONS] [SOURCES]" << std::endl;
!     std::cout << std::endl;
!     std::cout << "Where [OPTIONS] can be:\n";
!     std::cout << "-h         print this help message and exit" << std::endl; 
!     std::cout << "-d         print the project directory and exit" << 
std::endl; 
!     std::cout << "-v         print version and exit" << std::endl; 
!     std::cout << "-c         compile all SOURCES and exit" << std::endl;
!     std::cout << "-p dir     specify a custom project directory" << std::endl;
!     std::cout << "-j project specify a default project" << std::endl;
  }

Index: dlg_types.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/dlg_types.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** dlg_types.h 17 Oct 2002 10:08:42 -0000      1.5
--- dlg_types.h 22 Oct 2002 15:20:40 -0000      1.6
***************
*** 91,95 ****
      PREVIEW         = 6,
      RUN             = 7,
!     MAX_ITEM        = 8
  };
  
--- 91,96 ----
      PREVIEW         = 6,
      RUN             = 7,
!     OPEN_RECENT     = 8,
!     MAX_ITEM        = 9
  };
  
***************
*** 97,106 ****
   * Load node of file selction box.
   */
! #define LOAD    1
  
  /**
   * Save mode of file selction box.
   */
! #define SAVE    2
  
  /**
--- 98,107 ----
   * Load node of file selction box.
   */
! #define FS_LOAD     1
  
  /**
   * Save mode of file selction box.
   */
! #define FS_SAVE     2
  
  /**

Index: gui_dlgedit.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_dlgedit.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** gui_dlgedit.cc      21 Oct 2002 20:10:30 -0000      1.6
--- gui_dlgedit.cc      22 Oct 2002 15:20:40 -0000      1.7
***************
*** 32,35 ****
--- 32,36 ----
  #include <stdio.h>
  #include "gettext.h"
+ #include "cfg_data.h"
  #include "dlg_cmdline.h"
  #include "dlg_compiler.h"
***************
*** 134,138 ****
      gtk_widget_show (menuitem);
  
!     // Load
      menuitem = gtk_menu_item_new_with_label ("Open ...");
      gtk_container_add (GTK_CONTAINER (submenu), menuitem);
--- 135,139 ----
      gtk_widget_show (menuitem);
  
!     // Open
      menuitem = gtk_menu_item_new_with_label ("Open ...");
      gtk_container_add (GTK_CONTAINER (submenu), menuitem);
***************
*** 144,147 ****
--- 145,157 ----
      gtk_widget_show (menuitem);
  
+     // Open Previous >
+     menuitem = gtk_menu_item_new_with_label ("Open Previous");
+     gtk_container_add (GTK_CONTAINER (submenu), menuitem);
+     gtk_object_set_data (GTK_OBJECT (menuitem), "help-id", GINT_TO_POINTER 
(2));
+     gtk_signal_connect (GTK_OBJECT (menuitem), "enter-notify-event", 
GTK_SIGNAL_FUNC (on_display_help), message);
+     gtk_signal_connect (GTK_OBJECT (menuitem), "leave-notify-event", 
GTK_SIGNAL_FUNC (on_clear_help), message);
+     gtk_widget_show (menuitem);
+     menuItem[OPEN_RECENT] = menuitem;
+     
      // Save
      menuitem = gtk_menu_item_new_with_label ("Save");
***************
*** 243,247 ****
      // Preview i18n
  #ifdef ENABLE_NLS 
!     menuitem = gtk_menu_item_new_with_label ("Preview Localization ...");
      gtk_container_add (GTK_CONTAINER (submenu), menuitem);
      gtk_widget_add_accelerator (menuitem, "activate", accel_group, GDK_l, 
GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
--- 253,257 ----
      // Preview i18n
  #ifdef ENABLE_NLS 
!     menuitem = gtk_menu_item_new_with_label ("Preview L10n ...");
      gtk_container_add (GTK_CONTAINER (submenu), menuitem);
      gtk_widget_add_accelerator (menuitem, "activate", accel_group, GDK_l, 
GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
***************
*** 340,343 ****
--- 350,356 ----
      initColors (graph_->drawingArea ());
  
+     // init list of previously opened files
+     initRecentFiles ();
+     
      // get the current working directory
      directory_ = g_get_current_dir ();
***************
*** 378,381 ****
--- 391,397 ----
          return;
      }
+ 
+     // make sure that file has an absolute path
+     if (file[0] != '/') file = directory_ + std::string ("/") + file;
      
      // remember the current directory for later use
***************
*** 387,391 ****
      // remove file extension
      unsigned int pos = filename.rfind (FILE_EXT);
!     if (pos != filename.npos) filename.erase (pos, -1);
  
      // the new dialogue
--- 403,407 ----
      // remove file extension
      unsigned int pos = filename.rfind (FILE_EXT);
!     if (pos != filename.npos) filename.erase (pos);
  
      // the new dialogue
***************
*** 402,405 ****
--- 418,424 ----
      else 
      {
+         // update list of previously opened files
+         CfgData::data->addFile (file);
+ 
          message->display (200);      
          showDialogue (module, true);
***************
*** 421,425 ****
      // remove file extension
      unsigned int pos = filename.rfind (FILE_EXT);
!     if (pos != filename.npos) filename.erase (pos, -1);
  
      // try to save file
--- 440,444 ----
      // remove file extension
      unsigned int pos = filename.rfind (FILE_EXT);
!     if (pos != filename.npos) filename.erase (pos);
  
      // try to save file
***************
*** 430,433 ****
--- 449,455 ----
          message->display (201);
          
+         // update list of previously opened files
+         CfgData::data->addFile (file);
+ 
          // update the dialogue's name in case it has changed
          initTitle ();
***************
*** 459,462 ****
--- 481,487 ----
      initMenu ();
      
+     // update list of previously opened files
+     initRecentFiles ();
+     
      // delete the dialogue
      delete module;
***************
*** 732,735 ****
--- 757,789 ----
                  GDK_1 + position, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
      }
+ }
+ 
+ // initialize the list of recently opened files
+ void GuiDlgedit::initRecentFiles ()
+ {
+     GtkWidget *submenu = GTK_MENU_ITEM(menuItem[OPEN_RECENT])->submenu;
+     GtkWidget *menuitem;
+     
+     // first, remove everything from the submenu
+     if (submenu != NULL)
+         gtk_container_foreach (GTK_CONTAINER (submenu), (GtkCallback) 
gtk_widget_destroy, NULL);
+     else
+         submenu = gtk_menu_new ();
+ 
+     // get list of files
+     std::list<std::string> files = CfgData::data->getFiles ();
+     
+     // now recreate the recent files list
+     for (std::list<std::string>::iterator i = files.begin (); i != files.end 
(); i++)
+     {
+         menuitem = gtk_menu_item_new_with_label ((*i).c_str ());
+         gtk_container_add (GTK_CONTAINER (submenu), menuitem);
+         gtk_object_set_user_data (GTK_OBJECT (menuitem), (void *) (*i).c_str 
());
+         gtk_signal_connect (GTK_OBJECT (menuitem), "activate", 
GTK_SIGNAL_FUNC (on_file_load_recent_activate), (gpointer) this);
+         gtk_widget_show (menuitem);          
+     }
+ 
+     // append submenu
+     gtk_menu_item_set_submenu (GTK_MENU_ITEM(menuItem[OPEN_RECENT]), submenu);
  }
  

Index: gui_dlgedit.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_dlgedit.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** gui_dlgedit.h       12 Oct 2002 18:51:33 -0000      1.5
--- gui_dlgedit.h       22 Oct 2002 15:20:40 -0000      1.6
***************
*** 183,186 ****
--- 183,190 ----
      void initMenu ();
      /**
+      * (Re)build the 'open recent' sub-menu.                      
+      */
+     void initRecentFiles ();
+     /**
       * Display the correct window title
       */

Index: gui_dlgedit_events.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_dlgedit_events.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** gui_dlgedit_events.cc       12 Oct 2002 18:51:33 -0000      1.3
--- gui_dlgedit_events.cc       22 Oct 2002 15:20:40 -0000      1.4
***************
*** 38,46 ****
  }
  
! // File Menu: Load
  void on_file_load_activate (GtkMenuItem * menuitem, gpointer user_data)
  {
      GuiDlgedit *dlgedit = (GuiDlgedit *) user_data;
!     GuiFile fs (LOAD, "Load dialogue source", dlgedit->directory ());
  
      // File selection closed with OK
--- 38,46 ----
  }
  
!  // File Menu: Load
  void on_file_load_activate (GtkMenuItem * menuitem, gpointer user_data)
  {
      GuiDlgedit *dlgedit = (GuiDlgedit *) user_data;
!     GuiFile fs (FS_LOAD, "Load dialogue source", dlgedit->directory ());
  
      // File selection closed with OK
***************
*** 48,51 ****
--- 48,63 ----
  }
  
+ // File Menu: Load Recent
+ void on_file_load_recent_activate (GtkMenuItem * menuitem, gpointer user_data)
+ {
+     // get file
+     const char *file = (const char*) gtk_object_get_user_data (GTK_OBJECT 
(menuitem));
+ 
+     // load
+     GuiDlgedit *dlgedit = (GuiDlgedit *) user_data;
+     dlgedit->loadDialogue (file);
+ }
+ 
+ 
  // File Menu: Save
  void on_file_save_activate (GtkMenuItem * menuitem, gpointer user_data)
***************
*** 59,63 ****
  {
      GuiDlgedit *dlgedit = (GuiDlgedit *) user_data;
!     GuiFile fs (SAVE, "Save dialogue source", dlgedit->filename ());
  
      // File selection closed with OK
--- 71,75 ----
  {
      GuiDlgedit *dlgedit = (GuiDlgedit *) user_data;
!     GuiFile fs (FS_SAVE, "Save dialogue source", dlgedit->filename ());
  
      // File selection closed with OK
***************
*** 94,98 ****
  {
      GuiDlgedit *dlgedit = (GuiDlgedit *) user_data;
!     GuiFile fs (LOAD, "Select message catalogue (.mo)", dlgedit->directory 
());
  
      // start translation preview
--- 106,110 ----
  {
      GuiDlgedit *dlgedit = (GuiDlgedit *) user_data;
!     GuiFile fs (FS_LOAD, "Select message catalogue (.mo)", dlgedit->directory 
());
  
      // start translation preview

Index: gui_dlgedit_events.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_dlgedit_events.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** gui_dlgedit_events.h        12 Oct 2002 18:51:33 -0000      1.3
--- gui_dlgedit_events.h        22 Oct 2002 15:20:40 -0000      1.4
***************
*** 28,31 ****
--- 28,32 ----
  void on_file_new_activate (GtkMenuItem *, gpointer);
  void on_file_load_activate (GtkMenuItem *, gpointer);
+ void on_file_load_recent_activate (GtkMenuItem *, gpointer);
  void on_file_save_activate (GtkMenuItem *, gpointer);
  void on_file_save_as_activate (GtkMenuItem *, gpointer);

Index: gui_file.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_file.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** gui_file.cc 7 Apr 2002 09:51:28 -0000       1.2
--- gui_file.cc 22 Oct 2002 15:20:40 -0000      1.3
***************
*** 37,41 ****
  
      // hide new/delete/rename directory buttons if we're loading a file
!     if (type == LOAD) gtk_file_selection_hide_fileop_buttons 
(GTK_FILE_SELECTION (window));
  
      // open the directory browsed last 
--- 37,41 ----
  
      // hide new/delete/rename directory buttons if we're loading a file
!     if (type == FS_LOAD) gtk_file_selection_hide_fileop_buttons 
(GTK_FILE_SELECTION (window));
  
      // open the directory browsed last 

Index: gui_settings.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_settings.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** gui_settings.cc     21 Oct 2002 20:10:30 -0000      1.7
--- gui_settings.cc     22 Oct 2002 15:20:40 -0000      1.8
***************
*** 53,57 ****
      if (dir == "") dir = GuiDlgedit::window->directory ();
      
!     GuiFile fs (LOAD, "Select base directory", dir + "/");
  
      // File selection closed with OK
--- 53,57 ----
      if (dir == "") dir = GuiDlgedit::window->directory ();
      
!     GuiFile fs (FS_LOAD, "Select base directory", dir + "/");
  
      // File selection closed with OK

Index: gui_settings.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_settings.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** gui_settings.h      21 Oct 2002 20:10:30 -0000      1.5
--- gui_settings.h      22 Oct 2002 15:20:40 -0000      1.6
***************
*** 66,70 ****
       * @name Member access
       */
!     //@{}
      /**
       * Set the base directory according to selected project. Call this
--- 66,70 ----
       * @name Member access
       */
!     //@{            
      /**
       * Set the base directory according to selected project. Call this

Index: kb_traverse.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/kb_traverse.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** kb_traverse.h       14 Oct 2002 17:34:32 -0000      1.1
--- kb_traverse.h       22 Oct 2002 15:20:40 -0000      1.2
***************
*** 131,133 ****
  };
  
! #endif // KB_TRAVERSE_H
\ No newline at end of file
--- 131,133 ----
  };
  
! #endif // KB_TRAVERSE_H





reply via email to

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