hi john,
i'm trying to set up an internal buffer for the espeak -f to work against. it workd fine iff i leave the prefix as "talk"; the instant i type into the blank space where the user enters his own name [say, 'char' or rambleon' or whstever--then the program abouts. i have also created the play button and its callback. i havent bothered with the hbox code. first: get things working. make it look nice later! o'll append y.c below and attach it also. thanks for you insights! gary On Thu, Dec 08, 2011 at 08:56:12AM +0000, jcup...@gmail.com wrote: > Return-Path: <jcup...@gmail.com> > Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com > [209.85.210.50]) by ethic.thought.org (8.14.4/8.14.4) with ESMTP id > pB88uwvn090361 for <kl...@thought.org>; Thu, 8 Dec 2011 00:56:58 -0800 > (PST) (envelope-from jcup...@gmail.com) > Received: by dang27 with SMTP id g27so1506876dan.9 for > <kl...@thought.org>; Thu, 08 Dec 2011 00:56:53 -0800 (PST) > DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; > s=gamma; > h=mime-version:in-reply-to:references:from:date:message-id:subject:to > :cc:content-type:content-transfer-encoding; > bh=L/zLySazw2fgugJyHeeETUYujy/srMwGepcLPpSl2IU=; > b=VS21zCKEFIqOzRmszsbRFuKFX3iVpXvtjMII0l8+XOKIGIDo0El3XP5Qf0z2w+d9ui > D/iBL+HWGv+o6Ge8Bjr9KfYrcHhG+KocGpsro9Ebi88ShlIr+2ilgbq3zkWUOoojYolx > WoeXF4lFMs9KaKe0Pqzxqwoyk8vV45gudwhro= > Received: by 10.68.30.68 with SMTP id q4mr13453271pbh.75.1323334613164; > Thu, 08 Dec 2011 00:56:53 -0800 (PST) > MIME-Version: 1.0 > Received: by 10.68.23.74 with HTTP; Thu, 8 Dec 2011 00:56:12 -0800 (PST) > In-Reply-To: <20111208010028.ga27...@thought.org> > References: <20111208010028.ga27...@thought.org> > From: jcup...@gmail.com > Date: Thu, 8 Dec 2011 08:56:12 +0000 > Message-ID: > <cagns0rtpzzhe3poh5-cbonslx151ficd8pcmfl6xccgpgdp...@mail.gmail.com> > Subject: Re: a couple questions... > To: Gary Kline <kl...@thought.org> > Cc: GTK Devel List <gtk-app-devel-list@gnome.org> > Content-Type: text/plain; charset=ISO-8859-1 > X-Spam-Status: No, score=-2.6 required=3.9 tests=BAYES_00,FREEMAIL_FROM, > RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 > X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on ethic.thought.org > Content-Transfer-Encoding: 8bit > X-MIME-Autoconverted: from quoted-printable to 8bit by ethic.thought.org id > pB88uwvn090361 > > Hi Gary, > > On 8 December 2011 01:00, Gary Kline <kl...@thought.org> wrote: > > i'll need a play button and callback that invokes, say, > > espeak -f on that file. > > Make a play button with gtk_button_new_from_stock(GTK_STOCK_PLAY): > > http://developer.gnome.org/gtk3/stable/GtkButton.html#gtk-button-new-from-stock > > To put the button to the right of the label, make an hbox and append to that. > > http://developer.gnome.org/gtk3/stable/GtkHBox.html > > Attach a callback in the same way as the inc and dec one you have > already and run system("espeak -f %s", myfile) from that. > > John > -- Gary Kline kl...@thought.org http://www.thought.org Public Service Unix Journey Toward the Dawn, E-Book: http://www.thought.org The 8.57a release of Jottings: http://jottings.thought.org Twenty-five years of service to the Unix community. // GCc -Wall -Wextra -Werror -g y.c -o y1 `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` #include <gtk/gtk.h> #include <stdio.h> #include <string.h> #define DEFAULT "talk." static int counter = 0; static GtkWidget *label; static char *suffix = ".txt"; static char *prefix = DEFAULT; char internalFilename[1024]; static void update_label(void) { char buffer[1024], pibuf[1024]; /* internal buffer for filename */ memset(&buffer, 0, sizeof buffer); /*If counter is 1, use markup to highlight text*/ if(counter >= 0) { if(prefix) { g_snprintf(buffer, 1023, "<span foreground=\"red\" background=\"yellow\" size=\"x-large\">%s%d%s</span>",prefix, counter, suffix); sprintf(pibuf, "%s%d%s", prefix, counter, suffix); fprintf(stdout, "First pibuf = [%s]\n", pibuf); } else g_snprintf(buffer, 1023, "<span foreground=\"red\" background=\"yellow\" size=\"x-large\">%d%s</span>", counter, suffix); gtk_label_set_markup(GTK_LABEL(label), buffer); } else { if(prefix) { g_snprintf(buffer, 1023, "%s%d%s", prefix, counter, suffix); } else { g_snprintf(buffer, 1023, "%d%s", counter, suffix); gtk_label_set_label(GTK_LABEL(label), buffer); } } if (counter) { strcpy(internalFilename, pibuf); fprintf(stdout, "Last internalFilename = [%s]\n", internalFilename); } } static void inc_button_click_cb(GtkButton *button, gpointer data) { (void)button; GtkWidget *dec_button = data; counter++; /* Change senstivity of the decrement button based on counter*/ if(counter > 0 && !gtk_widget_is_sensitive(dec_button)) gtk_widget_set_sensitive(dec_button, TRUE); /* Update label to show updated counter */ update_label(); return; } static void dec_button_click_cb(GtkButton *button, gpointer data) { (void)data; counter--; if (counter < 0) { counter = 0; } /* Change senstivity of the decrement button based on counter*/ if(counter < 1 && gtk_widget_is_sensitive(GTK_WIDGET(button))) gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); /* Update label to show updated counter */ update_label(); return; } static void entry_changed_cb(GtkEditable *editable, gpointer data) { (void)data; /* Caller has to free the text, so call g_free */ g_free(prefix); /* Get the complete text */ prefix=gtk_editable_get_chars(editable,0, -1); /* Update label to show updated prefix */ update_label(); return; } int main(void) { GtkWidget *button_inc; GtkWidget *button_dec; GtkWidget *entry_label; GtkWidget *entry; GtkWidget *window; GtkWidget *vbox; gtk_init(NULL, NULL); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_title(GTK_WINDOW(window), "TalkByComputer"); gtk_container_set_border_width(GTK_CONTAINER(window), 10); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); vbox = gtk_vbox_new(FALSE, 5); gtk_container_add(GTK_CONTAINER(window), vbox); label = gtk_label_new(""); update_label(); button_dec = gtk_button_new_with_label("Decrease counter"); g_signal_connect(button_dec, "clicked", G_CALLBACK(dec_button_click_cb), NULL); gtk_widget_set_sensitive(button_dec, FALSE); button_inc = gtk_button_new_with_label("Increase counter"); g_signal_connect(button_inc, "clicked", G_CALLBACK(inc_button_click_cb), button_dec); entry_label = gtk_label_new("Type the filename in the space below:"); entry = gtk_entry_new(); g_signal_connect(entry,"changed", G_CALLBACK(entry_changed_cb), NULL); gtk_box_pack_start(GTK_BOX(vbox), label, 0, 0, 0); gtk_box_pack_start(GTK_BOX(vbox), button_inc, 0, 0, 0); gtk_box_pack_start(GTK_BOX(vbox), button_dec, 0, 0, 0); gtk_box_pack_start(GTK_BOX(vbox), entry_label, 0, 0, 0); gtk_box_pack_start(GTK_BOX(vbox), entry, 0, 0, 0); gtk_widget_show_all(window); gtk_main(); g_free(prefix); return 0; }
_______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list