gxsm_menucb.C

Go to the documentation of this file.
00001 /* Gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  * 
00005  * Copyright (C) 1999,2000,2001,2002,2003 Percy Zahl
00006  *
00007  * Authors: Percy Zahl <zahl@users.sf.net>
00008  * additional features: Andreas Klust <klust@users.sf.net>
00009  * WWW Home: http://gxsm.sf.net
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00024  */
00025 
00026 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&R" -*- */
00027 
00028 #include <config.h>
00029 #include <libgnome/libgnome.h>
00030 
00031 #include <gdk/gdk.h>
00032 #include "gnome-res.h"
00033 
00034 #include "gxsm_app.h"
00035 
00036 //#include "app_remote.h"
00037 //#include "app_mkicons.h"
00038 
00039 #include "dataio.h"
00040 #include "util.h"
00041 #include "version.h"
00042 #include "glbvars.h"
00043 
00044 #include "gxsm_resoucetable.h"
00045 
00046 #include "action_id.h"
00047 
00048 #include "tips_dialog.h"
00049 
00050 /* File ================================================== */
00051 
00052 void App::file_open_callback (GtkWidget *widget, void *data){
00053         if(!gapp) return;
00054         gapp->xsm->load();
00055         return;
00056 }
00057 
00058 void App::file_open_in_new_window_callback (GtkWidget *widget, void *data){
00059         if(!gapp) return;
00060         if(!gapp->xsm->ActivateFreeChannel())
00061                 gapp->xsm->load();
00062         return;
00063 }
00064 
00065 void App::file_browse_callback (GtkWidget *widget, void *data){
00066         if(!gapp) return;
00067         gapp->file_dialog (
00068                 N_("DAT/NC/HDF file to load"), NULL, 
00069                 "*.[nNdDsSh][cCaApPd]*", NULL, "browseload",
00070                 (GappBrowseFunc) App::browse_callback, 
00071                 (gpointer) gapp);
00072         return;
00073 }
00074 
00075 void App::browse_callback(gchar *selection, App* ap){ 
00076         if(!gapp) return;
00077         XSM_DEBUG(DBG_L2, "browsed:" << selection );
00078         if(selection)
00079                 ap->xsm->load(selection);
00080 }
00081 
00082 void App::file_save_callback (GtkWidget *widget, void *data){
00083         if(!gapp) return;
00084         gapp->xsm->save(TRUE);
00085         return;
00086 }
00087 
00088 void App::file_save_as_callback (GtkWidget *widget, void *data){
00089         if(!gapp) return;
00090         gapp->xsm->save(FALSE);
00091         return;
00092 }
00093 
00094 void App::file_print_callback (GtkWidget *widget, void *data){
00095         if (gapp->PluginCallPrinter)
00096                 (*gapp->PluginCallPrinter) (widget, data);
00097         else
00098                 gapp->message(N_("Sorry, no 'Printer' plugin loaded!"));
00099         return;
00100 }
00101 
00102 void App::file_close_callback (GtkWidget *widget, void *data){
00103         //  gapp->xsm->??
00104         return;
00105 }
00106 
00107 
00108 int App::file_exit_callback (GtkWidget *widget, void *data){
00109         if(!gapp) return TRUE;
00110         if(gapp->question(Q_WANTQUIT, TRUE) == 1){
00111                 // Destroy local allocated static objects:
00112                 App::file_print_callback(NULL, NULL);
00113                 App::tools_mkicons_callback (NULL, NULL);
00114 //              App::tools_remote_callback (NULL, NULL);
00115                 // and good by...
00116                 gtk_main_quit ();
00117                 return FALSE;
00118         }
00119         return TRUE;
00120 }
00121 
00122 /* Edit ================================================== */
00123 
00124 void App::edit_crop_callback (GtkWidget *widget, void *data){
00125         if(!gapp) return;
00126         gapp->xsm->MathOperation(CropScan);
00127         return;
00128 }
00129 
00130 void App::edit_copy_callback (GtkWidget *widget, void *data){
00131         if(!gapp) return;
00132         gapp->xsm->MathOperation(CopyScan);
00133         return;
00134 }
00135 
00136 /* Action ================================================== */
00137 
00138 
00139 void App::action_toolbar_callback (GtkWidget *widget, void *data){
00140         GtkWidget *w;
00141         if ((w = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (gapp->app), (const gchar*) data))){
00142                 gtk_object_set_data( GTK_OBJECT (w), "ToolbarButton", widget);
00143                 gtk_signal_emit_by_name (GTK_OBJECT (w), "pressed" );
00144         } else
00145                 XSM_DEBUG(DBG_L2, "no Toolbar Plugin " << (const gchar*) data << " Registerd!" );
00146 }
00147 
00148 /* View ================================================== */
00149 
00150 void App::view_autodisp_callback (GtkWidget *widget, void *data){
00151         if(!gapp) return;
00152         gapp->xsm->AutoDisplay();
00153         return;
00154 }
00155 
00156 void App::view_autozoom_callback (GtkWidget *widget, void *data){
00157         if(!gapp) return;
00158         if (GTK_CHECK_MENU_ITEM (widget)->active)
00159                 SET_FLAG(gapp->xsm->ZoomFlg, VIEW_ZOOM);
00160         else
00161                 CLR_FLAG(gapp->xsm->ZoomFlg, VIEW_ZOOM);
00162         return;
00163 }
00164 
00165 void App::view_tolerant_callback (GtkWidget *widget, void *data){
00166         if(!gapp) return;
00167         if (GTK_CHECK_MENU_ITEM (widget)->active){
00168                 SET_FLAG(gapp->xsm->ZoomFlg, VIEW_TOLERANT);
00169         }else{
00170                 CLR_FLAG(gapp->xsm->ZoomFlg, VIEW_TOLERANT);
00171         }
00172         return;
00173 }
00174 
00175 void App::view_palette_callback (GtkWidget *widget, void *data){
00176         if(!gapp) return;
00177         if (GTK_CHECK_MENU_ITEM (widget)->active){
00178                 SET_FLAG(gapp->xsm->ZoomFlg, VIEW_PALETTE);
00179                 SET_FLAG(gapp->xsm->ZoomFlg, VIEW_COLOR);
00180         }else{
00181                 CLR_FLAG(gapp->xsm->ZoomFlg, VIEW_PALETTE);
00182                 CLR_FLAG(gapp->xsm->ZoomFlg, VIEW_COLOR);
00183         }
00184         return;
00185 }
00186 
00187 void App::view_zoom_in_callback (GtkWidget *widget, void *data){
00188         gapp->xsm->MathOperation(ZoomInScan);
00189         return;
00190 }
00191 
00192 void App::view_zoom_out_callback (GtkWidget *widget, void *data){
00193         gapp->xsm->MathOperation(ZoomOutScan);
00194         return;
00195 }
00196 
00197 /* Math, Filter, ... ================================================== */
00198 
00199 void App::math_onearg_nodest_callback (GtkWidget *widget, gboolean (*MOp)(MATHOPPARAMSNODEST)){
00200         gapp->xsm->MathOperationNoDest(MOp);
00201         return;
00202 }
00203 
00204 void App::math_onearg_callback (GtkWidget *widget, gboolean (*MOp)(MATHOPPARAMS)){
00205         gapp->xsm->MathOperation(MOp);
00206         return;
00207 }
00208 
00209 void App::math_twoarg_callback (GtkWidget *widget, gboolean (*MOp)(MATH2OPPARAMS)){
00210         gapp->xsm->MathOperationX(MOp, ID_CH_M_X, TRUE);
00211         return;
00212 }
00213 
00214 void App::math_twoarg_no_same_size_check_callback (GtkWidget *widget, gboolean (*MOp)(MATH2OPPARAMS)){
00215         gapp->xsm->MathOperationX(MOp, ID_CH_M_X, FALSE);
00216         return;
00217 }
00218 
00219 /* Tools ================================================== */
00220 
00221 void App::tools_monitor_callback (GtkWidget *widget, void *data){
00222         gapp->monitorcontrol->show();
00223         return;
00224 }
00225 
00226 // void App::tools_remote_callback (GtkWidget *widget, void *data){
00227 //      if (gapp->PluginCallRemote)
00228 //              (*gapp->PluginCallRemote) (widget, data);
00229 //      else
00230 //              gapp->message(N_("Sorry, no 'pyremote' plugin loaded!"));
00231 //      return;
00232 // }
00233 
00234 void App::tools_chanselwin_callback (GtkWidget *widget, void *data){
00235         gapp->channelselector->show();
00236         return;
00237 }
00238 
00239 void App::tools_mkicons_callback (GtkWidget *widget, void *data){
00240         if (gapp->PluginCallMkicons)
00241                 (*gapp->PluginCallMkicons) (widget, data);
00242         else
00243                 gapp->message(N_("Sorry, no 'Mkicons' plugin loaded!"));
00244         return;
00245 }
00246 
00247 void App::tools_plugin_reload_callback (GtkWidget *widget, void *data){
00248         gapp->reload_gxsm_plugins();
00249         return;
00250 }
00251 
00252 void App::tools_plugin_info_callback (GtkWidget *widget, void *data){
00253         if(gapp){
00254                 if(gapp->GxsmPlugins)
00255                         gapp->GxsmPlugins->view_pi_info();
00256                 else
00257                         gapp->message(N_("No Plugins loaded!"));
00258         }
00259         return;
00260 }
00261 
00262 /* Options ================================================== */
00263 
00264 void App::options_preferences_callback (GtkWidget *widget, void *data){
00265         gxsm_search_for_palette();
00266         gxsm_search_for_HwI();
00267         GnomeResPreferences *pref = gnome_res_preferences_new (xsm_res_def);
00268         gnome_res_read_user_config (pref);
00269         gnome_res_run_change_user_config (pref, N_("Gxsm Preferences")); 
00270 // on Dlg close pref is destroyed!
00271         return;
00272 }
00273 
00274 void App::options_save_geometry_callback (GtkWidget *widget, void *data){
00275         //  gapp->xsm->savegeometry();
00276         return;
00277 }
00278 
00279 void App::options_save_preferences_callback (GtkWidget *widget, void *data){
00280         return;
00281 }
00282 void App::options_load_preferences_callback (GtkWidget *widget, void *data){
00283         return;
00284 }
00285 
00286 void App::options_save_values_callback (GtkWidget *widget, void *data){
00287         if (data)
00288                 gapp->xsm->data.SaveValues((gchar*) data);
00289         else    
00290                 gapp->xsm->data.SaveValues();
00291         return;
00292 }
00293 void App::options_load_values_callback (GtkWidget *widget, void *data){
00294         if (data)
00295                 gapp->xsm->data.LoadValues(gapp->xsm->Inst, gapp->xsm->hardware, (gchar*) data);
00296         else
00297                 gapp->xsm->data.LoadValues(gapp->xsm->Inst, gapp->xsm->hardware);
00298         return;
00299 }
00300 
00301 /* Help ================================================== */
00302 void App::help_license_callback (GtkWidget *widget, void *data){
00303         gapp->message(N_(
00304                          "GXSM - Gnome X Scanning Microscopy\n"
00305                          "universal STM/AFM/SARLS/SPALEED/... controlling and\n"
00306                          "data analysis software\n"
00307                          "\n"
00308                          "Copyright (C) 1999-2003 Percy Zahl\n"
00309                          "\n"
00310                          "Authors: Percy Zahl <zahl@users.sf.net>\n"
00311                          "additional features: Andreas Klust <klust@users.sf.net>\n"
00312                          "WWW Home: http://gxsm.sourceforge.net\n"
00313                          "\n"
00314                          "This program is free software; you can redistribute it and/or modify\n"
00315                          "it under the terms of the GNU General Public License as published by\n"
00316                          "the Free Software Foundation; either version 2 of the License, or\n"
00317                          "(at your option) any later version.\n"
00318                          "\n"
00319                          "This program is distributed in the hope that it will be useful,\n"
00320                          "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
00321                          "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
00322                          "GNU General Public License for more details.\n"
00323                          "\n"
00324                          "You should have received a copy of the GNU General Public License\n"
00325                          "along with this program; if not, write to the Free Software\n"
00326                          "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.\n"
00327                          "\n"
00328                          "Online at http://www.gnu.org/copyleft/gpl.html\n"
00329                          ));
00330 }
00331 
00332 /* Help ================================================== */
00333 void App::help_about_callback (GtkWidget *widget, void *data){
00334         GtkWidget *about;
00335         gchar *message;
00336         const gchar *authors[] = {
00337                 /* Here should be your names */
00338                 "Percy Zahl  (zahl@users.sourceforge.net)",
00339                 "Andreas Klust  (klust@users.sourceforge.net)",
00340                 "Stefan Schroeder  (stefan_fkp@users.sourceforge.net)",
00341                 "Juan de la Figuera  (johnnybegood@users.sourceforge.net)",
00342                 "and others http://gxsm.sourceforge.net",
00343                 NULL
00344         };
00345         
00346         const gchar *documenters[] = {
00347                 /* Here should be the documenters names */
00348                 "Percy Zahl",
00349                 "Andreas Klust",
00350                 "Stefan Schroeder",
00351                 NULL
00352         };
00353         
00354 #ifdef XSM_DEBUG_OPTION
00355         gchar *dbg_lvl_tmp = g_strdup_printf ("\n\nGXSM / PlugIn debug level is: %d/%d", debug_level, pi_debug_level);
00356 #else
00357         gchar *dbg_lvl_tmp = g_strdup_printf ("\n\nGXSM debug support is disabled.");
00358 #endif
00359 
00360         message = g_strconcat
00361                 (_("GXSM is a Universal Scanning Microscopy Data Aquisitation System "
00362                    "including general 2D Data handling and transforming "
00363                    "for Linux/X11 using a TMS320 DSP (PCI32 and Signal Ranger, ...)."
00364                    "\n\nApplications: STM, AFM, SARLS+NM, SPA-LEED"
00365                    "\n\nHardware: "),
00366                  gapp->xsm->hardware->Info(0),
00367                  dbg_lvl_tmp,
00368                  _("\n\nGxsm Package Version: "),
00369                  VERSION,
00370                  _("\n\ncompiled by "),
00371                  COMPILEDBYNAME,
00372                  _("\n\nGXSM-2 is based on Gxsm, Xxsm, pmstm, ..."),
00373                  _("\n\nThe GXSM Project: http://gxsm.sourceforge.net"),
00374                  _("\n\nSRanger/Linux Project: http://sranger.sourceforge.net"),
00375                  _("\n\nMore about GNOME: http://www.gnome.org"),
00376                  NULL);
00377 
00378         g_free (dbg_lvl_tmp);
00379 
00380         GdkPixbuf *logo = gdk_pixbuf_new_from_file (GNOME_ICONDIR"/GxsmBWlogoTransparentColor.png", NULL);
00381         about = gnome_about_new 
00382                 ( /* const gchar *Name */
00383                   _("GXSM"),
00384                   /* const gchar *Version */
00385                   VERSION,
00386                   /* const gchar *copyrigth notice */
00387                   _("Copyright (C) 1999-2003 the Free Software Foundation,\n"
00388                         " see Help->License for details."),
00389                   /* const gchar *Comments */
00390                   message,
00391                   /* const gchar **Authors */
00392                   authors,
00393                   /* const gchar **Documenters */
00394                   documenters,
00395                   /* const gchar *Translators_credits */
00396                   "Juan de la Figuera",
00397                   /* GdkPixbuf *logo_pixbuf */
00398                   logo
00399                         );
00400         
00401         gtk_widget_show (about);
00402         g_free(message);
00403         return;
00404 }
00405 
00406 void App::help_tip_callback (GtkWidget *widget, void *data){
00407         tips_dialog_create ();
00408 }
00409 
00410 void App::help_remote_tt_callback (GtkWidget *widget, void *data){
00411         if (gapp->RemoteEntryList->data) {
00412                 if (GTK_CHECK_MENU_ITEM (widget)->active)
00413                         ((Gtk_EntryControl*)(gapp->RemoteEntryList->data))->enable_remote_pcs_tips ();
00414                 else
00415                         ((Gtk_EntryControl*)(gapp->RemoteEntryList->data))->disable_remote_pcs_tips ();
00416         }
00417 }
00418 
00419 void App::help_home_callback (GtkWidget *widget, void *data){
00420         gnome_url_show ("http://gxsm.sourceforge.net", NULL);
00421 }
00422 
00423 void App::help_manual_callback (GtkWidget *widget, void *data){
00424         gnome_url_show ("http://gxsm.sourceforge.net/Gxsm2-main.pdf", NULL);
00425 }
00426 
00427 /* Diverse CallBack Handler */
00428 
00429 gint App::close_scan_event_cb(GtkWidget *window, GdkEventAny* e, gpointer data){
00430         if(gapp->xsm->SetMode((long)gtk_object_get_data (GTK_OBJECT (window), "Ch"),ID_CH_M_OFF))
00431                 return FALSE;
00432         else
00433                 return TRUE;
00434 }

Generated on Sat Apr 1 09:03:58 2006 for GXSM by  doxygen 1.4.6