Skip to content
Snippets Groups Projects
Commit 3acec4e6 authored by edgrif's avatar edgrif
Browse files

initial versions

parent ece3cc80
No related branches found
No related tags found
No related merge requests found
================================================================================
ZMapApp
The code that forms the "main" of the zmap client application, it constructs
the intial zmap window and creates/destroys individual ZMaps.
#
# Makes the manager part of the ZMap application.
#
# local macros
APP_PRIV_HDRS = zmapApp_P.h
APP_SRC = zmapAppwindow.c zmapAppmenubar.c zmapAppmanage.c zmapAppconnect.c
APP_OBJ = zmapAppwindow.o zmapAppmenubar.o zmapAppmanage.o zmapAppconnect.o
APP_CC_MAIN_OBJ = zmapAppmain_c.o
APP_CCC_MAIN_OBJ = zmapAppmain_C.o
APP_EXE = zmap zmapC
#
# These must all be set for the common includes to work.
#
CURRENT_LIB = $(ZMAPAPP_LIB)
CURRENT_OBJ = $(APP_OBJ)
CURRENT_DEP = $(PUB_HDRS) $(APP_PRIV_HDRS)
CURRENT_SRC = $(APP_PRIV_HDRS) $(APP_SRC)
CURRENT_REMOVE = cd $(BINDIR) ; rm -f $(APP_EXE) $(APP_CC_MAIN_OBJ) $(APP_CCC_MAIN_OBJ)
#
# point to common make include file which contains all the rules etc.
#
ROOT_DIRECTORY = ..
MAKE_DIR = $(ROOT_DIRECTORY)/zmapMake
include $(MAKE_DIR)/build.make
# Make the application programs themselves.
# ZMAP library...
ZMAP_LIB_FLAGS = -L$(BINDIR) -lZMapApp -lZMap
# Ace-Conn library...
ACECONN_DIR = $(HOME)/acedb/CODE/Ace-Conn
ACECONN_INCL_DIR = $(ACECONN_DIR)
ACECONN_LIB_DIR = $(ACECONN_DIR)/bin.ALPHA_5
ACECONN_LIB_FLAGS = -L$(ACECONN_LIB_DIR) -lAceConn -lmd5
zmap: $(APP_CC_MAIN_OBJ) $(ZMAPAPP_LIB) $(ZMAP_LIB)
$(CC) -g -pthread -o $(BINDIR)/$@ `gtk-config --libs` $(BINDIR)/zmapAppmain_c.o $(ZMAP_LIB_FLAGS) $(ACECONN_LIB_FLAGS)
@echo 'zmap (C version) make...'
zmapC: $(APP_CCC_MAIN_OBJ) $(ZMAPAPP_LIB) $(ZMAP_LIB)
$(CCC) -g -pthread -o $(BINDIR)/$@ `gtk-config --libs` $(BINDIR)/zmapAppmain_c.o $(ZMAP_LIB_FLAGS) $(ACECONN_LIB_FLAGS)
@echo 'zmap (C++ version) make...'
/* File: zmapApp.h
* Author: Ed Griffiths (edgrif@sanger.ac.uk)
* Copyright (c) Sanger Institute, 2003
*-------------------------------------------------------------------
* ZMap is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
*-------------------------------------------------------------------
* This file is part of the ZMap genome database package
* and was written by
* Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk and
* Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk,
*
* Description:
* Exported functions: See XXXXXXXXXXXXX.h
* HISTORY:
* Last edited: Nov 12 15:09 2003 (edgrif)
* Created: Thu Jul 24 14:35:41 2003 (edgrif)
* CVS info: $Id: zmapApp_P.h,v 1.1 2003-11-13 14:58:39 edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_APP_PRIV_H
#define ZMAP_APP_PRIV_H
#include <gtk/gtk.h>
#include <ZMap/zmapManager.h>
/* Minimum GTK version supported. */
enum {ZMAP_GTK_MAJOR = 1, ZMAP_GTK_MINOR = 2, ZMAP_GTK_MICRO = 10} ;
/* Overall application control struct. */
typedef struct
{
GtkWidget *app_widg ;
GtkWidget *machine_widg ;
GtkWidget *port_widg ;
GtkWidget *sequence_widg ;
GtkWidget *clist_widg ;
ZMapManager zmap_manager ;
ZMapWinConn selected_zmap ;
} ZMapAppContextStruct, *ZMapAppContext ;
/* cols in connection list. */
enum {ZMAP_NUM_COLS = 3} ;
int zmapMainMakeAppWindow(int argc, char *argv[]) ;
GtkWidget *zmapMainMakeMenuBar(ZMapAppContext app_context) ;
GtkWidget *zmapMainMakeConnect(ZMapAppContext app_context) ;
GtkWidget *zmapMainMakeManage(ZMapAppContext app_context) ;
void zmapExit(ZMapAppContext app_context) ;
#endif /* !ZMAP_APP_PRIV_H */
/* File: zmapappconnect.c
* Author: Ed Griffiths (edgrif@sanger.ac.uk)
* Copyright (c) Sanger Institute, 2003
*-------------------------------------------------------------------
* ZMap is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
*-------------------------------------------------------------------
* This file is part of the ZMap genome database package
* and was written by
* Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk,
* Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk and
* Simon Kelley (Sanger Institute, UK) srk@sanger.ac.uk
*
* Description:
* Exported functions: See XXXXXXXXXXXXX.h
* HISTORY:
* Last edited: Nov 12 15:06 2003 (edgrif)
* Created: Thu Jul 24 14:36:37 2003 (edgrif)
* CVS info: $Id: zmapAppconnect.c,v 1.1 2003-11-13 14:58:39 edgrif Exp $
*-------------------------------------------------------------------
*/
#include <stdlib.h>
#include <stdio.h>
#include <zmapApp_P.h>
static void createThreadCB(GtkWidget *widget, gpointer data) ;
GtkWidget *zmapMainMakeConnect(ZMapAppContext app_context)
{
GtkWidget *frame ;
GtkWidget *topbox, *hbox, *entry, *label, *create_button ;
frame = gtk_frame_new( "New Connection" );
gtk_frame_set_label_align( GTK_FRAME( frame ), 0.0, 0.0 );
gtk_container_border_width(GTK_CONTAINER(frame), 5);
topbox = gtk_hbox_new(FALSE, 0) ;
gtk_container_border_width(GTK_CONTAINER(topbox), 5);
gtk_container_add (GTK_CONTAINER (frame), topbox);
hbox = gtk_hbox_new(FALSE, 0) ;
gtk_container_border_width(GTK_CONTAINER(hbox), 5);
gtk_box_pack_start(GTK_BOX(topbox), hbox, FALSE, FALSE, 0) ;
label = gtk_label_new( "Machine:" ) ;
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0) ;
app_context->machine_widg = entry = gtk_entry_new() ;
gtk_entry_set_text(GTK_ENTRY(entry), "") ;
gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1) ;
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0) ;
hbox = gtk_hbox_new(FALSE, 0) ;
gtk_container_border_width(GTK_CONTAINER(hbox), 5);
gtk_box_pack_start(GTK_BOX(topbox), hbox, FALSE, FALSE, 0) ;
label = gtk_label_new( "Port:" ) ;
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0) ;
app_context->port_widg = entry = gtk_entry_new() ;
gtk_entry_set_text(GTK_ENTRY(entry), "") ;
gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1) ;
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0) ;
hbox = gtk_hbox_new(FALSE, 0) ;
gtk_container_border_width(GTK_CONTAINER(hbox), 5);
gtk_box_pack_start(GTK_BOX(topbox), hbox, FALSE, FALSE, 0) ;
label = gtk_label_new( "Sequence:" ) ;
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0) ;
app_context->sequence_widg = entry = gtk_entry_new() ;
gtk_entry_set_text(GTK_ENTRY(entry), "") ;
gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1) ;
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0) ;
create_button = gtk_button_new_with_label("Create Thread") ;
gtk_signal_connect(GTK_OBJECT(create_button), "clicked",
GTK_SIGNAL_FUNC(createThreadCB), (gpointer)app_context) ;
gtk_box_pack_start(GTK_BOX(topbox), create_button, FALSE, FALSE, 0) ;
GTK_WIDGET_SET_FLAGS(create_button, GTK_CAN_DEFAULT) ;
gtk_widget_grab_default(create_button) ;
return frame ;
}
static void createThreadCB(GtkWidget *widget, gpointer cb_data)
{
ZMapAppContext app_context = (ZMapAppContext)cb_data ;
char *machine ;
char *port_str ;
int port ;
char *sequence ;
char *row_text[ZMAP_NUM_COLS] = {"", "", ""} ;
int row ;
ZMapWinConn zmapconn ;
machine = gtk_entry_get_text(GTK_ENTRY(app_context->machine_widg)) ;
port_str = gtk_entry_get_text(GTK_ENTRY(app_context->port_widg)) ;
port = atoi(port_str) ;
sequence = gtk_entry_get_text(GTK_ENTRY(app_context->sequence_widg)) ;
zmapconn = zMapManagerAdd(app_context->zmap_manager, machine, port, sequence) ;
/* ERROR HANDLING ETC.... */
row_text[0] = machine ;
row_text[1] = port_str ;
row_text[2] = sequence ;
row = gtk_clist_append(GTK_CLIST(app_context->clist_widg), row_text) ;
gtk_clist_set_row_data(GTK_CLIST(app_context->clist_widg), row, (gpointer)zmapconn) ;
ZMAP_DEBUG(("GUI: create thread number %d to access: %s on port %d\n",
(row + 1), machine ? machine : "localhost", port)) ;
return ;
}
/* File: zmapAppmain_C.C
* Author: Ed Griffiths (edgrif@sanger.ac.uk)
* Copyright (c) Sanger Institute, 2003
*-------------------------------------------------------------------
* ZMap is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
*-------------------------------------------------------------------
* This file is part of the ZMap genome database package
* originated by
* Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
* Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk
*
* Description: C++ main, if the executable is compiled/linked with
* main then we can use C++ classes from our code.
* Exported functions: None.
* HISTORY:
* Created: Thu Nov 13 14:38:41 2003 (edgrif)
* CVS info: $Id: zmapAppmain_C.C,v 1.1 2003-11-13 14:58:40 edgrif Exp $
*-------------------------------------------------------------------
*/
#include <zmapApp_P.h>
int main(int argc, char *argv[])
{
int main_rc ;
// cout << "about to call zmap \"main\"" << endl ;
main_rc = zmapMainMakeAppWindow(argc, argv) ;
// cout << "I shouldn't have got here..." << endl ;
return(main_rc) ;
}
/* File: zmapAppmain_c.c
* Author: Ed Griffiths (edgrif@sanger.ac.uk)
* Copyright (c) Sanger Institute, 2003
*-------------------------------------------------------------------
* ZMap is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
*-------------------------------------------------------------------
* This file is part of the ZMap genome database package
* originated by
* Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
* Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk
*
* Description: C main, if the executable is compiled/linked with
* main then you get a standard C executable.
* Exported functions: None.
* HISTORY:
* Last edited: Nov 13 14:40 2003 (edgrif)
* Created: Thu Nov 13 14:38:41 2003 (edgrif)
* CVS info: $Id: zmapAppmain_c.c,v 1.1 2003-11-13 14:58:39 edgrif Exp $
*-------------------------------------------------------------------
*/
#include <zmapApp_P.h>
int main(int argc, char *argv[])
{
int main_rc ;
main_rc = zmapMainMakeAppWindow(argc, argv) ;
return(main_rc) ;
}
/* File: zmapappmanage.c
* Author: Ed Griffiths (edgrif@sanger.ac.uk)
* Copyright (c) Sanger Institute, 2003
*-------------------------------------------------------------------
* ZMap is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
*-------------------------------------------------------------------
* This file is part of the ZMap genome database package
* and was written by
* Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk,
* Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk and
* Simon Kelley (Sanger Institute, UK) srk@sanger.ac.uk
*
* Description:
* Exported functions: See XXXXXXXXXXXXX.h
* HISTORY:
* Last edited: Nov 13 12:29 2003 (edgrif)
* Created: Thu Jul 24 14:36:47 2003 (edgrif)
* CVS info: $Id: zmapAppmanage.c,v 1.1 2003-11-13 14:58:39 edgrif Exp $
*-------------------------------------------------------------------
*/
#include <stdlib.h>
#include <stdio.h>
#include <zmapApp_P.h>
static void loadThreadCB(GtkWidget *widget, gpointer cb_data) ;
static void killThreadCB(GtkWidget *widget, gpointer data) ;
static void checkThreadCB(GtkWidget *widget, gpointer cb_data) ;
static void selectRow(GtkCList *clist, gint row, gint column, GdkEventButton *event,
gpointer cb_data) ;
static void unselectRow(GtkCList *clist, gint row, gint column, GdkEventButton *event,
gpointer cb_data) ;
static char *column_titles[ZMAP_NUM_COLS] = {"Window", "Status", "Last Request"} ;
GtkWidget *zmapMainMakeManage(ZMapAppContext app_context)
{
GtkWidget *frame ;
GtkWidget *vbox, *scrwin, *clist, *hbox, *load_button, *kill_button, *check_button ;
frame = gtk_frame_new("Manage Connections") ;
gtk_frame_set_label_align( GTK_FRAME( frame ), 0.0, 0.0 ) ;
gtk_container_border_width(GTK_CONTAINER(frame), 5) ;
vbox = gtk_vbox_new(FALSE, 0) ;
gtk_container_border_width(GTK_CONTAINER(vbox), 5);
gtk_container_add(GTK_CONTAINER (frame), vbox);
scrwin = gtk_scrolled_window_new(NULL, NULL) ;
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrwin),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC) ;
gtk_widget_set_usize(scrwin, -2, 150) ; /* -2 => leave value unchanged. */
gtk_box_pack_start(GTK_BOX(vbox), scrwin, FALSE, FALSE, 0) ;
app_context->clist_widg = clist = gtk_clist_new_with_titles(3, column_titles) ;
gtk_signal_connect(GTK_OBJECT(clist), "select_row",
GTK_SIGNAL_FUNC(selectRow), (gpointer)app_context) ;
gtk_signal_connect(GTK_OBJECT(clist), "unselect_row",
GTK_SIGNAL_FUNC(unselectRow), (gpointer)app_context) ;
gtk_container_add (GTK_CONTAINER (scrwin), clist);
hbox = gtk_hbox_new(FALSE, 0) ;
gtk_container_border_width(GTK_CONTAINER(hbox), 5);
gtk_container_add(GTK_CONTAINER(vbox), hbox);
load_button = gtk_button_new_with_label("Load Thread Data") ;
gtk_signal_connect(GTK_OBJECT(load_button), "clicked",
GTK_SIGNAL_FUNC(loadThreadCB), (gpointer)app_context) ;
gtk_box_pack_start(GTK_BOX(hbox), load_button, FALSE, FALSE, 0) ;
GTK_WIDGET_SET_FLAGS(load_button, GTK_CAN_DEFAULT) ;
gtk_widget_grab_default(load_button) ;
kill_button = gtk_button_new_with_label("Kill Thread") ;
gtk_signal_connect(GTK_OBJECT(kill_button), "clicked",
GTK_SIGNAL_FUNC(killThreadCB), (gpointer)app_context) ;
gtk_box_pack_start(GTK_BOX(hbox), kill_button, FALSE, FALSE, 0) ;
GTK_WIDGET_SET_FLAGS(kill_button, GTK_CAN_DEFAULT) ;
gtk_widget_grab_default(kill_button) ;
check_button = gtk_button_new_with_label("Check Connections") ;
gtk_signal_connect(GTK_OBJECT(check_button), "clicked",
GTK_SIGNAL_FUNC(checkThreadCB), (gpointer)app_context) ;
gtk_box_pack_start(GTK_BOX(hbox), check_button, FALSE, FALSE, 0) ;
GTK_WIDGET_SET_FLAGS(check_button, GTK_CAN_DEFAULT) ;
gtk_widget_grab_default(check_button) ;
return frame ;
}
static void loadThreadCB(GtkWidget *widget, gpointer cb_data)
{
ZMapAppContext app_context = (ZMapAppContext)cb_data ;
int row ;
if (app_context->selected_zmap)
{
zMapManagerLoadData(app_context->selected_zmap) ;
}
return ;
}
static void killThreadCB(GtkWidget *widget, gpointer cb_data)
{
ZMapAppContext app_context = (ZMapAppContext)cb_data ;
int row ;
if (app_context->selected_zmap)
{
row = gtk_clist_find_row_from_data(GTK_CLIST(app_context->clist_widg),
app_context->selected_zmap) ;
ZMAP_DEBUG(("GUI: kill thread for row %d with connection pointer: %x\n",
row, app_context->selected_zmap)) ;
zMapManagerKill(app_context->zmap_manager, app_context->selected_zmap) ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
/* this all done by a callback now as we need to do this from several places and
* at the right time. */
app_context->selected_zmap = NULL ;
/* The remove call actually sets my data which I attached to the row to NULL
* which is v. naughty, so I reset my data in the widget to NULL to avoid it being
* messed with. */
gtk_clist_set_row_data(GTK_CLIST(app_context->clist_widg), row, NULL) ;
gtk_clist_remove(GTK_CLIST(app_context->clist_widg), row) ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
}
return ;
}
/* this function was for testing really and needs to go or be updated..... */
static void checkThreadCB(GtkWidget *widget, gpointer cb_data)
{
ZMapAppContext app_context = (ZMapAppContext)cb_data ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
/* REPLACE WITH A CALL TO DISPLAY STATE OF CONNECTIONS.....was for testing only anyway. */
ZMapCheckConnections(app_context->connections,
zmapSignalData, app_context,
zmapCleanUpConnection, app_context) ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
return ;
}
static void selectRow(GtkCList *clist, gint row, gint column, GdkEventButton *event,
gpointer cb_data)
{
ZMapAppContext app_context = (ZMapAppContext)cb_data ;
app_context->selected_zmap = (ZMapWinConn)gtk_clist_get_row_data(clist, row) ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
ZMAP_DEBUG(("GUI: select row %d with connection pointer: %x\n", row, connection)) ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
return ;
}
static void unselectRow(GtkCList *clist, gint row, gint column, GdkEventButton *event,
gpointer cb_data)
{
ZMapAppContext app_context = (ZMapAppContext)cb_data ;
app_context->selected_zmap = NULL ;
ZMAP_DEBUG(("GUI: unselect row %d\n", row)) ;
return ;
}
/* File: zmapappmenubar.c
* Author: Ed Griffiths (edgrif@sanger.ac.uk)
* Copyright (c) Sanger Institute, 2003
*-------------------------------------------------------------------
* ZMap is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
*-------------------------------------------------------------------
* This file is part of the ZMap genome database package
* and was written by
* Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk,
* Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk and
* Simon Kelley (Sanger Institute, UK) srk@sanger.ac.uk
*
* Description:
* Exported functions: See XXXXXXXXXXXXX.h
* HISTORY:
* Last edited: Nov 12 15:08 2003 (edgrif)
* Created: Thu Jul 24 14:36:59 2003 (edgrif)
* CVS info: $Id: zmapAppmenubar.c,v 1.1 2003-11-13 14:58:39 edgrif Exp $
*-------------------------------------------------------------------
*/
#include <stdlib.h>
#include <stdio.h>
#include <zmapApp_P.h>
static void quitCB(gpointer cb_data, guint callback_action, GtkWidget *w) ;
static void print_hello( gpointer data, guint callback_action, GtkWidget *w ) ;
static void handle_option( gpointer data, guint callback_action, GtkWidget *w ) ;
void DestroyNotifyFunc( gpointer data ) ;
GtkItemFactory *item_factory;
/* When we go to GTK 2 this global can disappear as the below table will allow us to
* specify callback data. */
static ZMapAppContext app_context_G ;
static GtkItemFactoryEntry menu_items[] = {
{ "/_File", NULL, NULL, 0, "<Branch>" },
{ "/File/_New", "<control>N", print_hello, 2, NULL },
{ "/File/_Open", "<control>O", print_hello, 0, NULL },
{ "/File/_Save", "<control>S", print_hello, 0, NULL },
{ "/File/Save _As", NULL, NULL, 0, NULL },
{ "/File/sep1", NULL, NULL, 0, "<Separator>" },
{ "/File/Quit", "<control>Q", quitCB, 0, NULL },
{ "/_Edit", NULL, NULL, 0, "<Branch>" },
{ "/Edit/Cu_t", "<control>X", print_hello, 0, NULL },
{ "/Edit/_Copy", "<control>C", print_hello, 0, NULL },
{ "/Edit/_Paste", "<control>V", print_hello, 0, NULL },
{ "/_Options", NULL, NULL, 0, "<Branch>" },
{ "/Options/Option1", NULL, handle_option, 1, "<CheckItem>" },
{ "/Options/Option2", NULL, handle_option, 2, "<ToggleItem>" },
{ "/Options/Option3", NULL, handle_option, 3, "<CheckItem>" },
{ "/Options/Option4", NULL, handle_option, 4, "<ToggleItem>" },
{ "/_Help", NULL, NULL, 0, "<LastBranch>" },
{ "/Help/One", NULL, NULL, 0, NULL },
{ "/Help/Two", NULL, NULL, 0, "<Branch>" },
{ "/Help/Two/A", NULL, NULL, 0, "<RadioItem>" },
{ "/Help/Two/B", NULL, NULL, 0, "/Help/Two/A" },
{ "/Help/Two/C", NULL, NULL, 0, "/Help/Two/A" },
{ "/Help/Two/D", NULL, NULL, 0, "/Help/Two/A" },
{ "/Help/Two/E", NULL, NULL, 0, "/Help/Two/A" },
{ "/Help/Three", NULL, NULL, 0, NULL },
};
GtkWidget *zmapMainMakeMenuBar(ZMapAppContext app_context)
{
GtkWidget *menubar ;
GtkAccelGroup *accel_group;
gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
GtkWidget *widget;
/* global will go away with gtk 2 */
app_context_G = app_context ;
accel_group = gtk_accel_group_new ();
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group );
gtk_item_factory_create_items(item_factory, nmenu_items, menu_items, (gpointer)app_context);
gtk_accel_group_attach(accel_group, GTK_OBJECT (app_context->app_widg));
menubar = gtk_item_factory_get_widget (item_factory, "<main>");
widget = (GtkWidget *) gtk_item_factory_from_widget(menubar);
/* What is this about ????????????????????? */
if ( widget == (GtkWidget *) item_factory )
printf( "widget and item_factory are the same\n" );
else
printf( "widget and item_factory are not the same\n" );
return menubar ;
}
static void quitCB(gpointer cb_data, guint callback_action, GtkWidget *w)
{
ZMapAppContext app_context = (ZMapAppContext)cb_data ;
zmapExit(app_context) ;
}
static void print_hello( gpointer data, guint callback_action, GtkWidget *w )
{
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
GtkWidget *myWidget;
printf( "widget is %x data is %s\n", w, data );
g_message ("Hello, World!\n");
myWidget = gtk_item_factory_get_widget (item_factory, "/File/New");
printf( "File/New is %x\n", myWidget );
gtk_item_factory_delete_item( item_factory, "/Edit" );
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
}
static void handle_option( gpointer data, guint callback_action, GtkWidget *w )
{
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
GtkCheckMenuItem *checkMenuItem = (GtkCheckMenuItem *) w;
printf( "widget is %x data is %s\n", w, data );
g_message ("Hello, World!\n");
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
}
void DestroyNotifyFunc( gpointer data )
{
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
printf( "data is %x\n", data );
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
}
/* File: zmapappmain.c
* Author: Ed Griffiths (edgrif@sanger.ac.uk)
* Copyright (c) Sanger Institute, 2003
*-------------------------------------------------------------------
* ZMap is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
*-------------------------------------------------------------------
* This file is part of the ZMap genome database package
* and was written by
* Rob Clack (Sanger Institute, UK) rnc@sanger.ac.uk,
* Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk and
* Simon Kelley (Sanger Institute, UK) srk@sanger.ac.uk
*
* Description:
* Exported functions: See XXXXXXXXXXXXX.h
* HISTORY:
* Last edited: Nov 12 15:06 2003 (edgrif)
* Created: Thu Jul 24 14:36:27 2003 (edgrif)
* CVS info: $Id: zmapAppwindow.c,v 1.1 2003-11-13 14:58:39 edgrif Exp $
*-------------------------------------------------------------------
*/
#include <stdlib.h>
#include <stdio.h>
#include <zmapApp_P.h>
static void initGTK(int argc, char *argv[]) ;
static ZMapAppContext createAppContext(void) ;
static void quitCB(GtkWidget *widget, gpointer data) ;
static gint idleCB(gpointer cb_data) ;
static void removeZmapRow(void *app_data, void *zmap) ;
/* Overall app. debugging output. */
gboolean zmap_debug_G = TRUE ;
int zmapMainMakeAppWindow(int argc, char *argv[])
{
ZMapAppContext app_context ;
GtkWidget *toplevel, *vbox, *menubar, *connect_frame, *manage_frame ;
GtkWidget *kill_button, *quit_button ;
initGTK(argc, argv) ; /* May exit if checks fail. */
app_context = createAppContext() ;
app_context->app_widg = toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL) ;
gtk_window_set_policy(GTK_WINDOW(toplevel), FALSE, TRUE, FALSE ) ;
gtk_window_set_title(GTK_WINDOW(toplevel), "ZMap - Son of FMap !") ;
gtk_container_border_width(GTK_CONTAINER(toplevel), 0) ;
gtk_signal_connect(GTK_OBJECT(toplevel), "destroy",
GTK_SIGNAL_FUNC(quitCB), (gpointer)app_context) ;
vbox = gtk_vbox_new(FALSE, 0) ;
gtk_container_add(GTK_CONTAINER(toplevel), vbox) ;
menubar = zmapMainMakeMenuBar(app_context) ;
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
connect_frame = zmapMainMakeConnect(app_context) ;
gtk_box_pack_start(GTK_BOX(vbox), connect_frame, TRUE, TRUE, 0);
manage_frame = zmapMainMakeManage(app_context) ;
gtk_box_pack_start(GTK_BOX(vbox), manage_frame, TRUE, TRUE, 0);
quit_button = gtk_button_new_with_label("Quit") ;
gtk_signal_connect(GTK_OBJECT(quit_button), "clicked",
GTK_SIGNAL_FUNC(quitCB), (gpointer)app_context) ;
gtk_box_pack_start(GTK_BOX(vbox), quit_button, FALSE, FALSE, 0) ;
GTK_WIDGET_SET_FLAGS(quit_button, GTK_CAN_DEFAULT) ;
gtk_widget_grab_default(quit_button) ;
gtk_widget_show_all(toplevel) ;
gtk_idle_add(idleCB, (gpointer)app_context) ;
gtk_main() ;
return(EXIT_SUCCESS) ;
}
void zmapExit(ZMapAppContext app_context)
{
printf("\nGoodbye cruel world !\n" ) ;
gtk_exit(EXIT_SUCCESS) ;
}
/*
* ------------------- Internal functions -------------------
*/
static void initGTK(int argc, char *argv[])
{
gchar *err_msg ;
gtk_set_locale() ;
if ((err_msg = gtk_check_version(ZMAP_GTK_MAJOR, ZMAP_GTK_MINOR, ZMAP_GTK_MICRO)))
{
fprintf(stderr, "%s\n", err_msg) ;
gtk_exit(EXIT_FAILURE) ;
}
gtk_init(&argc, &argv) ;
return ;
}
static ZMapAppContext createAppContext(void)
{
ZMapAppContext app_context ;
app_context = g_new(ZMapAppContextStruct, sizeof(ZMapAppContextStruct)) ;
app_context->app_widg
= app_context->machine_widg = app_context->port_widg = app_context->sequence_widg
= app_context->clist_widg = NULL ;
app_context->zmap_manager = zMapManagerInit(removeZmapRow, (void *)app_context) ;
app_context->selected_zmap = NULL ;
return app_context ;
}
static void quitCB(GtkWidget *widget, gpointer cb_data)
{
ZMapAppContext app_context = (ZMapAppContext)cb_data ;
zmapExit(app_context) ; /* Does not return. */
return ;
}
/* This is really the guts of the code to check what our connection threads are up
* to. Every time the GUI thread has stopped doing things this routine gets called
* so then we check all connections for action..... */
static gint idleCB(gpointer cb_data)
{
ZMapAppContext app_context = (ZMapAppContext)cb_data ;
zMapManagerCheckConnections(app_context->zmap_manager) ;
return 1 ; /* > 0 tells gtk to keep calling idleCB */
}
static void removeZmapRow(void *app_data, void *zmap_data)
{
ZMapAppContext app_context = (ZMapAppContext)app_data ;
ZMapWinConn zmap = (ZMapWinConn)zmap_data ;
int row ;
row = gtk_clist_find_row_from_data(GTK_CLIST(app_context->clist_widg), zmap) ;
if (app_context->selected_zmap == zmap)
app_context->selected_zmap = NULL ;
/* The remove call actually sets my data which I attached to the row to NULL
* which is v. naughty, so I reset my data in the widget to NULL to avoid it being
* messed with. */
gtk_clist_set_row_data(GTK_CLIST(app_context->clist_widg), row, NULL) ;
gtk_clist_remove(GTK_CLIST(app_context->clist_widg), row) ;
return ;
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment