Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
da672142
Commit
da672142
authored
18 years ago
by
rds
Browse files
Options
Downloads
Patches
Plain Diff
added utility to ease creating radio groups.
parent
6fe1c1f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/ZMap/zmapUtilsGUI.h
+13
-2
13 additions, 2 deletions
src/include/ZMap/zmapUtilsGUI.h
src/zmapUtils/zmapGUIutils.c
+94
-2
94 additions, 2 deletions
src/zmapUtils/zmapGUIutils.c
with
107 additions
and
4 deletions
src/include/ZMap/zmapUtilsGUI.h
+
13
−
2
View file @
da672142
...
...
@@ -25,9 +25,9 @@
* Description: Set of general GUI functions.
*
* HISTORY:
* Last edited: Ma
r 21 13:33
2006 (
edgrif
)
* Last edited: Ma
y 10 18:07
2006 (
rds
)
* Created: Fri Nov 4 16:59:52 2005 (edgrif)
* CVS info: $Id: zmapUtilsGUI.h,v 1.
8
2006-0
3-2
1 1
4
:07:
39 edgrif
Exp $
* CVS info: $Id: zmapUtilsGUI.h,v 1.
9
2006-0
5-1
1 1
3
:07:
41 rds
Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_UTILS_GUI_H
...
...
@@ -43,6 +43,7 @@ typedef enum {ZMAPGUI_PIXELS_PER_CM, ZMAPGUI_PIXELS_PER_INCH,
/*! Callback function for menu items. The id indicates which menu_item was selected
* resulting in the call to this callback. */
typedef
void
(
*
ZMapGUIMenuItemCallbackFunc
)(
int
menu_item_id
,
gpointer
callback_data
)
;
typedef
void
(
*
ZMapGUIRadioButtonCBFunc
)(
GtkWidget
*
button
,
gpointer
data
,
gboolean
button_active
);
/*!
* Defines a menu item. */
...
...
@@ -57,6 +58,12 @@ typedef struct
}
ZMapGUIMenuItemStruct
,
*
ZMapGUIMenuItem
;
typedef
struct
{
int
value
;
char
*
name
;
GtkWidget
*
widget
;
}
ZMapGUIRadioButtonStruct
,
*
ZMapGUIRadioButton
;
void
zMapGUIMakeMenu
(
char
*
menu_title
,
GList
*
menu_sets
,
GdkEventButton
*
button_event
)
;
...
...
@@ -81,5 +88,9 @@ void zMapGUIShowText(char *title, char *text, gboolean edittable) ;
char
*
zmapGUIFileChooser
(
GtkWidget
*
toplevel
,
char
*
title
,
char
*
directory
,
char
*
file_suffix
)
;
void
zMapGUICreateRadioGroup
(
GtkWidget
*
gtkbox
,
ZMapGUIRadioButton
all_buttons
,
int
default_button
,
int
*
value_out
,
ZMapGUIRadioButtonCBFunc
clickedCB
,
gpointer
clickedData
);
#endif
/* ZMAP_UTILS_GUI_H */
This diff is collapsed.
Click to expand it.
src/zmapUtils/zmapGUIutils.c
+
94
−
2
View file @
da672142
...
...
@@ -25,9 +25,9 @@
* Description:
* Exported functions: See ZMap/zmapUtilsGUI.h
* HISTORY:
* Last edited: May
5 11:21
2006 (rds)
* Last edited: May
11 14:02
2006 (rds)
* Created: Thu Jul 24 14:37:35 2003 (edgrif)
* CVS info: $Id: zmapGUIutils.c,v 1.1
6
2006-05-
05 11:00:16
rds Exp $
* CVS info: $Id: zmapGUIutils.c,v 1.1
7
2006-05-
11 13:08:21
rds Exp $
*-------------------------------------------------------------------
*/
...
...
@@ -35,6 +35,13 @@
#include
<zmapUtils_P.h>
#include
<ZMap/zmapUtilsGUI.h>
typedef
struct
{
int
value
;
int
*
output
;
ZMapGUIRadioButtonCBFunc
callback
;
gpointer
user_data
;
}
RadioButtonCBDataStruct
,
*
RadioButtonCBData
;
/* ONLY NEEDED FOR OLD STYLE FILE SELECTOR, REMOVE WHEN WE CAN USE THE NEW CODE... */
typedef
struct
...
...
@@ -805,6 +812,91 @@ void zMapGUIGetPixelsPerUnit(ZMapGUIPixelConvType conv_type, GtkWidget *widget,
}
/* Handle creating a radio group.
* pass in a vbox or hbox and the buttons will get packed in order.
*/
/* Callback to set the value and call any user specified callback */
static
void
radioButtonCB
(
GtkWidget
*
button
,
gpointer
radio_data
)
{
RadioButtonCBData
data
=
(
RadioButtonCBData
)
radio_data
;
gboolean
active
;
if
((
active
=
gtk_toggle_button_get_active
(
GTK_TOGGLE_BUTTON
(
button
)))
&&
data
->
output
)
*
(
data
->
output
)
=
data
->
value
;
if
(
data
->
callback
)
(
data
->
callback
)(
button
,
data
->
user_data
,
active
);
return
;
}
/* GDestroyNotify for the RadioButtonCBData attached to radio buttons
* for "clicked" signal */
static
void
radioButtonCBDataDestroy
(
gpointer
data
)
{
RadioButtonCBData
button_data
=
(
RadioButtonCBData
)
data
;
/* clear pointers */
button_data
->
output
=
NULL
;
button_data
->
callback
=
NULL
;
button_data
->
user_data
=
NULL
;
/* and free .. */
g_free
(
button_data
);
return
;
}
/* Possibly sensible to make value_out point to a member of clickedData if you are setting clickedCB. */
void
zMapGUICreateRadioGroup
(
GtkWidget
*
gtkbox
,
ZMapGUIRadioButton
all_buttons
,
int
default_button
,
int
*
value_out
,
ZMapGUIRadioButtonCBFunc
clickedCB
,
gpointer
clickedData
)
{
GtkWidget
*
radio
=
NULL
;
GSList
*
group
=
NULL
;
ZMapGUIRadioButton
buttons
=
NULL
;
buttons
=
all_buttons
;
while
(
buttons
->
name
)
{
RadioButtonCBData
data
=
NULL
;
radio
=
NULL
;
data
=
g_new0
(
RadioButtonCBDataStruct
,
1
);
data
->
value
=
buttons
->
value
;
data
->
output
=
value_out
;
data
->
callback
=
clickedCB
;
data
->
user_data
=
clickedData
;
buttons
->
widget
=
radio
=
gtk_radio_button_new_with_label
(
group
,
buttons
->
name
);
g_signal_connect_data
(
G_OBJECT
(
radio
),
"clicked"
,
G_CALLBACK
(
radioButtonCB
),
(
gpointer
)
data
,
(
GClosureNotify
)
radioButtonCBDataDestroy
,
0
);
/* If value == default set it so */
if
(
buttons
->
value
==
default_button
)
{
gtk_toggle_button_set_active
(
GTK_TOGGLE_BUTTON
(
radio
),
TRUE
);
*
(
data
->
output
)
=
data
->
value
;
/* In case we're never clicked */
}
/* pack into the box */
gtk_box_pack_start
(
GTK_BOX
(
gtkbox
),
radio
,
TRUE
,
TRUE
,
0
);
/* Get the group it's in */
group
=
gtk_radio_button_get_group
(
GTK_RADIO_BUTTON
(
radio
));
/* move to the next input */
buttons
++
;
}
return
;
}
/*! @} end of zmapguiutils docs. */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment