~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina6/tina-tools/tinatool/wdgts/gtk2/wdgtsGtk_tw_hlp_btn.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :  TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/wdgts/gtk2/wdgtsGtk_tw_hlp_btn.c,v $
 37  * Date    :  $Date: 2009/05/15 15:51:20 $
 38  * Version :  $Revision: 1.5 $
 39  * CVS Id  :  $Id: wdgtsGtk_tw_hlp_btn.c,v 1.5 2009/05/15 15:51:20 paul Exp $
 40  *
 41  * Author  :  a.lacey@man.ac.uk, giob@man.ac.uk
 42  *
 43  *********
 44 */
 45 /** 
 46  *  @file  wdgtsGtk_tw_hlp_btn.c
 47  *  @brief Define and create GTK help button and its associated callbacks.
 48  *
 49  *  Create a button labelled "help" which summons help from a file
 50  *  <help_file_name>, searching directories in this order: current
 51  *  directory, directory specified by environment variable TINA_HELPDIR,
 52  *  home directory. (Re-reads file on each button press to simplify
 53  *  adding help (instant gratification!) Output to Help tool's text
 54  *  subwindow.
 55  *
 56  *  Note that the functions in this file are duplicated for each widget set 
 57  *  (xv, GTK, xm, etc ...).
 58  */
 59 
 60 #include "wdgtsGtk_tw_hlp_btn.h"
 61 
 62 #if HAVE_CONFIG_H
 63 #   include <config.h>
 64 #endif
 65 
 66 #include <stdio.h>
 67 #include <gtk/gtk.h>
 68 #include <tina/sys/sysGen_help.h>
 69 #include <tina/sys/sysLst_rec.h>
 70 #include <tina/sys/sysGen_format.h>
 71 #include <tina/sys/sysGen_string.h>
 72 #include <tinatool/wdgts/gtk2/wdgts_GtkDef.h>
 73 #include <tinatool/wdgts/gtk2/wdgtsGtk_tw_textsw.h>
 74 #include <tinatool/wdgts/gtk2/wdgtsGtk_tw_command.h>
 75 #include <tinatool/wdgts/gtk2/wdgtsGtk_tw_tool.h>
 76 
 77 
 78 /**
 79  * @brief Create and show new help tool.  
 80  * @param help_file  String name of help file to display.
 81  */
 82 static void help_proc(char *help_file)
 83 {
 84     static GtkWidget *help_tool = NULL;
 85     static GtkWidget *help_win  = NULL;
 86 
 87     GtkTextBuffer *text_buffer;
 88     GtkTextIter start_iter, end_iter;
 89 
 90     if (help_tool)
 91     {
 92         tw_textsw_clear(help_win);
 93         tw_show_tool(help_tool);
 94     }
 95     else
 96     {
 97         help_tool = tw_tool("Tina Help", 10, 10);
 98         help_win  = tw_textsubwin(20, 100);
 99         tw_end_tool();
100     }
101     print_help((void *)help_win, help_file);
102 }
103 
104 /**
105  * @brief Help button callback.  
106  * @param twc   Pointer to Tw_callback associated with help button.
107  */
108 static void button_call(Tw_callback * twc)
109 {
110     (*twc->func) (twc->data1);
111 }
112 
113 
114 /**
115  * @brief  Create a new help button and its associated callback struct.  
116  * @param  help_file    String to be used as entry field identifier and label.
117  * 
118  * Invokes callback for each keypress, via call to tw_button_callback 
119  * (in wdgtsGtk_tw_command.c).
120  */
121 void tw_help_button(char *help_file)
122 {
123   GtkWidget *panel= tw_get_menubox();
124   GtkWidget *hbutton;
125   GtkWidget *buttox;
126 
127   Tw_callback *twc;
128 
129   static char name[] = "Help";
130   char *fullname = tw_extend_fullname(tw_get_toolname(), name);
131 
132   /* Pack all buttons into a vbox inside the current hbox: this prevents the  
133      buttons expanding to fill the full vertical range of the current hbox, 
134      which causes them to be larger vertically if there is a choice or check 
135      list in the current hbox. PAB 27/03/2009 */
136 
137   /* In order to distinguish the help buttons, pack them into the end (right
138      hand side) of the menubox, so that they are always at the top of the tool
139   */
140 
141   buttox = gtk_vbox_new (FALSE, 0);
142   gtk_box_pack_end(GTK_BOX(panel), buttox, FALSE, FALSE, 0);
143   gtk_widget_show(buttox);
144 
145   hbutton = gtk_button_new_with_label(name);
146   gtk_box_pack_end(GTK_BOX(buttox), hbutton, FALSE, FALSE, 0);
147   gtk_widget_show(hbutton);
148 
149   twc = tw_callback_make(fullname, hbutton, 
150                          button_call, (void (*)()) NULL, (void (*)()) NULL, (void *) help_proc,
151                          (void *) string_copy(help_file), NULL);  
152 
153   /*  Invoke callback for GTK entry "clicked" event */
154   gtk_signal_connect(GTK_OBJECT(hbutton), "clicked",
155                      GTK_SIGNAL_FUNC(tw_gtk_callback),
156                      (gpointer) twc);
157   
158   format_set_print_sw(textsw_print_sw);
159 }
160 
161 
162 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.