"Fossies" - the Fresh Open Source Software Archive

Member "procmeter3-3.6+svn387/gtk2/menus.c" (4 Jan 2012, 23125 Bytes) of package /linux/misc/procmeter3-3.6+svn387.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "menus.c" see the Fossies "Dox" file reference documentation.

    1 /***************************************
    2   ProcMeter - A system monitoring program for Linux - Version 3.6.
    3 
    4   X Window menus (GTK version).
    5   ******************/ /******************
    6   Written by Andrew M. Bishop
    7 
    8   This file Copyright 1998-2012 Andrew M. Bishop
    9   It may be distributed under the GNU Public License, version 2, or
   10   any higher version.  See section COPYING of the GNU Public license
   11   for conditions under which this file may be redistributed.
   12   ***************************************/
   13 
   14 
   15 #include <stdlib.h>
   16 #include <stdio.h>
   17 #include <string.h>
   18 #include <unistd.h>
   19 
   20 #include <gtk/gtk.h>
   21 
   22 #include "window.h"
   23 #include "procmeterp.h"
   24 
   25 
   26 /*+ The orientation of the windows. +*/
   27 extern int vertical;
   28 
   29 /*+ The pane that contains all of the outputs. +*/
   30 extern GtkWidget *pane;
   31 
   32 /* Local functions */
   33 
   34 static void MenuStart(GtkWidget *w,GdkEvent *event,gpointer data);
   35 static void ModuleMenuStart(GtkWidget *w,GdkEvent *event,gpointer data);
   36 static void OutputMenuStart(GtkWidget *w,GdkEvent *event,gpointer data);
   37 static void FunctionsMenuStart(GtkWidget *w,GdkEvent *event,gpointer data);
   38 
   39 static void SelectOutputMenuCallback(gpointer clientData);
   40 static void SelectFunctionsMenuCallback(gpointer clientData);
   41 
   42 static void PropertiesDialogDoneCallback(GtkWidget *w,gpointer data);
   43 static gint PropertiesDialogCloseCallback(GtkWidget *w,GdkEvent *event,gpointer data);
   44 
   45 /* Menu widgets */
   46 
   47 static GtkWidget *module_menu;
   48 static GtkWidget *functions_menu,*properties_dialog;
   49 static GtkWidget *func_run;
   50 static GtkWidget *prop_modname,*prop_moddesc,
   51                  *prop_outname,*prop_outdesc,
   52                  *prop_label,*prop_type,*prop_interval,*prop_scale;
   53 static GtkTextBuffer *prop_moddesc_text,*prop_outdesc_text;
   54 static gboolean properties_popped_up=FALSE;
   55 static gint doing_move=0;
   56 
   57 
   58 /*+ The output that was used for the Functions menu. +*/
   59 static Output function_output;
   60 
   61 
   62 /*++++++++++++++++++++++++++++++++++++++
   63   Initialise the menus.
   64 
   65   GtkWidget *parent The parent widget that the menu belongs to.
   66   ++++++++++++++++++++++++++++++++++++++*/
   67 
   68 void CreateMenus(GtkWidget *parent)
   69 {
   70  GtkWidget *menulabel;
   71  GtkWidget *menuline;
   72  GtkWidget *func_prop,*func_above,*func_below,*func_delete;
   73  GtkWidget *prop_form,*prop_form1,*prop_form2,
   74            *prop_modlabel,*prop_outlabel,
   75            *prop_lbllabel,*prop_typlabel,*prop_intlabel,*prop_scllabel,
   76            *prop_done;
   77  // char *string;
   78 
   79  /* Sort out the resources in advance. */
   80  
   81  //  if((string=GetProcMeterRC("resources","menu-foreground")))
   82  //    {XtSetArg(args[nargs],XtNforeground,StringToPixel(string));nargs++;}
   83  // 
   84  //  if((string=GetProcMeterRC("resources","menu-background")))
   85  //    {XtSetArg(args[nargs],XtNbackground,StringToPixel(string));nargs++;}
   86  // 
   87  //  if((string=GetProcMeterRC("resources","menu-font")))
   88  //    {XtSetArg(args[nargs],XtNfont,StringToFont(string));nargs++;}
   89 
   90  /* The module menu */
   91 
   92  module_menu=gtk_menu_new();
   93 
   94  menulabel=gtk_menu_item_new_with_label("Modules");
   95  gtk_widget_set_sensitive(GTK_WIDGET(menulabel),FALSE);
   96  gtk_menu_append(GTK_MENU(module_menu),menulabel);
   97  gtk_widget_show(GTK_WIDGET(menulabel));
   98 
   99  menuline=gtk_menu_item_new();
  100  gtk_menu_append(GTK_MENU(module_menu),menuline);
  101  gtk_widget_show(GTK_WIDGET(menuline));
  102 
  103  /* The functions menu */
  104 
  105  functions_menu=gtk_menu_new();
  106 
  107  menulabel=gtk_menu_item_new_with_label("Functions");
  108  gtk_widget_set_sensitive(GTK_WIDGET(menulabel),FALSE);
  109  gtk_menu_append(GTK_MENU(functions_menu),menulabel);
  110  gtk_widget_show(GTK_WIDGET(menulabel));
  111 
  112  menuline=gtk_menu_item_new();
  113  gtk_menu_append(GTK_MENU(functions_menu),menuline);
  114  gtk_widget_show(GTK_WIDGET(menuline));
  115 
  116  /* The functions menu items */
  117 
  118  func_prop=gtk_menu_item_new_with_label("Properties");
  119  gtk_menu_append(GTK_MENU(functions_menu),func_prop);
  120  gtk_widget_show(GTK_WIDGET(func_prop));
  121 
  122  gtk_signal_connect_object(GTK_OBJECT(func_prop),"activate",
  123                            GTK_SIGNAL_FUNC(SelectFunctionsMenuCallback),(gpointer)0);
  124 
  125  func_above=gtk_menu_item_new_with_label(vertical?"Move To Above":"Move To Left Of");
  126  gtk_menu_append(GTK_MENU(functions_menu),func_above);
  127  gtk_widget_show(GTK_WIDGET(func_above));
  128 
  129  gtk_signal_connect_object(GTK_OBJECT(func_above),"activate",
  130                            GTK_SIGNAL_FUNC(SelectFunctionsMenuCallback),(gpointer)1);
  131 
  132  func_below=gtk_menu_item_new_with_label(vertical?"Move To Below":"Move To Right Of");
  133  gtk_menu_append(GTK_MENU(functions_menu),func_below);
  134  gtk_widget_show(GTK_WIDGET(func_below));
  135 
  136  gtk_signal_connect_object(GTK_OBJECT(func_below),"activate",
  137                            GTK_SIGNAL_FUNC(SelectFunctionsMenuCallback),(gpointer)2);
  138 
  139  func_delete=gtk_menu_item_new_with_label("Delete");
  140  gtk_menu_append(GTK_MENU(functions_menu),func_delete);
  141  gtk_widget_show(GTK_WIDGET(func_delete));
  142 
  143  gtk_signal_connect_object(GTK_OBJECT(func_delete),"activate",
  144                            GTK_SIGNAL_FUNC(SelectFunctionsMenuCallback),(gpointer)3);
  145 
  146  func_run=gtk_menu_item_new_with_label("Run");
  147  gtk_menu_append(GTK_MENU(functions_menu),func_run);
  148  gtk_widget_show(GTK_WIDGET(func_run));
  149 
  150  gtk_signal_connect_object(GTK_OBJECT(func_run),"activate",
  151                            GTK_SIGNAL_FUNC(SelectFunctionsMenuCallback),(gpointer)4);
  152 
  153  /* The properties_dialog */
  154 
  155  properties_dialog=gtk_dialog_new();
  156  gtk_window_set_title(GTK_WINDOW(properties_dialog),"ProcMeter Properties");
  157  gtk_widget_set_usize(GTK_WIDGET(properties_dialog),300,400);
  158  gtk_window_set_resizable(GTK_WINDOW(properties_dialog),FALSE);
  159 
  160  /* The properties dialog elements. */
  161 
  162  prop_form=gtk_hbox_new(FALSE,0);
  163 
  164  prop_modlabel=gtk_label_new("Module: ");
  165  gtk_label_set_justify(GTK_LABEL(prop_modlabel),GTK_JUSTIFY_LEFT);
  166  gtk_box_pack_start(GTK_BOX(prop_form),prop_modlabel,FALSE,FALSE,0);
  167  gtk_widget_show(GTK_WIDGET(prop_modlabel));
  168 
  169  prop_modname=gtk_label_new("NNNNNNNNNNNNNNN");
  170  gtk_label_set_justify(GTK_LABEL(prop_modname),GTK_JUSTIFY_LEFT);
  171  gtk_box_pack_start(GTK_BOX(prop_form),prop_modname,FALSE,FALSE,0);
  172  gtk_widget_show(GTK_WIDGET(prop_modname));
  173 
  174  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(properties_dialog)->vbox),prop_form,FALSE,FALSE,0);
  175  gtk_widget_show(GTK_WIDGET(prop_form));
  176 
  177  prop_moddesc=gtk_text_view_new();
  178  gtk_text_view_set_editable(GTK_TEXT_VIEW(prop_moddesc),FALSE);
  179  gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(prop_moddesc),GTK_WRAP_WORD);
  180  prop_moddesc_text=gtk_text_buffer_new(NULL);
  181  gtk_text_view_set_buffer(GTK_TEXT_VIEW(prop_moddesc),GTK_TEXT_BUFFER(prop_moddesc_text));
  182  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(properties_dialog)->vbox),prop_moddesc,FALSE,FALSE,0);
  183  gtk_widget_set_usize(GTK_WIDGET(prop_moddesc),250,100);
  184  gtk_widget_show(GTK_WIDGET(prop_moddesc));
  185 
  186  prop_form=gtk_hbox_new(FALSE,0);
  187 
  188  prop_outlabel=gtk_label_new("Output: ");
  189  gtk_label_set_justify(GTK_LABEL(prop_outlabel),GTK_JUSTIFY_LEFT);
  190  gtk_box_pack_start(GTK_BOX(prop_form),prop_outlabel,FALSE,FALSE,0);
  191  gtk_widget_show(GTK_WIDGET(prop_outlabel));
  192 
  193  prop_outname=gtk_label_new("NNNNNNNNNNNNNNN");
  194  gtk_label_set_justify(GTK_LABEL(prop_outname),GTK_JUSTIFY_LEFT);
  195  gtk_box_pack_start(GTK_BOX(prop_form),prop_outname,FALSE,FALSE,0);
  196  gtk_widget_show(GTK_WIDGET(prop_outname));
  197 
  198  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(properties_dialog)->vbox),prop_form,FALSE,FALSE,0);
  199  gtk_widget_show(GTK_WIDGET(prop_form));
  200 
  201  prop_outdesc=gtk_text_view_new();
  202  gtk_text_view_set_editable(GTK_TEXT_VIEW(prop_outdesc),FALSE);
  203  gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(prop_outdesc),GTK_WRAP_WORD);
  204  prop_outdesc_text=gtk_text_buffer_new(NULL);
  205  gtk_text_view_set_buffer(GTK_TEXT_VIEW(prop_outdesc),GTK_TEXT_BUFFER(prop_outdesc_text));
  206  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(properties_dialog)->vbox),prop_outdesc,FALSE,FALSE,0);
  207  gtk_widget_set_usize(GTK_WIDGET(prop_outdesc),250,100);
  208  gtk_widget_show(GTK_WIDGET(prop_outdesc));
  209 
  210  prop_form=gtk_hbox_new(FALSE,0);
  211 
  212  prop_form1=gtk_vbox_new(TRUE,0);
  213 
  214  prop_lbllabel=gtk_label_new("Label:");
  215  gtk_label_set_justify(GTK_LABEL(prop_lbllabel),GTK_JUSTIFY_LEFT);
  216  gtk_box_pack_start(GTK_BOX(prop_form1),prop_lbllabel,TRUE,TRUE,0);
  217  gtk_widget_show(GTK_WIDGET(prop_lbllabel));
  218 
  219  prop_typlabel=gtk_label_new("Type:");
  220  gtk_label_set_justify(GTK_LABEL(prop_typlabel),GTK_JUSTIFY_LEFT);
  221  gtk_box_pack_start(GTK_BOX(prop_form1),prop_typlabel,TRUE,TRUE,0);
  222  gtk_widget_show(GTK_WIDGET(prop_typlabel));
  223 
  224  prop_intlabel=gtk_label_new("Interval:");
  225  gtk_label_set_justify(GTK_LABEL(prop_intlabel),GTK_JUSTIFY_LEFT);
  226  gtk_box_pack_start(GTK_BOX(prop_form1),prop_intlabel,TRUE,TRUE,0);
  227  gtk_widget_show(GTK_WIDGET(prop_intlabel));
  228 
  229  prop_scllabel=gtk_label_new("Grid Spacing:");
  230  gtk_label_set_justify(GTK_LABEL(prop_scllabel),GTK_JUSTIFY_LEFT);
  231  gtk_box_pack_start(GTK_BOX(prop_form1),prop_scllabel,TRUE,TRUE,0);
  232  gtk_widget_show(GTK_WIDGET(prop_scllabel));
  233 
  234  gtk_box_pack_start(GTK_BOX(prop_form),prop_form1,TRUE,TRUE,0);
  235  gtk_widget_show(GTK_WIDGET(prop_form1));
  236 
  237  prop_form2=gtk_vbox_new(TRUE,0);
  238 
  239  prop_label=gtk_label_new("NNNNNNNNNNNNNNN");
  240  gtk_label_set_justify(GTK_LABEL(prop_label),GTK_JUSTIFY_LEFT);
  241  gtk_box_pack_start(GTK_BOX(prop_form2),prop_label,TRUE,TRUE,0);
  242  gtk_widget_show(GTK_WIDGET(prop_label));
  243 
  244  prop_type=gtk_label_new("NNNNNNN");
  245  gtk_label_set_justify(GTK_LABEL(prop_type),GTK_JUSTIFY_LEFT);
  246  gtk_box_pack_start(GTK_BOX(prop_form2),prop_type,TRUE,TRUE,0);
  247  gtk_widget_show(GTK_WIDGET(prop_type));
  248 
  249  prop_interval=gtk_label_new("NNNNNNN");
  250  gtk_label_set_justify(GTK_LABEL(prop_interval),GTK_JUSTIFY_LEFT);
  251  gtk_box_pack_start(GTK_BOX(prop_form2),prop_interval,TRUE,TRUE,0);
  252  gtk_widget_show(GTK_WIDGET(prop_interval));
  253 
  254  prop_scale=gtk_label_new("NNNNNNN");
  255  gtk_label_set_justify(GTK_LABEL(prop_scale),GTK_JUSTIFY_LEFT);
  256  gtk_box_pack_start(GTK_BOX(prop_form2),prop_scale,TRUE,TRUE,0);
  257  gtk_widget_show(GTK_WIDGET(prop_scale));
  258 
  259  gtk_box_pack_start(GTK_BOX(prop_form),prop_form2,TRUE,TRUE,0);
  260  gtk_widget_show(GTK_WIDGET(prop_form2));
  261 
  262  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(properties_dialog)->vbox),prop_form,TRUE,TRUE,0);
  263  gtk_widget_show(GTK_WIDGET(prop_form));
  264 
  265  prop_done=gtk_button_new_with_label("Done");
  266  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(properties_dialog)->action_area),prop_done,TRUE,TRUE,0);
  267  gtk_widget_show(GTK_WIDGET(prop_done));
  268 
  269  gtk_signal_connect_object(GTK_OBJECT(prop_done),"clicked",
  270                            GTK_SIGNAL_FUNC(PropertiesDialogDoneCallback),NULL);
  271 
  272  /* Fixup the properties dialog box */
  273 
  274  gtk_signal_connect_object(GTK_OBJECT(properties_dialog),"delete_event",
  275                            GTK_SIGNAL_FUNC(PropertiesDialogCloseCallback),NULL);
  276 }
  277 
  278 
  279 /*++++++++++++++++++++++++++++++++++++++
  280   Add a specified module to the menus.
  281 
  282   Module module The module to add.
  283   ++++++++++++++++++++++++++++++++++++++*/
  284 
  285 void AddModuleToMenu(Module module)
  286 {
  287  int i;
  288  GtkWidget *menulabel,*menuline,*submenu=NULL,*menuitem=NULL;
  289  ProcMeterOutput *prevoutput=NULL;
  290  char *string;
  291 
  292  /* Return if pane widget is not initialised (e.g. gprocmeter3 -h). */
  293 
  294  if(!pane)
  295     return;
  296 
  297  /* Sort out the resources in advance. */
  298 
  299  // if(((string=GetProcMeterRC(module->module->name,"menu-foreground")) ||
  300  //     (string=GetProcMeterRC("resources","menu-foreground"))))
  301  //   {XtSetArg(args[nargs],XtNforeground,StringToPixel(string));nargs++;}
  302  //
  303  // if(((string=GetProcMeterRC(module->module->name,"menu-background")) ||
  304  //     (string=GetProcMeterRC("resources","menu-background"))))
  305  //   {XtSetArg(args[nargs],XtNbackground,StringToPixel(string));nargs++;}
  306  //
  307  // if(((string=GetProcMeterRC(module->module->name,"menu-font")) ||
  308  //     (string=GetProcMeterRC("resources","menu-font"))))
  309  //   {XtSetArg(args[nargs],XtNfont,StringToFont(string));nargs++;}
  310 
  311  /* Create a new menu. */
  312 
  313  module->submenu_widget=gtk_menu_new();
  314 
  315  menulabel=gtk_menu_item_new_with_label(module->module->name);
  316  gtk_widget_set_sensitive(GTK_WIDGET(menulabel),FALSE);
  317  gtk_menu_append(GTK_MENU(module->submenu_widget),menulabel);
  318  gtk_widget_show(GTK_WIDGET(menulabel));
  319 
  320  menuline=gtk_menu_item_new();
  321  gtk_menu_append(GTK_MENU(module->submenu_widget),menuline);
  322  gtk_widget_show(GTK_WIDGET(menuline));
  323 
  324  /* Add an entry to the module menu */
  325 
  326  module->menu_item_widget=gtk_menu_item_new_with_label(module->module->name);
  327 
  328  gtk_menu_append(GTK_MENU(module_menu),module->menu_item_widget);
  329  gtk_widget_show(GTK_WIDGET(module->menu_item_widget));
  330  gtk_menu_item_set_submenu(GTK_MENU_ITEM(module->menu_item_widget),module->submenu_widget);
  331 
  332  /* Add entries to it for each output. */
  333 
  334  for(i=0;module->outputs[i];i++)
  335    {
  336     GtkWidget *sme;
  337 
  338     if(module->outputs[i]->output!=prevoutput)
  339       {
  340        menuitem=gtk_menu_item_new_with_label(module->outputs[i]->output->name);
  341 
  342        gtk_menu_append(GTK_MENU(module->submenu_widget),menuitem);
  343        gtk_widget_show(GTK_WIDGET(menuitem));
  344 
  345  //       if(((string=GetProcMeterRC2(module->module->name,module->outputs[i]->output->name,"menu-foreground")) ||
  346  //           (string=GetProcMeterRC(module->module->name,"menu-foreground")) ||
  347  //           (string=GetProcMeterRC("resources","menu-foreground"))))
  348  //          XtVaSetValues(menuitem,XtNforeground,StringToPixel(string),NULL);
  349  //
  350  //       if(((string=GetProcMeterRC2(module->module->name,module->outputs[i]->output->name,"menu-font")) ||
  351  //           (string=GetProcMeterRC(module->module->name,"menu-font")) ||
  352  //           (string=GetProcMeterRC("resources","menu-font"))))
  353  //          XtVaSetValues(menuitem,XtNfont,StringToFont(string),NULL);
  354 
  355        submenu=gtk_menu_new();
  356        gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),submenu);
  357 
  358        prevoutput=module->outputs[i]->output;
  359       }
  360 
  361     string="";
  362     if(module->outputs[i]->type==PROCMETER_GRAPH)
  363        string="Graph";
  364     else if(module->outputs[i]->type==PROCMETER_TEXT)
  365        string="Text";
  366     else if(module->outputs[i]->type==PROCMETER_BAR)
  367        string="Bar";
  368 
  369     sme=gtk_check_menu_item_new_with_label(string);
  370 
  371     gtk_menu_append(GTK_MENU(submenu),sme);
  372     gtk_widget_show(GTK_WIDGET(sme));
  373 
  374     gtk_signal_connect_object(GTK_OBJECT(sme),"activate",
  375                               GTK_SIGNAL_FUNC(SelectOutputMenuCallback),(gpointer)module->outputs[i]);
  376 
  377  //    if(((string=GetProcMeterRC2(module->module->name,module->outputs[i]->output->name,"menu-foreground")) ||
  378  //        (string=GetProcMeterRC(module->module->name,"menu-foreground")) ||
  379  //        (string=GetProcMeterRC("resources","menu-foreground"))))
  380  //       XtVaSetValues(sme,XtNforeground,StringToPixel(string),NULL);
  381 
  382     module->outputs[i]->menu_item_widget=sme;
  383     module->outputs[i]->output_widget=NULL;
  384    }
  385 }
  386 
  387 
  388 /*++++++++++++++++++++++++++++++++++++++
  389   Add the menus to the right mouse button of the output.
  390 
  391   GtkWidget *widget The widget itself.
  392 
  393   Module module The module that this widget belongs to.
  394   ++++++++++++++++++++++++++++++++++++++*/
  395 
  396 void AddMenuToOutput(GtkWidget *widget,Module module)
  397 {
  398  /* Return if pane widget is not initialised (e.g. gprocmeter3 -h). */
  399 
  400  if(!pane)
  401     return;
  402 
  403  gtk_signal_connect(GTK_OBJECT(widget),"button_press_event",
  404                     GTK_SIGNAL_FUNC(MenuStart),module?module->module->name:NULL);
  405 }
  406 
  407 
  408 /*++++++++++++++++++++++++++++++++++++++
  409   Remove a specified module from the menus.
  410 
  411   Module module The module to remove.
  412   ++++++++++++++++++++++++++++++++++++++*/
  413 
  414 void RemoveModuleFromMenu(Module module)
  415 {
  416  /* Return if pane widget is not initialised (e.g. gprocmeter3 -h). */
  417 
  418  if(!pane)
  419     return;
  420 
  421  gtk_widget_destroy(GTK_WIDGET(module->submenu_widget));
  422  gtk_object_destroy(GTK_OBJECT(module->menu_item_widget));
  423 }
  424 
  425 
  426 /*++++++++++++++++++++++++++++++++++++++
  427   Destroy all of the menus.
  428   ++++++++++++++++++++++++++++++++++++++*/
  429 
  430 void DestroyMenus(void)
  431 {
  432  gtk_widget_destroy(GTK_WIDGET(module_menu));
  433  gtk_widget_destroy(GTK_WIDGET(functions_menu));
  434  gtk_widget_destroy(GTK_WIDGET(properties_dialog));
  435 }
  436 
  437 
  438 /*++++++++++++++++++++++++++++++++++++++
  439   The callback that is called by the output being selected on the output menu.
  440 
  441   gpointer clientData The client data from the callback.
  442 
  443   This function is only ever called from the GTK event loop.
  444   ++++++++++++++++++++++++++++++++++++++*/
  445 
  446 static void SelectOutputMenuCallback(gpointer clientData)
  447 {
  448  Output output=(Output)clientData;
  449 
  450  AddRemoveOutput(output);
  451 }
  452 
  453 
  454 /*++++++++++++++++++++++++++++++++++++++
  455   The callback that is called by the output being selected on the output menu.
  456 
  457   gpointer clientData The client data from the callback.
  458 
  459   This function is only ever called from the GTK event loop.
  460   ++++++++++++++++++++++++++++++++++++++*/
  461 
  462 static void SelectFunctionsMenuCallback(gpointer clientData)
  463 {
  464  if(clientData==(gpointer)0)         /* Properties */
  465    {
  466     gtk_widget_show(GTK_WIDGET(properties_dialog));
  467 
  468     properties_popped_up=TRUE;
  469    }
  470  else if(clientData==(gpointer)1 || clientData==(gpointer)2) /* Above / Below */
  471    {
  472     doing_move=(glong)clientData;
  473 
  474     gdk_pointer_grab(GTK_WIDGET(pane)->window,TRUE,GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK,NULL,gdk_cursor_new(GDK_HAND1),GDK_CURRENT_TIME);
  475    }
  476  else if(clientData==(gpointer)3)    /* Delete */
  477    {
  478     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(function_output->menu_item_widget),FALSE);
  479    }
  480  else if(clientData==(gpointer)4)    /* Run */
  481    {
  482     if(function_output->menu_run.flag)
  483        RunProgram(&function_output->menu_run);
  484    }
  485 }
  486 
  487 
  488 /*++++++++++++++++++++++++++++++++++++++
  489   The callback for the done button on the properties dialog box.
  490 
  491   GtkWidget *w The widget that the callback came from.
  492 
  493   gpointer data The data from the callback.
  494 
  495   This function is only ever called from the GTK event loop.
  496   ++++++++++++++++++++++++++++++++++++++*/
  497 
  498 static void PropertiesDialogDoneCallback(GtkWidget *w,gpointer data)
  499 {
  500  gtk_widget_hide(GTK_WIDGET(properties_dialog));
  501  properties_popped_up=FALSE;
  502 }
  503 
  504 
  505 /*++++++++++++++++++++++++++++++++++++++
  506   The callback for the window manager close on the dialog.
  507 
  508   GtkWidget *w The widget that caused the event.
  509 
  510   GdkEvent *event The event information.
  511 
  512   gpointer data Not used.
  513 
  514   This function is only ever called from the GTK event loop.
  515   ++++++++++++++++++++++++++++++++++++++*/
  516 
  517 static gint PropertiesDialogCloseCallback(GtkWidget *w,GdkEvent *event,gpointer data)
  518 {
  519  gtk_widget_hide(GTK_WIDGET(properties_dialog));
  520  properties_popped_up=FALSE;
  521 
  522  return(TRUE);
  523 }
  524 
  525 
  526 /*++++++++++++++++++++++++++++++++++++++
  527   Start one of the popup menus.
  528 
  529   GtkWidget *w The widget that caused it.
  530 
  531   GdkEvent *event The event that caused it.
  532 
  533   gpointer data The name of the module (or NULL for the pane).
  534 
  535   This function is only ever called from the GTK event loop.
  536   ++++++++++++++++++++++++++++++++++++++*/
  537 
  538 static void MenuStart(GtkWidget *w,GdkEvent *event,gpointer data)
  539 {
  540  if(event->type!=GDK_BUTTON_PRESS)
  541     return;
  542 
  543  if(event->button.button==1 && data)
  544     FunctionsMenuStart(w,event,data);
  545  else if(event->button.button==2 && data)
  546     OutputMenuStart(w,event,data);
  547  else if(event->button.button==3)
  548     ModuleMenuStart(w,event,data);
  549 }
  550 
  551 
  552 /*++++++++++++++++++++++++++++++++++++++
  553   Start the Module menu.
  554 
  555   GtkWidget *w The widget that caused it.
  556 
  557   GdkEvent *event The event that caused it.
  558 
  559   gpointer data The name of the module (or NULL for the pane).
  560 
  561   This function is only ever called from the GTK event loop.
  562   ++++++++++++++++++++++++++++++++++++++*/
  563 
  564 static void ModuleMenuStart(GtkWidget *w,GdkEvent *event,gpointer data)
  565 {
  566  gtk_menu_popup(GTK_MENU(module_menu),NULL,NULL,NULL,NULL,event->button.button,event->button.time);
  567 }
  568 
  569 
  570 /*++++++++++++++++++++++++++++++++++++++
  571   Start one of the Output menus.
  572 
  573   GtkWidget *w The widget that caused it.
  574 
  575   GdkEvent *event The event that caused it.
  576 
  577   gpointer data The name of the module (or NULL for the pane).
  578 
  579   This function is only ever called from the GTK event loop.
  580   ++++++++++++++++++++++++++++++++++++++*/
  581 
  582 static void OutputMenuStart(GtkWidget *w,GdkEvent *event,gpointer data)
  583 {
  584  static Module *modulep=NULL;
  585 
  586  for(modulep=Modules;*modulep;modulep++)
  587     if(!strcmp((*modulep)->module->name,data))
  588        gtk_menu_popup(GTK_MENU((*modulep)->submenu_widget),NULL,NULL,NULL,NULL,event->button.button,event->button.time);
  589 }
  590 
  591 
  592 /*++++++++++++++++++++++++++++++++++++++
  593   Start the properties menu.
  594 
  595   GtkWidget *w The widget that caused it.
  596 
  597   GdkEvent *event The event that caused it.
  598 
  599   gpointer data The name of the module (or NULL for the pane).
  600 
  601   This function is only ever called from the GTK event loop.
  602   ++++++++++++++++++++++++++++++++++++++*/
  603 
  604 static void FunctionsMenuStart(GtkWidget *w,GdkEvent *event,gpointer data)
  605 {
  606  static Output *outputp=NULL;
  607  static Module *modulep=NULL;
  608  char string[24];
  609 
  610  for(modulep=Modules;*modulep;modulep++)
  611     if(!strcmp((*modulep)->module->name,data))
  612       {
  613        for(outputp=(*modulep)->outputs;*outputp;outputp++)
  614           if(w==(*outputp)->output_widget)
  615              break;
  616        break;
  617       }
  618 
  619  if(doing_move)
  620    {
  621     gdk_pointer_ungrab(GDK_CURRENT_TIME);
  622 
  623     MoveOutput(function_output,*outputp,doing_move);
  624     doing_move=0;
  625     return;
  626    }
  627 
  628  if(!*modulep || !*outputp)
  629     return;
  630 
  631  function_output=*outputp;
  632 
  633  if((*outputp)->menu_run.flag)
  634    {
  635     char *r=(*outputp)->menu_run.command;
  636 
  637     strncpy(string,"Run '",16);
  638     strncpy(string+5,r,8);
  639     if(strlen(r)>8)
  640        strcat(string," ...'");
  641     else
  642        strcat(string,"'");
  643  
  644 //     XtVaSetValues(func_run,XtNlabel,string,NULL);
  645     gtk_widget_set_sensitive(GTK_WIDGET(func_run),TRUE);
  646    }
  647  else
  648    {
  649 //     XtVaSetValues(func_run,XtNlabel,"Run",NULL);
  650     gtk_widget_set_sensitive(GTK_WIDGET(func_run),FALSE);
  651    }
  652 
  653  /* Set up the properties window. */
  654 
  655  gtk_label_set_text(GTK_LABEL(prop_modname),(*modulep)->module->name);
  656  gtk_text_buffer_set_text(GTK_TEXT_BUFFER(prop_moddesc_text),
  657                           (*modulep)->module->description,strlen((*modulep)->module->description));
  658 
  659  gtk_label_set_text(GTK_LABEL(prop_outname),(*outputp)->output->name);
  660  gtk_text_buffer_set_text(GTK_TEXT_BUFFER(prop_outdesc_text),
  661                           (*modulep)->module->description,strlen((*modulep)->module->description));
  662 
  663  gtk_label_set_text(GTK_LABEL(prop_label),(*outputp)->label);
  664 
  665  if((*outputp)->type==PROCMETER_GRAPH)
  666     gtk_label_set_text(GTK_LABEL(prop_type),"Graph");
  667  else if((*outputp)->type==PROCMETER_TEXT)
  668     gtk_label_set_text(GTK_LABEL(prop_type),"Text");
  669  else if((*outputp)->type==PROCMETER_BAR)
  670     gtk_label_set_text(GTK_LABEL(prop_type),"Bar");
  671 
  672  if((*outputp)->output->interval)
  673     sprintf(string,"%d s",(*outputp)->output->interval);
  674  else
  675     strcpy(string,"Never");
  676  gtk_label_set_text(GTK_LABEL(prop_interval),string);
  677 
  678  if((*outputp)->type&(PROCMETER_GRAPH|PROCMETER_BAR))
  679    {
  680     char str[PROCMETER_UNITS_LEN+1];
  681     snprintf(str,PROCMETER_UNITS_LEN+1,(*outputp)->output->graph_units,(*outputp)->output->graph_scale);
  682     if(*str=='(')
  683        strcpy(string,str+1);
  684     else
  685        strcpy(string,str);
  686     if(string[strlen(string)-1]==')')
  687        string[strlen(string)-1]=0;
  688 
  689     gtk_label_set_text(GTK_LABEL(prop_scale),string);
  690    }
  691  else
  692    {
  693     gtk_label_set_text(GTK_LABEL(prop_scale),"n/a");
  694    }
  695 
  696  if(!properties_popped_up)
  697     gtk_menu_popup(GTK_MENU(functions_menu),NULL,NULL,NULL,NULL,event->button.button,event->button.time);
  698 }