[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Denemo-devel] Transpose
From: |
Richard Shann |
Subject: |
Re: [Denemo-devel] Transpose |
Date: |
Mon, 11 Aug 2008 19:24:44 +0100 |
On Mon, 2008-08-11 at 09:23 -0500, Jeremiah Benham wrote:
> No. I am going to have to read through the docs first. I will get
> started on that now.
>
> > As I mentioned I
> > could generate an interface to all the menu Actions callback
> functions
> > in a matter of minutes, given an example of the format required.
>
> ok. I will get on that.
I've written a very simple example of generating an interface array
the result looks like this:
/* Interface (dummy) for a scripting engine */
typedef struct arraytype {
char *command_name;
void* callback;
}
arraytype;
arraytype interface_array[] = {
{"Denemo_InsertBflatmaj",(void*) 0x816ac40},
{"Denemo_StaffUp",(void*) 0x815ec98},
{"Denemo_SetInitialDflatmaj",(void*) 0x816d920},
{"Denemo_ToggleStartCrescendo",(void*) 0x8170ed0},
{"Denemo_ToggleTenuto",(void*) 0x81710d8},
...
and so on.
The void* are the GtkAction pointers, so the call to
ToggleStartCrescendo would call a function that would do
gtk_action_activate(0x8170ed0);
For parameters, notice that there is a whole machinery GValue for
passing parameters whose types can be determined.
Here is a little snippet of code showing GValue in use:
GValue *value = g_malloc0(sizeof(GValue));
g_value_init(value, G_TYPE_BOOLEAN);
g_value_set_boolean(value,Denemo.gui->textview &&
GTK_WIDGET_VISIBLE(Denemo.gui->textwindow));
g_object_set_property (G_OBJECT (widget), "active", value);
though you wouldn't normally generate them on the heap.
I'm mentioning all this as I am scheduled to be in hospital Thursday
this week, and hope to come back to find everything finished!
Richard
p.s. the code generating the above is this (at the end of view.c)
...
GtkActionGroup *action_group;
GList *groups = gtk_ui_manager_get_action_groups (Denemo.ui_manager);
action_group = GTK_ACTION_GROUP(groups->data);
GList *g = gtk_action_group_list_actions(action_group);
#ifdef GENERATE_INTERFACE_TO_SCRIPTING_LANGUAGE
g_print("/* Interface (dummy) for a scripting engine */\n");
g_print("typedef struct arraytype {\nchar *command_name;\n void*
callback;\n}\narraytype;\n");
g_print("arraytype interface_array[] = {\n");
#endif
for(;g;g=g->next) {
gint command_idx;
keymap *the_keymap = Denemo.prefs.the_keymap;
GSList *h = gtk_action_get_proxies (g->data);
for(;h;h=h->next) {
#if (GTK_MINOR_VERSION <10)
attach_action_to_widget(h->data, g->data, Denemo.gui);
#endif
attach_set_accel_callback(h->data, g->data,"", Denemo.gui);
command_idx = lookup_index_from_name(the_keymap,
gtk_action_get_name(g->data));
if (command_idx != -1) {
update_accel_labels(the_keymap, command_idx);
}
}
#ifdef GENERATE_INTERFACE_TO_SCRIPTING_LANGUAGE
GtkAction *action = g->data;
g_print("{\"Denemo_%s\",(void*) %p},\n",
gtk_action_get_name(action), action);
#endif
}
#ifdef GENERATE_INTERFACE_TO_SCRIPTING_LANGUAGE
g_print("{\"\", 0x0}};\n");
#endif
initialized = TRUE;
}
...
- [Denemo-devel] Transpose, Richard Shann, 2008/08/09
- Re: [Denemo-devel] Transpose, Richard Shann, 2008/08/10
- Re: [Denemo-devel] Transpose, Jeremiah Benham, 2008/08/11
- Re: [Denemo-devel] Transpose,
Richard Shann <=
- Re: [Denemo-devel] Transpose, Jeremiah Benham, 2008/08/11
- Re: [Denemo-devel] Transpose, Jeremiah Benham, 2008/08/12
- Re: [Denemo-devel] Transpose, Richard Shann, 2008/08/12
- Re: [Denemo-devel] Transpose, Jeremiah Benham, 2008/08/12
- Re: [Denemo-devel] Transpose, Richard Shann, 2008/08/12
- Re: [Denemo-devel] Transpose, Jeremiah Benham, 2008/08/12
- Re: [Denemo-devel] Transpose, Richard Shann, 2008/08/12
- Re: [Denemo-devel] Transpose, Jeremiah Benham, 2008/08/13
- Re: [Denemo-devel] Transpose, Richard Shann, 2008/08/12
- Re: [Denemo-devel] Transpose, Jeremiah Benham, 2008/08/12