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.2,1.3


From: Kai Sterker <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src/tools/dlgedit cfg_data.cc,1.2,1.3 cfg_data.h,1.1,1.2 cfg_project.cc,1.1,1.2 cfg_project.h,1.2,1.3 dlg_cmdline.cc,1.4,1.5 dlg_module.cc,1.6,1.7 dlg_module.h,1.6,1.7 dlg_module_entry.h,1.3,1.4 gui_dlgedit.cc,1.5,1.6 gui_settings.cc,1.6,1.7 gui_settings.h,1.4,1.5
Date: Mon, 21 Oct 2002 16:10:33 -0400

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

Modified Files:
        cfg_data.cc cfg_data.h cfg_project.cc cfg_project.h 
        dlg_cmdline.cc dlg_module.cc dlg_module.h dlg_module_entry.h 
        gui_dlgedit.cc gui_settings.cc gui_settings.h 
Log Message:
ADDED backend to Settings dialog
ADDED 'Apply' button to Settings dialog
FIXED bugs with '-j' and '-p' command line options


Index: cfg_data.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/cfg_data.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** cfg_data.cc 20 Oct 2002 20:22:57 -0000      1.2
--- cfg_data.cc 21 Oct 2002 20:10:30 -0000      1.3
***************
*** 24,30 ****
--- 24,44 ----
  #include "cfg_data.h"
  
+ /**
+  * Global access to the dlgedit configuration
+  */
+ CfgData* CfgData::data = NULL;
+ 
+ // ctor
+ CfgData::CfgData ()
+ {
+     // make this configuration globally available
+     data = this;
+ }
+ 
  // dtor
  CfgData::~CfgData ()
  {
+     data = NULL;
+     
      // delete all projects
      for (std::vector<CfgProject*>::iterator i = Projects.begin (); i != 
Projects.end (); i++)
***************
*** 78,81 ****
--- 92,127 ----
          else delete p;
      }
+ }
+ 
+ // get basedir associated with a certain project
+ std::string CfgData::getBasedir (const std::string & project)
+ {
+     std::vector<CfgProject*>::iterator i;
+ 
+     // try to locate project
+     for (i = Projects.begin (); i != Projects.end (); i++)
+         if ((*i)->name () == project)
+             return (*i)->basedir ();
+ 
+     return "";
+ }
+ 
+ // set basedir of a certain project
+ void CfgData::setBasedir (const std::string & project, const std::string & 
basedir)
+ {
+     std::vector<CfgProject*>::iterator i;
+ 
+     // try to locate project
+     for (i = Projects.begin (); i != Projects.end (); i++)
+         if ((*i)->name () == project)
+         {
+             (*i)->setBasedir (basedir);
+             return;
+         }
+ 
+     // project does not exist, so create it
+     CfgProject *p = new CfgProject (project);
+     p->setBasedir (basedir);
+     Projects.push_back (p);
  }
  

Index: cfg_data.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/cfg_data.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** cfg_data.h  17 Oct 2002 20:42:59 -0000      1.1
--- cfg_data.h  21 Oct 2002 20:10:30 -0000      1.2
***************
*** 40,43 ****
--- 40,47 ----
  public:
      /**
+      * Constructor. Initialize global CfgData::data pointer.
+      */
+     CfgData ();
+     /**
       * Destructor. Delete all Project entries.
       */
***************
*** 58,61 ****
--- 62,80 ----
       */
      void addProject (std::string & project);
+ 
+     /**
+      * Assign a (new) base directory to the given project. If no
+      * such project exists yet, it will be created.
+      * @param project name of the project to modify/create.
+      * @param basedir directory to assign to this project.
+      */
+     void setBasedir (const std::string & project, const std::string & 
basedir);
+     /**
+      * Return the base directory associated with a given project.
+      * In case there is no such project, or no basedir assigned,
+      * return "" (the empty string).
+      */    
+     std::string getBasedir (const std::string & project);
+     
      /**
       * Save data to disk.
***************
*** 64,67 ****
--- 83,91 ----
      void save (ofstream & file);
      
+     /**
+      * Global access to the dlgedit configuration
+      */
+     static CfgData *data;
+ 
  private:
      std::deque <std::string> Files;         // list of previously opened files

Index: cfg_project.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/cfg_project.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** cfg_project.cc      17 Oct 2002 20:42:59 -0000      1.1
--- cfg_project.cc      21 Oct 2002 20:10:30 -0000      1.2
***************
*** 26,30 ****
  
  // ctor
! CfgProject::CfgProject (std::string &name)
  {
      Name = name;
--- 26,30 ----
  
  // ctor
! CfgProject::CfgProject (std::string name)
  {
      Name = name;
***************
*** 62,66 ****
  void CfgProject::save (ofstream &out)
  {
!     out << "Project [" << Name << "]\n"
          << "  BaseDir [" << BaseDir << "]\n"
          << "End" << endl;
--- 62,66 ----
  void CfgProject::save (ofstream &out)
  {
!     out << "\nProject [" << Name << "]\n"
          << "  BaseDir [" << BaseDir << "]\n"
          << "End" << endl;

Index: cfg_project.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/cfg_project.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** cfg_project.h       20 Oct 2002 20:22:57 -0000      1.2
--- cfg_project.h       21 Oct 2002 20:10:30 -0000      1.3
***************
*** 38,42 ****
       * @param name The name, or id, of the project.
       */
!     CfgProject (std::string &name);
  
      /**
--- 38,42 ----
       * @param name The name, or id, of the project.
       */
!     CfgProject (std::string name);
  
      /**
***************
*** 56,60 ****
       * @return name (id) of the project
       */
!     std::string name ()             { return Name; }
      
  private:
--- 56,75 ----
       * @return name (id) of the project
       */
!     std::string name ()                 { return Name; }
! 
!     /**
!      * Get the project's basedir
!      * @return basedir of the project.
!      */
!     std::string basedir ()              { return BaseDir; }
! 
!     /**
!      * Assign a base directory to the project. This is the
!      * root of the dialogue sources belonging to this project.
!      * When working with subdialogues, they will be adressed
!      * relative to the base directory.
!      * @param d the new base directory for this project.
!      */
!     void setBasedir (std::string d)     { BaseDir = d; }
      
  private:

Index: dlg_cmdline.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/dlg_cmdline.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** dlg_cmdline.cc      13 Oct 2002 20:37:45 -0000      1.4
--- dlg_cmdline.cc      21 Oct 2002 20:10:30 -0000      1.5
***************
*** 43,47 ****
      
      // Check for options
!     while ((c = getopt (argc, argv, "cdhvg:j:")) != -1)
      {
          switch (c)
--- 43,47 ----
      
      // Check for options
!     while ((c = getopt (argc, argv, "cdhvp:j:")) != -1)
      {
          switch (c)
***************
*** 71,75 ****
              }
              
!             case 'g':
              {
                  datadir = optarg;
--- 71,75 ----
              }
              
!             case 'p':
              {
                  datadir = optarg;

Index: dlg_module.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/dlg_module.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** dlg_module.cc       12 Oct 2002 18:51:33 -0000      1.6
--- dlg_module.cc       21 Oct 2002 20:10:30 -0000      1.7
***************
*** 29,33 ****
  DlgModule::DlgModule (std::string p, std::string n, std::string s, 
std::string d)
  {
!     description_ = d;
      serial_ = s;
      path_ = p + "/";
--- 29,33 ----
  DlgModule::DlgModule (std::string p, std::string n, std::string s, 
std::string d)
  {
!     entry_.setDescription (d);
      serial_ = s;
      path_ = p + "/";
***************
*** 207,211 ****
              case LOAD_NOTE:
              {
!                 if (parse_dlgfile (s, n) == LOAD_STR) description_ = s;
                  break;
              }
--- 207,211 ----
              case LOAD_NOTE:
              {
!                 if (parse_dlgfile (s, n) == LOAD_STR) entry_.setDescription 
(s);
                  break;
              }
***************
*** 298,302 ****
          << "# (C) 2000/2001/2002 Kai Sterker\n#\n"
          << "# $I" << "d$\n\n"
!         << "Note §" << description_ << "§\n\n";
  
      // Node ID
--- 298,302 ----
          << "# (C) 2000/2001/2002 Kai Sterker\n#\n"
          << "# $I" << "d$\n\n"
!         << "Note §" << entry_.description () << "§\n\n";
  
      // Node ID

Index: dlg_module.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/dlg_module.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** dlg_module.h        14 Oct 2002 17:34:32 -0000      1.6
--- dlg_module.h        21 Oct 2002 20:10:30 -0000      1.7
***************
*** 210,214 ****
      std::string path_;          // Path of the dialogue
      std::string serial_;        // Unique number of the dialogue
-     std::string description_;   // Description of the dialogue
      
      DlgModuleEntry entry_;      // further content of the dialogue
--- 210,213 ----

Index: dlg_module_entry.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/dlg_module_entry.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** dlg_module_entry.h  26 Apr 2002 20:20:10 -0000      1.3
--- dlg_module_entry.h  21 Oct 2002 20:10:30 -0000      1.4
***************
*** 45,48 ****
--- 45,53 ----
      std::string project ()          { return project_; }
      /**
+      * Get the description of this module.
+      * @return the module's description.
+      */
+     std::string description ()      { return description_; }
+     /**
       * Get the import statements assigned to this module.
       * @return the module's additional imports.
***************
*** 72,76 ****
       */
      bool setProject (std::string p);
! 
      /**
       * Set the import statements assigned to this module.
--- 77,86 ----
       */
      bool setProject (std::string p);
!     
!     /**
!      * Set the description of this module.
!      * @param d some text describing the module.
!      */
!     void setDescription (std::string d) { description_ = d; }
      /**
       * Set the import statements assigned to this module.
***************
*** 133,136 ****
--- 143,147 ----
      std::string dtor_;              // destructor code
      std::string methods_;           // user defined methods
+     std::string description_;       // Description of the dialogue
      
      std::vector<std::string> characters;

Index: gui_dlgedit.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_dlgedit.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** gui_dlgedit.cc      12 Oct 2002 18:51:33 -0000      1.5
--- gui_dlgedit.cc      21 Oct 2002 20:10:30 -0000      1.6
***************
*** 32,35 ****
--- 32,36 ----
  #include <stdio.h>
  #include "gettext.h"
+ #include "dlg_cmdline.h"
  #include "dlg_compiler.h"
  #include "gui_code.h"
***************
*** 666,669 ****
--- 667,673 ----
      DlgModule *dlg = new DlgModule (directory_, name, serial, "New Dialogue");
  
+     // set project if dlgedit started with '-j' option
+     dlg->entry()->setProject (DlgCmdline::project);
+     
      // insert into the list of open dialogues
      dialogues_.push_back (dlg);

Index: gui_settings.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_settings.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** gui_settings.cc     20 Oct 2002 20:22:57 -0000      1.6
--- gui_settings.cc     21 Oct 2002 20:10:30 -0000      1.7
***************
*** 22,26 ****
--- 22,29 ----
  #include <gtk/gtk.h>
  #include <sys/stat.h>
+ #include <dirent.h>
  #include <iostream>
+ #include "cfg_data.h"
+ #include "dlg_cmdline.h"
  #include "gui_file.h"
  #include "gui_dlgedit.h"
***************
*** 30,63 ****
  GuiSettings * GuiSettings::dialog = NULL;
  
  // browse the harddisk for a project
  void on_browse_basedir_clicked (GtkButton * button, gpointer user_data)
  {
!     GuiFile fs (LOAD, "Select project directory", DATA_DIR "/games/");
  
      // File selection closed with OK
      if (fs.run ())
      {
          // check if we have a directory
          struct stat statbuf;
-         std::string file = fs.getSelection ();
          stat (file.c_str (), &statbuf);
  
          if (S_ISDIR (statbuf.st_mode))
          {
!             // extract the projectname from the directory
!             GtkEntry *entry = (GtkEntry *) user_data;
!             unsigned int pos, len = file.length () - 1;
! 
!             if (file[len] == '/')
!             {
!                 pos = file.rfind ('/', len - 1) + 1;
!                 gtk_entry_set_text (entry, file.substr (pos, len - pos).c_str 
());
!             }
!             else
!             {
!                 pos = file.rfind ('/') + 1;
!                 gtk_entry_set_text (entry, file.substr (pos).c_str ());
!             }
          }
      }
  }
--- 33,82 ----
  GuiSettings * GuiSettings::dialog = NULL;
  
+ // the project selection has changed
+ void on_project_changed (GtkMenuItem *menuitem, gpointer user_data)
+ {
+     // read project from selected item
+     std::string project = (char *) gtk_object_get_user_data (GTK_OBJECT 
(menuitem));
+ 
+     // set project basedir accordingly
+     GuiSettings *settings = (GuiSettings *) user_data;
+     settings->setBasedir (project);
+ }
+ 
  // browse the harddisk for a project
  void on_browse_basedir_clicked (GtkButton * button, gpointer user_data)
  {
!     // if a project root exists, use that in file selector
!     std::string dir = CfgData::data->getBasedir 
(GuiSettings::dialog->getProject ());
! 
!     // otherwise revert to directory last opened
!     if (dir == "") dir = GuiDlgedit::window->directory ();
!     
!     GuiFile fs (LOAD, "Select base directory", dir + "/");
  
      // File selection closed with OK
      if (fs.run ())
      {
+         GtkEntry *entry = (GtkEntry *) user_data;
+         std::string file = fs.getSelection ();
+         unsigned int len = file.length () - 1;
+ 
          // check if we have a directory
          struct stat statbuf;
          stat (file.c_str (), &statbuf);
  
          if (S_ISDIR (statbuf.st_mode))
          {
!             // have a directory
!             gtk_entry_set_text (entry, file.substr (0, len).c_str ());
!         }
!         else
!         {
!             // extract directory from file name
!             unsigned int pos = file.rfind ('/');
!             gtk_entry_set_text (entry, file.substr (0, pos).c_str ());
          }
+ 
+         gtk_entry_set_position (entry, -1);
      }
  }
***************
*** 70,73 ****
--- 89,98 ----
  }
  
+ // Apply button pressed
+ void on_apply_button_clicked (GtkButton * button, gpointer user_data)
+ {
+     GuiSettings::dialog->applyChanges ();
+ }
+ 
  // callback for closing the window
  void on_close_settings (GtkButton * button, gpointer user_data)
***************
*** 128,132 ****
      gtk_container_set_border_width (GTK_CONTAINER (table), 4);
      gtk_table_set_col_spacings (GTK_TABLE (table), 8);
! 
      // project
      label = gtk_label_new ("Project");
--- 153,158 ----
      gtk_container_set_border_width (GTK_CONTAINER (table), 4);
      gtk_table_set_col_spacings (GTK_TABLE (table), 8);
!     gtk_table_set_row_spacings (GTK_TABLE (table), 4);
!     
      // project
      label = gtk_label_new ("Project");
***************
*** 162,166 ****
--- 188,194 ----
      gtk_tooltips_set_tip (tooltips, description, "Here goes a description of 
the dialogue", NULL);
      gtk_text_set_editable (GTK_TEXT (description), TRUE);
+     gtk_text_set_word_wrap (GTK_TEXT (description), TRUE);
  
+     // project selection
      project = gtk_option_menu_new ();
      gtk_widget_ref (project);
***************
*** 170,174 ****
      gtk_tooltips_set_tip (tooltips, project, "The project this dialogue 
belongs to", NULL);
      project_menu = gtk_menu_new ();
!     gtk_option_menu_set_menu (GTK_OPTION_MENU (project), project_menu);
  
      frame = gtk_frame_new ("Project Settings");
--- 198,204 ----
      gtk_tooltips_set_tip (tooltips, project, "The project this dialogue 
belongs to", NULL);
      project_menu = gtk_menu_new ();
!     
!     // add available projects to list
!     populateProjects (project_menu);
  
      frame = gtk_frame_new ("Project Settings");
***************
*** 235,238 ****
--- 265,276 ----
      gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC 
(on_close_settings), NULL);
  
+     button = gtk_button_new_with_label ("Apply");
+     gtk_widget_ref (button);
+     gtk_object_set_data_full (GTK_OBJECT (window), "button", button, 
(GtkDestroyNotify) gtk_widget_unref);
+     gtk_widget_show (button);
+     gtk_container_add (GTK_CONTAINER (hbuttonbox), button);
+     GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+     gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC 
(on_apply_button_clicked), this);
+ 
      button = gtk_button_new_with_label ("OK");
      gtk_widget_ref (button);
***************
*** 267,271 ****
  
          // display the contents of the module
!         // gtk_entry_set_text (GTK_ENTRY (project), entry->project ().c_str 
());
      }
  
--- 305,311 ----
  
          // display the contents of the module
!         setProject (entry->project ());
!         setDescription (entry->description());
!         
      }
  
***************
*** 281,285 ****
  void GuiSettings::applyChanges ()
  {
!     if (!entry->setProject (gtk_entry_get_text (GTK_ENTRY (project))))
          std::cout << "Loading quests/characters failed!\n";
  }
--- 321,483 ----
  void GuiSettings::applyChanges ()
  {
!     // project
!     std::string project = getProject ();
!     if (project != "none" && !entry->setProject (project))
          std::cout << "Loading quests/characters failed!\n";
+ 
+     // description
+     entry->setDescription (getDescription ());
+ 
+     // basedir
+     if (project != "none") 
+         CfgData::data->setBasedir (project, getBasedir ());
+ }
+ 
+ // returns selected option
+ std::string GuiSettings::getProject ()
+ {
+     GtkMenu *m = (GtkMenu *) gtk_option_menu_get_menu (GTK_OPTION_MENU 
(project));
+     GtkMenuItem *i = (GtkMenuItem *) gtk_menu_get_active (m);
+     char *s = (char *) gtk_object_get_user_data (GTK_OBJECT (i));
+ 
+     return s ? s : "none";
+ }
+ 
+ // sets a default option
+ void GuiSettings::setProject (const std::string & label)
+ {
+     GtkMenu *m = (GtkMenu *) gtk_option_menu_get_menu (GTK_OPTION_MENU 
(project));
+     GList *l = gtk_container_children (GTK_CONTAINER (m));                    
+     char* c;
+     int j = 0;
+ 
+     while (l)
+     {
+         GtkMenuItem *i = (GtkMenuItem *) l->data;
+         c = (char *) gtk_object_get_user_data (GTK_OBJECT (i));
+ 
+         if (c && strcmp (c, label.c_str ()) == 0)
+         {
+             // found our entry -> set as default and return
+             gtk_option_menu_set_history (GTK_OPTION_MENU (project), j);
+ 
+             // update base directory
+             setBasedir (label);
+             
+             return;
+         }
+ 
+         j++;
+         l = g_list_next (l);
+     }
+ 
+     if (label != "")
+     {
+         // that project is not available yet, so add it
+         GtkWidget *menuitem = gtk_menu_item_new_with_label (label.c_str ());
+         gtk_object_set_user_data (GTK_OBJECT (menuitem), (void *) strdup 
(label.c_str ()));
+         gtk_signal_connect (GTK_OBJECT (menuitem), "activate", 
GTK_SIGNAL_FUNC (on_project_changed), (gpointer) this);
+         gtk_widget_show (menuitem);
+ 
+         gtk_menu_insert (GTK_MENU (m), menuitem, 0);
+         gtk_option_menu_set_history (GTK_OPTION_MENU (project), 0);
+ 
+         // update base directory
+         setBasedir (label);
+     }
+     else setProject ("none");
+ }
+ 
+ // set the module's description
+ void GuiSettings::setDescription (const std::string & desc)
+ {
+     int pos = 0;
+     
+     gtk_text_freeze (GTK_TEXT (description));
+     
+     gtk_editable_delete_text (GTK_EDITABLE (description), 0, 
gtk_text_get_length (GTK_TEXT (description)));
+     gtk_editable_insert_text (GTK_EDITABLE (description), desc.c_str (), 
desc.length (), &pos);
+     gtk_editable_set_position (GTK_EDITABLE (description), pos);
+ 
+     gtk_text_thaw (GTK_TEXT (description));
+ }                                 
+ 
+ // get the module's description
+ std::string GuiSettings::getDescription ()
+ {
+     return gtk_editable_get_chars (GTK_EDITABLE (description), 0, -1);
+ }
+ 
+ // set project base directory
+ void GuiSettings::setBasedir (const std::string & project)
+ {
+     // do nothing for project "none"
+     if (project == "none")
+     {
+         gtk_entry_set_text (GTK_ENTRY (basedir), "");
+         return;       
+     }
+     
+     // get base directory of given project from config file
+     std::string dir = CfgData::data->getBasedir (project);
+ 
+     // update the entry
+     gtk_entry_set_text (GTK_ENTRY (basedir), dir.c_str ());
+     gtk_entry_set_position (GTK_ENTRY (basedir), -1);                         
                    
+ }
+ 
+ // get project base directory
+ std::string GuiSettings::getBasedir ()
+ {
+     return gtk_entry_get_text (GTK_ENTRY (basedir));
+ }
+ 
+ // add available projects to list
+ void GuiSettings::populateProjects (GtkWidget *menu)
+ {
+     struct dirent * d;
+     struct stat statbuf;
+     GtkWidget *menuitem;
+     DIR * mydir = opendir (DlgCmdline::datadir.c_str());
+     std::string name, filename, path = DlgCmdline::datadir + "/";
+ 
+     // project 'none'
+     menuitem = gtk_menu_item_new_with_label ("none");
+     gtk_object_set_user_data (GTK_OBJECT (menuitem), (void *) "none");
+     gtk_signal_connect (GTK_OBJECT (menuitem), "activate", GTK_SIGNAL_FUNC 
(on_project_changed), (gpointer) this);
+     gtk_widget_show (menuitem);
+     gtk_menu_append (GTK_MENU (menu), menuitem);
+ 
+     // no such directory
+     if (!mydir) return;
+     
+     // get all directories inside
+     while ((d = readdir (mydir)) != NULL)
+     {
+         name = d->d_name;
+         filename = path + name;
+ 
+         // ignore '.' and '..' directories
+         if (name != "." && name != "..")
+         {
+             stat (filename.c_str (), &statbuf);
+             
+             // fill list with valid entries
+             if (S_ISDIR (statbuf.st_mode))
+             {
+                 menuitem = gtk_menu_item_new_with_label (name.c_str ());
+                 gtk_object_set_user_data (GTK_OBJECT (menuitem), (void *) 
strdup (name.c_str ()));
+                 gtk_signal_connect (GTK_OBJECT (menuitem), "activate", 
GTK_SIGNAL_FUNC (on_project_changed), (gpointer) this);
+                 gtk_widget_show (menuitem);
+ 
+                 gtk_menu_append (GTK_MENU (menu), menuitem);
+             }
+         }
+     }
+ 
+     // finally append menu to drop-down list
+     gtk_option_menu_set_menu (GTK_OPTION_MENU (project), menu);
+ 
+     // cleanup
+     closedir (mydir);
  }

Index: gui_settings.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/tools/dlgedit/gui_settings.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** gui_settings.h      20 Oct 2002 20:22:57 -0000      1.4
--- gui_settings.h      21 Oct 2002 20:10:30 -0000      1.5
***************
*** 27,32 ****
  
  /**
!  * Interface to various generic dialogue settings, like the project it belongs
!  * to or the NPC it will be attached to. Most of these settings are optional.
   */
  class GuiSettings
--- 27,35 ----
  
  /**
!  * Interface to various generic dialogue and project settings. Currently this
!  * includes
!  * - the project of the dialogue
!  * - the dialogue's description
!  * - the base directory of the above project
   */
  class GuiSettings
***************
*** 60,64 ****
--- 63,115 ----
      void applyChanges ();
  
+     /**
+      * @name Member access
+      */
+     //@{}
+     /**
+      * Set the base directory according to selected project. Call this
+      * method whenever the user assigns a different project.
+      * @param project the name of the selected project.
+      */
+     void setBasedir (const std::string & project);
+     /**
+      * Return the basedir associated with the selected project.
+      * @return The basedir of the selected project.
+      */
+     std::string getBasedir ();
+     /**
+      * Set the project list to the project the module is assigned to.
+      * If that module is not in the list yet, it will be added.
+      * @param project name of the module's project.
+      */
+     void setProject (const std::string & project);
+     /**
+      * Return the project the user has selected in the list.
+      * @return The name of the selected project.
+      */
+     std::string getProject ();
+     //@}
+     
  private:
+     /**
+      * Display the module's description. The text area is cleared
+      * if neccessary.
+      * @param desc the module's description.
+      */
+     void setDescription (const std::string & desc);
+     /**
+      * Get the Description the user has entered for the module.
+      * @return the module's description.
+      */
+     std::string getDescription ();
+ 
+     /**
+      * Read available projects from DlgCmdline::datadir and add
+      * them to the project list. Also add the "none" entry for
+      * modules that do not belong to a project yet.
+      * @param the menu widget of the drop-down list. 
+      */
+     void populateProjects (GtkWidget *menu);
+ 
      DlgModuleEntry *entry;  // The module's settings
      GtkWidget *window;      // The dialog window





reply via email to

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