diff -urN /home/rshann/denemo-musicfont/denemo/src/commandfuncs.c ./src/commandfuncs.c --- /home/rshann/denemo-musicfont/denemo/src/commandfuncs.c 2007-08-23 14:36:35.000000000 +0100 +++ ./src/commandfuncs.c 2007-08-22 10:50:03.000000000 +0100 @@ -26,7 +26,7 @@ #include "exportxml.h" #include "prefops.h" #include "keyresponses.h" -#include "view.h" + /** * Macro to get the current DenemoObject */ @@ -49,37 +49,19 @@ return; if(gui->si->currhythm==NULL) gui->si->currhythm = g_list_last(gui->si->rhythms); -#if 0 gtk_widget_set_state(((RhythmPattern *)gui->si->currhythm->data)->button, GTK_STATE_NORMAL); -#else - - {GdkColor thecolor; - gdk_color_parse ("gray", &thecolor); - gtk_widget_modify_bg (gtk_tool_button_get_label_widget(GTK_WIDGET(((RhythmPattern *)gui->si->currhythm->data)->button)), GTK_STATE_NORMAL, &thecolor); - } - -#endif if(gui->si->currhythm->next) gui->si->currhythm = gui->si->currhythm->next; else gui->si->currhythm = gui->si->rhythms; #define g (gui->si->rstep) - g = ((RhythmPattern*)gui->si->currhythm->data)->rsteps; - - -#define CURRP ((RhythmPattern *)gui->si->currhythm->data) + if(((RhythmElement*)g->data)->icon) { - GtkWidget *label = LABEL(CURRP->button); - gtk_label_set_markup(label,((RhythmElement*)g->data)->icon); + gtk_tool_button_set_label(((RhythmPattern *)gui->si->currhythm->data)->button,((RhythmElement*)g->data)->icon); } -#if 0 - gtk_widget_set_state(GTK_WIDGET(((RhythmPattern *)gui->si->currhythm->data)->button), GTK_STATE_PRELIGHT); -#else - highlight_rhythm((RhythmPattern *)gui->si->currhythm->data); -#endif - //g_print("selected active\n"); -#undef CURRP + gtk_widget_set_state(((RhythmPattern *)gui->si->currhythm->data)->button, GTK_STATE_PRELIGHT); + g_print("selected active\n"); #undef g } @@ -471,19 +453,11 @@ g = g->next;/* list is circular */ } } while(g!=start && modifier_code(h->data)); -#define CURRP ((RhythmPattern *)gui->si->currhythm->data) + if(((RhythmElement*)g->data)->icon) { - GtkWidget *label = LABEL(CURRP->button); - gtk_label_set_markup(label,((RhythmElement*)g->data)->icon);// FIXME repeated code, here above and in view.c -#if 0 -!!! the descr is NULL on a bad one - printf("font family %s\n",pango_font_description_get_family( - pango_layout_get_font_description(gtk_label_get_layout (label)))); - // pango_layout_get_attribute?s (gtk_label_get_layout (label)); -#endif + gtk_tool_button_set_label(((RhythmPattern *)gui->si->currhythm->data)->button,((RhythmElement*)g->data)->icon); } } -#undef CURRP #undef g } diff -urN /home/rshann/denemo-musicfont/denemo/src/keyresponses.c ./src/keyresponses.c --- /home/rshann/denemo-musicfont/denemo/src/keyresponses.c 2007-08-23 14:36:35.000000000 +0100 +++ ./src/keyresponses.c 2007-08-22 10:50:05.000000000 +0100 @@ -12,7 +12,7 @@ #include "barline.h" #include "utils.h" #include "tupletops.h" -#include "view.h" + /** * keypress event callback * looks up the key press and executes the correct function @@ -48,6 +48,16 @@ ki->func.nocallback==(gpointer)insert_chord_4key || ki->func.nocallback==(gpointer)insert_chord_5key || ki->func.nocallback==(gpointer)insert_chord_6key +#if 0 + || + ki->func.nocallback==(gpointer)insert_rest_0key || + ki->func.nocallback==(gpointer)insert_rest_1key || + ki->func.nocallback==(gpointer)insert_rest_2key || + ki->func.nocallback==(gpointer)insert_rest_3key || + ki->func.nocallback==(gpointer)insert_rest_4key || + ki->func.nocallback==(gpointer)insert_rest_5key || + ki->func.nocallback==(gpointer)insert_rest_6key +#endif ) { @@ -55,8 +65,7 @@ RhythmElement *relement = (RhythmElement*)g_malloc0(sizeof(RhythmElement)); relement->functions = g_list_append(NULL, (gpointer)ki->func.callback); if(gui->si->currhythm) { - unhighlight_rhythm((RhythmPattern *)gui->si->currhythm->data); - + gtk_widget_set_state(GTK_WIDGET(((RhythmPattern *)gui->si->currhythm->data)->button), GTK_STATE_NORMAL); } else if(g) { g_list_free(((RhythmElement*)g->data)->functions); g->next = g->prev = NULL; @@ -601,15 +610,10 @@ if(gui->si->rhythmicsubmode) { #define g (gui->si->rstep) -#define CURRP ((RhythmPattern *)gui->si->currhythm->data) - g = g->prev; /* list is circular - should we stop at beginning? */ if(((RhythmElement*)g->data)->icon) { - GtkWidget *label = LABEL(CURRP->button); - gtk_label_set_markup(label,((RhythmElement*)g->data)->icon); - + gtk_tool_button_set_label(((RhythmPattern *)gui->si->currhythm->data)->button,((RhythmElement*)g->data)->icon); } -#undef CURRP #undef g } } diff -urN /home/rshann/denemo-musicfont/denemo/src/utils.c ./src/utils.c --- /home/rshann/denemo-musicfont/denemo/src/utils.c 2007-08-23 14:36:35.000000000 +0100 +++ ./src/utils.c 2007-08-22 10:50:05.000000000 +0100 @@ -605,10 +605,3 @@ #endif /* not G_OS_WIN32 */ g_spawn_close_pid (pid); } - -/* markup the passed string to be in the denemo music font -* caller must free the returned string -*/ -gchar * music_font(gchar *str) { - return g_strdup_printf("%s", str); -} diff -urN /home/rshann/denemo-musicfont/denemo/src/utils.h ./src/utils.h --- /home/rshann/denemo-musicfont/denemo/src/utils.h 2007-08-23 14:36:35.000000000 +0100 +++ ./src/utils.h 2007-01-24 19:44:26.000000000 +0000 @@ -108,7 +108,5 @@ void kill_process (GPid pid); -gchar * music_font(gchar *str); - #endif /* UTILS_H */ diff -urN /home/rshann/denemo-musicfont/denemo/src/view.c ./src/view.c --- /home/rshann/denemo-musicfont/denemo/src/view.c 2007-08-23 14:36:35.000000000 +0100 +++ ./src/view.c 2007-08-22 10:50:05.000000000 +0100 @@ -332,14 +332,12 @@ r->gui->si->currhythm = g_list_find(r->gui->si->rhythms, r); r->gui->si->rstep = r->rsteps; #define g (r->gui->si->rstep) -#define CURRP ((RhythmPattern *)r->gui->si->currhythm->data) if(((RhythmElement*)g->data)->icon) { - GtkWidget *label = LABEL(CURRP->button); - gtk_label_set_markup(label,((RhythmElement*)g->data)->icon); + gtk_tool_button_set_label(((RhythmPattern *)r->gui->si->currhythm->data)->button,((RhythmElement*)g->data)->icon); } - highlight_rhythm(CURRP); - -#undef CURRP + gtk_widget_set_state(GTK_WIDGET(((RhythmPattern *)r->gui->si->currhythm->data)->button), GTK_STATE_ACTIVE); + g_print("selected active\n"); + #undef g } @@ -396,6 +394,8 @@ if(r->rsteps==NULL){ last_data = NULL; } + + #define GDK_BackSpace 0xFF08 /* to save including gdkkeysyms.h */ if (event->key.keyval == GDK_BackSpace) { if(r->rsteps) { @@ -478,9 +478,11 @@ entry = gtk_entry_new (); - gtk_widget_modify_font(entry, pango_font_description_from_string ("Denemo 14")); g_signal_connect (GTK_OBJECT (entry), "key_press_event", G_CALLBACK (translate_rhythm), r); + + + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), entry, TRUE, TRUE, 0); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); @@ -492,24 +494,21 @@ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { - const gchar *pattern = gtk_entry_get_text (GTK_ENTRY (entry));//FIXME free pattern? - gchar *labelstr = music_font(pattern); + const gchar *pattern = gtk_entry_get_text (GTK_ENTRY (entry)); g_print("rsteps is %p entry is %s\n", r->rsteps, pattern); - GtkWidget *label = LABEL(r->button); - gtk_label_set_markup(label, labelstr); - g_free(labelstr); + gtk_tool_button_set_label(r->button,pattern); /* fill the r->rsteps with icons for each step */ GList *g; gint i; RhythmElement *el; for(g=r->rsteps, i=0;g;g=g->next, i+=g_list_length(el->functions)) { el = (RhythmElement*)g->data; -#define highlight(c) ((c)+20) + gchar *fmt; - fmt = g_strdup_printf("%%.%ds%c%s",i,highlight(*(pattern+i)),pattern+i+1); - //g_printf("format string %s\n", fmt); - el->icon = music_font(g_strdup_printf(fmt, pattern));//FIXME memory leak - //g_print("el->icon = %s\n", el->icon); + fmt = g_strdup_printf("%%.%ds<%c>%s",i,*(pattern+i),pattern+i+1); + g_printf("format string %s\n", fmt); + el->icon = g_strdup_printf(fmt, pattern); + g_print("el->icon = %s\n", el->icon); g_free(fmt); } @@ -524,21 +523,6 @@ gtk_widget_destroy (dialog); } -static void color_rhythm_button(RhythmPattern *r, const gchar *color) { - - GdkColor thecolor; - gdk_color_parse (color, &thecolor); - gtk_widget_modify_bg (gtk_tool_button_get_label_widget(GTK_WIDGET(r->button)), GTK_STATE_NORMAL, &thecolor); - -} -void highlight_rhythm(RhythmPattern *r) { - color_rhythm_button(r, "green"); -} - -void unhighlight_rhythm(RhythmPattern *r) { - color_rhythm_button(r, "gray"); -} - /* * take user input for a rhythmic pattern to be placed * as a button on the rhythm toolbar @@ -546,60 +530,47 @@ static void create_rhythm_cb (GtkAction * action, DenemoGUI * gui) { - GSList*g = gtk_action_get_proxies(action); - if(g && g->data) { - /* make one rhythm */ - RhythmPattern *r = (RhythmPattern*)g_malloc0(sizeof(RhythmPattern)); - r->gui = gui; - GtkToolButton *button = (GtkToolButton *)gtk_tool_button_new(NULL, NULL); - /* gtk_button_set_relief(button, GTK_RELIEF_HALF); */ - GtkWidget *label = gtk_label_new(NULL); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - GtkWidget *ev = gtk_event_box_new(); - - gtk_container_add (ev, label); - gtk_tool_button_set_label_widget (button, ev /*label*/); + +GSList*g = gtk_action_get_proxies(action); + #if 0 - // this did not work as expected, the attribute applies to the layout of - // the text that is in the label, and goes away with new text (sometimes!) - /* set the font attr of the label of this button */ - PangoFontDescription*descr = pango_font_description_from_string ("Denemo 24"); - PangoAttribute*attr = pango_attr_font_desc_new (descr); - PangoAttrList *list = pango_attr_list_new (); - pango_attr_list_insert (list, attr); - gtk_label_set_attributes (GTK_LABEL(label), list); - /*pango_attribute_destroy() no!! - ownership assumed by list*/ - /* pango_attr_list_unref() should be done FIXME */ - pango_attr_list_unref(list); + if(g && g->data) { + static GtkWidget *label_widget; + if(label_widget==NULL) { + label_widget = gtk_label_new(NULL); + gtk_tool_button_set_label_widget(g->data, label_widget); + gtk_widget_show(label_widget); + } + if(label_widget){ + gtk_label_set_markup (GTK_LABEL (label_widget),"Create a rhythm"); + } + } #endif - r->button = button; - rhythm_edit(gui, r); - if(r->rsteps==NULL) - { - gtk_widget_destroy(GTK_WIDGET(button)); - g_free(r); - } else - { - GtkWidget *toolbar = gtk_widget_get_parent(g->data); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(button), -1); - gtk_widget_show_all(GTK_WIDGET(button)); - gui->si->rstep = r->rsteps; - gui->si->rhythms = g_list_append(gui->si->rhythms , r); - /* FIXME FUNCTIONALIZE - unhighlight gui->si->currhythm and - highlight the new currhythm */ - if(gui->si->currhythm) - unhighlight_rhythm((RhythmPattern *)gui->si->currhythm->data); - - - gui->si->currhythm = g_list_last(gui->si->rhythms); - highlight_rhythm((RhythmPattern *)gui->si->currhythm->data); - - //gui->si->rhythmicsubmode = (gboolean)gui->si->rhythms; - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (select_rhythm_pattern), (gpointer)r); - } - } + if(g && g->data) { + /* make one rhythm */ + RhythmPattern *r = (RhythmPattern*)g_malloc0(sizeof(RhythmPattern)); + r->gui = gui; + GtkToolButton *button = (GtkToolButton *)gtk_tool_button_new(NULL, NULL); + r->button = button; + rhythm_edit(gui, r); + if(r->rsteps==NULL) + { + gtk_widget_destroy(GTK_WIDGET(button)); + g_free(r); + } else + { + GtkWidget *toolbar = gtk_widget_get_parent(g->data); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(button), -1); + gtk_widget_show(GTK_WIDGET(button)); + gui->si->rstep = r->rsteps; + gui->si->rhythms = g_list_append(gui->si->rhythms , r); + gui->si->currhythm = g_list_last(gui->si->rhythms); + //gui->si->rhythmicsubmode = (gboolean)gui->si->rhythms; + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (select_rhythm_pattern), (gpointer)r); + } + } + } /* * delete a rhythmic pattern and its button @@ -629,10 +600,8 @@ if(gui->si->currhythm == NULL) gui->si->rstep = NULL;/* gui->si->rhythmicsubmode = FALSE */ - else { - highlight_rhythm(gui->si->currhythm->data); + else gui->si->rstep = ((RhythmPattern *)gui->si->currhythm->data)->rsteps; - } } @@ -1094,7 +1063,7 @@ gtk_window_add_accel_group (GTK_WINDOW (gui->window), accel_group); data_dir = g_build_filename ( -#ifdef USE_LOCAL_DENEMOUI +#ifndef USE_LOCAL_DENEMOUI get_data_dir (), #endif "denemoui.xml", NULL); diff -urN /home/rshann/denemo-musicfont/denemo/src/view.h ./src/view.h --- /home/rshann/denemo-musicfont/denemo/src/view.h 2007-08-23 14:36:35.000000000 +0100 +++ ./src/view.h 2007-07-10 01:34:43.000000000 +0100 @@ -61,13 +61,4 @@ DenemoGUI *gui; GtkWidget *menu; }; - - -/* tool_buttons cannot be visually separated from the toolbar, which is ok for icons but not so good for pure text; to separate them we put the label of the tool_button into an event box and decorate that. This macro gets the label out. */ -#define LABEL(a) (gtk_bin_get_child(GTK_BIN(gtk_tool_button_get_label_widget((a))))) - -void highlight_rhythm(RhythmPattern *r); -void unhighlight_rhythm(RhythmPattern *r); - - #endif