Exemple #1
0
static void pattern_clist_sync_selection (void) {
  GSList *list;
  struct player_pattern *pp;

  if (current_row >= 0) {
    list = g_slist_nth (curplrs, current_row);
    pp = (struct player_pattern *) list->data;

    if (!GTK_WIDGET_REALIZED (comment_text))
      gtk_widget_realize (comment_text);
  
    gtk_text_freeze (GTK_TEXT (comment_text));
    gtk_text_set_point (GTK_TEXT (comment_text), 0);
    gtk_text_forward_delete (GTK_TEXT (comment_text),
                               gtk_text_get_length (GTK_TEXT (comment_text)));
    gtk_text_set_point (GTK_TEXT (comment_text), 0);
    if (pp->comment) {
      gtk_text_insert (GTK_TEXT (comment_text), NULL, NULL, NULL,
                                           pp->comment, strlen (pp->comment));
      gtk_text_set_point (GTK_TEXT (comment_text), 0);
    }
    gtk_text_set_editable (GTK_TEXT (comment_text), TRUE);
    gtk_text_thaw (GTK_TEXT (comment_text));

    gtk_entry_set_text (GTK_ENTRY (pattern_entry), 
                                             (pp->pattern)? pp->pattern : "");
    gtk_entry_set_editable (GTK_ENTRY (pattern_entry), TRUE);

    gtk_widget_set_sensitive (mode_buttons[PATTERN_MODE_STRING], TRUE);
    gtk_widget_set_sensitive (mode_buttons[PATTERN_MODE_SUBSTR], TRUE);
    gtk_widget_set_sensitive (mode_buttons[PATTERN_MODE_REGEXP], TRUE);

    gtk_toggle_button_set_active (
  			    GTK_TOGGLE_BUTTON (mode_buttons[pp->mode]), TRUE);

    gtk_widget_set_sensitive (delete_button, TRUE);
    gtk_widget_set_sensitive (up_button, TRUE);
    gtk_widget_set_sensitive (down_button, TRUE);
  }
  else {
    gtk_text_freeze (GTK_TEXT (comment_text));
    gtk_text_set_point (GTK_TEXT (comment_text), 0);
    gtk_text_forward_delete (GTK_TEXT (comment_text),
                               gtk_text_get_length (GTK_TEXT (comment_text)));
    gtk_text_set_editable (GTK_TEXT (comment_text), FALSE);
    gtk_text_thaw (GTK_TEXT (comment_text));

    gtk_entry_set_text (GTK_ENTRY (pattern_entry), "");
    gtk_entry_set_editable (GTK_ENTRY (pattern_entry), FALSE);

    gtk_widget_set_sensitive (mode_buttons[PATTERN_MODE_STRING], FALSE);
    gtk_widget_set_sensitive (mode_buttons[PATTERN_MODE_SUBSTR], FALSE);
    gtk_widget_set_sensitive (mode_buttons[PATTERN_MODE_REGEXP], FALSE);

    gtk_widget_set_sensitive (delete_button, FALSE);
    gtk_widget_set_sensitive (up_button, FALSE);
    gtk_widget_set_sensitive (down_button, FALSE);
  }
}
void on_load_ok_button_clicked(GtkButton *button, gpointer user_data)
{
	GtkWidget *load_select;
	FILE *infile;
	char *filename;
	char text[512];

	load_select = gtk_widget_get_ancestor(GTK_WIDGET(button),GTK_TYPE_FILE_SELECTION);
	filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(load_select));
	gtk_widget_hide(load_select);

	infile = fopen(filename,"r");
	if(infile == NULL) {
		fprintf(stderr,"IOL: can't open %s\n",filename);
		gtk_widget_destroy(load_select);
		return;
	}

	gtk_widget_destroy(load_select);

	gtk_text_freeze(script_text);

	/* since GTK+ (lamely) has no gtk_text_empty() or whatever,
	   so we have to revert to kludges :( */
	gtk_text_set_point(script_text,0);
	gtk_text_forward_delete(script_text,gtk_text_get_length(script_text));

	while(fgets(text,512,infile) != NULL)
		gtk_text_insert(script_text,script_font,NULL,NULL,text,strlen(text));

	fclose(infile);

	gtk_text_set_point(script_text,0);
	gtk_text_thaw(script_text);
}
Exemple #3
0
static void change_color(GtkText *gtktext, gint start, gint end, GdkColor *color)
{
  gchar *newtext;

  /* So we don't need spaces at the very end of the text */
  if ( end == gtk_text_get_length(GTK_TEXT(gtktext))+1 )
    end--;

  newtext = gtk_editable_get_chars(GTK_EDITABLE(gtktext), start, end);
    
  gtk_text_freeze(gtktext);
  gtk_signal_handler_block_by_func(GTK_OBJECT(gtktext),  
				   GTK_SIGNAL_FUNC(entry_insert_cb), NULL); 
	
  gtk_text_set_point(gtktext, start);
  gtk_text_forward_delete(gtktext, end-start);

  if (newtext && end-start > 0)
    gtk_text_insert(gtktext, NULL, color, NULL, newtext, end-start); 

  gtk_signal_handler_unblock_by_func(GTK_OBJECT(gtktext), 
				     GTK_SIGNAL_FUNC(entry_insert_cb), NULL); 
  gtk_text_thaw(gtktext);
  g_free(newtext);
}
Exemple #4
0
int
putmail (GtkWidget * widget)
{
    synopsis *s;
    GtkCTreeNode *n;
    GtkWidget *from, *subj, *date, *recipt, *body;
    char *shtuff;

    if (widget != NULL)
      {
	  n = gtk_ctree_node_nth (GTK_CTREE (widget),
				  (&(GTK_CTREE (widget)->clist))->focus_row);
	  s = (synopsis *) gtk_ctree_node_get_row_data (GTK_CTREE (widget),
							n);
	  if (s)
	      shtuff = (char *) db_read_body (s->id);
	  else
	    {
		printf ("synopsis for row %d is NULL!\n", (&(GTK_CTREE (widget)->clist))->focus_row);
		return FALSE;
	    }
      }
    else
      {
	  s = (synopsis *) malloc (sizeof (synopsis));
	  s->sender = strdup (" ");
	  s->subject = strdup (" ");
	  s->date = strdup (" ");
	  s->sender = strdup (" ");
	  shtuff = strdup (" ");
      }
    from = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (gems), "entry1");
    date = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (gems), "entry2");
    subj = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (gems), "entry3");
    recipt = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (gems), "entry4");
    body = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (gems), "text1");

    gtk_entry_set_text (GTK_ENTRY (from), s->sender);
    gtk_entry_set_text (GTK_ENTRY (subj), s->subject);
    gtk_entry_set_text (GTK_ENTRY (date), s->date);
    gtk_text_freeze (GTK_TEXT (body));
    gtk_text_set_point (GTK_TEXT (body), 0);
    gtk_text_forward_delete (GTK_TEXT (body),
			     gtk_text_get_length (GTK_TEXT (body)));
    gtk_text_insert (GTK_TEXT (body), NULL, NULL, NULL, shtuff, -1);
    gtk_text_thaw (GTK_TEXT (body));
    if (widget == NULL)
      {
	  free (s);
	  free (shtuff);
      }
    return TRUE;
}
Exemple #5
0
void
on_toolbar_reply_clicked (GtkButton * UNUSED(button), gpointer UNUSED(user_data))
{
    synopsis *s;
    GtkCTreeNode *n;
    GtkWidget *from, *subj, *date, *recipt, *body, *comp, *widget;
    char *shtuff, buf[1024];

    if ((widget = lookup_widget (gems, "mailbox")) == NULL)
	return;
    comp = create_compose ();
    from = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (comp), "entry1");
    /* to = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (comp), "entry5"); */
    date = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (comp), "entry2");
    subj = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (comp), "entry6");
    recipt = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (comp), "entry4");
    body = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (comp), "text2");

    n = gtk_ctree_node_nth (GTK_CTREE (widget),
	(&(GTK_CTREE (widget)->clist))->focus_row);
    s = (synopsis *) gtk_ctree_node_get_row_data (GTK_CTREE (widget), n);
    shtuff = replyify (s, (char *)db_read_body (s->id));

    gtk_entry_set_text (GTK_ENTRY (from), s->sender);
    /*
     * if(!strncasecmp("re: ", s->subject, 4)) 
     */
    if (tolower (s->subject[0]) == 'r' && tolower (s->subject[1]) == 'e'
	&& s->subject[2] == ':' && s->subject[3] == ' ')
	sprintf (buf, "%s", s->subject);
    else
	sprintf (buf, "Re: %s", s->subject);
    gtk_entry_set_text (GTK_ENTRY (subj), buf);
    gtk_entry_set_text (GTK_ENTRY (date), s->date);


    gtk_text_freeze (GTK_TEXT (body));
    gtk_text_set_point (GTK_TEXT (body), 0);
    gtk_text_forward_delete (GTK_TEXT (body),
	gtk_text_get_length (GTK_TEXT (body)));
    gtk_text_insert (GTK_TEXT (body), NULL, NULL, NULL, shtuff, -1);
    gtk_text_thaw (GTK_TEXT (body));
    if (widget == NULL)
    {
	free (s);
	free (shtuff);
    }
    gtk_text_set_editable (GTK_TEXT (body), TRUE);
    gtk_widget_show (comp);
    return;
}
Exemple #6
0
void gtkspell_uncheck_all(GtkText *gtktext) {
	int origpos;
	char *text;
	float adj_value;

	adj_value = gtktext->vadj->value;
	gtk_text_freeze(gtktext);
	origpos = gtk_editable_get_position(GTK_EDITABLE(gtktext));
	text = gtk_editable_get_chars(GTK_EDITABLE(gtktext), 0, -1);
	gtk_text_set_point(gtktext, 0);
	gtk_text_forward_delete(gtktext, gtk_text_get_length(gtktext));
	gtk_text_insert(gtktext, NULL, NULL, NULL, text, strlen(text));
	gtk_text_thaw(gtktext);

	gtk_editable_set_position(GTK_EDITABLE(gtktext), origpos);
	gtk_adjustment_set_value(gtktext->vadj, adj_value);
}
Exemple #7
0
static void change_color(GtkText *gtktext, 
		int start, int end, GdkColor *color) {
	char *newtext = gtk_editable_get_chars(GTK_EDITABLE(gtktext), start, end);
	gtk_text_freeze(gtktext);
	gtk_signal_handler_block_by_func(GTK_OBJECT(gtktext), 
			GTK_SIGNAL_FUNC(entry_insert_cb), NULL);
	
	gtk_text_set_point(gtktext, start);
	gtk_text_forward_delete(gtktext, end-start);

	if (newtext && end-start > 0)
		gtk_text_insert(gtktext, NULL, color, NULL, newtext, end-start);

	gtk_signal_handler_unblock_by_func(GTK_OBJECT(gtktext), 
			GTK_SIGNAL_FUNC(entry_insert_cb), NULL);
	gtk_text_thaw(gtktext);
	g_free(newtext);
}
Exemple #8
0
static void
set_text_buffer(GtkWidget *widget, const char *text)
{
	GtkText *buffer;

	g_return_if_fail(widget);
	g_return_if_fail(text);

	buffer = GTK_TEXT(widget);
	g_return_if_fail(buffer);

	gtk_text_freeze(buffer);
	gtk_text_set_point(buffer, 0);
	gtk_text_forward_delete(buffer, gtk_text_get_length(buffer));
	gtk_text_set_point(buffer, 0);
	gtk_text_insert(buffer, NULL, NULL, NULL,
		lazy_utf8_to_ui_string(text), (-1));
	gtk_text_thaw(buffer);
}
Exemple #9
0
EXPORT void wTextClear(
		wText_p bt )
{
#ifdef USE_TEXTVIEW
	GtkTextBuffer * tb;
#endif
	if (bt->text == 0) abort();
#ifdef USE_TEXTVIEW
	tb = gtk_text_view_get_buffer( GTK_TEXT_VIEW(bt->text) );
	gtk_text_buffer_set_text( tb, "", -1 );
	if (bt->option & BO_READONLY)
		gtk_text_view_set_editable( GTK_TEXT_VIEW(bt->text), FALSE );
#else
	gtk_text_set_point( GTK_TEXT(bt->text), 0 );
	gtk_text_forward_delete( GTK_TEXT(bt->text), gtk_text_get_length( GTK_TEXT(bt->text) ) );
	if (bt->option & BO_READONLY)
		gtk_text_set_editable( GTK_TEXT(bt->text), FALSE );
#endif
	bt->changed = FALSE;
}
Exemple #10
0
void
clear_text_page(gboolean add, gint *uncommitted)
{
    guint len;
    gint  ucm;

    ucm = *uncommitted;
    gtk_entry_set_text(GTK_ENTRY(sp->title_entry), "");
    if (add == TRUE)
    {
        time_label_set_time(TIME_LABEL(sp->tlabel_created), time(NULL));
    }
    else
    {
        time_label_set_time(TIME_LABEL(sp->tlabel_created), -1);
    }
    time_label_set_time(TIME_LABEL(sp->tlabel_changed), -1);
    if (add == TRUE)
    {
        gtk_label_set_text(GTK_LABEL(sp->label_changes), _("0"));
    }
    else
    {
        gtk_label_set_text(GTK_LABEL(sp->label_changes), "");
    }
    time_label_set_time(TIME_LABEL(sp->tlabel_expire), -1);
    gtk_entry_set_text(GTK_ENTRY(sp->note_id_entry), "");
    gnome_date_edit_set_time(GNOME_DATE_EDIT(sp->de_deadline), 0);
    gtk_entry_set_text(GTK_ENTRY(sp->prio_entry), "");
    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(sp->todo_check), FALSE);
    gtk_adjustment_set_value(GTK_ADJUSTMENT(sp->ad_complete), 0);
    len = gtk_text_get_length(GTK_TEXT(sp->text_entry));
    if (len)
    {
        gtk_text_freeze(GTK_TEXT(sp->text_entry));
        gtk_text_set_point(GTK_TEXT(sp->text_entry), 0);
        gtk_text_forward_delete(GTK_TEXT(sp->text_entry), len);
        gtk_text_thaw(GTK_TEXT(sp->text_entry));
    }
    *uncommitted = ucm;
}
Exemple #11
0
static void 
sfe_ui_TreeSelectionChanged( GtkWidget *tree )
    {
    GList *itemlist;
    gchar *name;
    GtkBox *hbox;
    GtkLabel *label;
    GtkWidget *item;
    pStructInf infptr, subinf;
    gchar* annotation;
    int i;
    gchar* rowtext[2];
    gchar intbuf[32];
    char* strval;
    int intval;

	/** Get the hidden label which contains the pointer to the inf **/
	if (!tree) return;
	itemlist = GTK_TREE_SELECTION(tree);
	if (!itemlist) return;
	item = GTK_WIDGET (itemlist->data);
	if (!item) return;
	hbox = GTK_BOX (GTK_BIN (item)->child);
	label = GTK_LABEL (((GtkBoxChild*)(hbox->children->next->next->data))->widget);
	gtk_label_get (label, &name);
	infptr = (pStructInf)(strtol(name, NULL, 16));
	if (!infptr) return;

	/** Show the info on the right side of the window **/
	gtk_entry_set_text(GTK_ENTRY(SFE_Globals.NameEdit), infptr->Name);
	gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(SFE_Globals.TypeCombo)->entry), infptr->UsrType);
	gtk_text_set_point(GTK_TEXT(SFE_Globals.AnnotText), 0);
	gtk_text_forward_delete(GTK_TEXT(SFE_Globals.AnnotText), gtk_text_get_length(GTK_TEXT(SFE_Globals.AnnotText)));
	annotation="";
	stAttrValue(stLookup(infptr,"annotation"), NULL, &annotation, 0);
	gtk_text_insert(GTK_TEXT(SFE_Globals.AnnotText), NULL, NULL, NULL, annotation, strlen(annotation));

	/** Build the attributes listing **/
	gtk_clist_clear(GTK_CLIST(SFE_Globals.AttrsCList));
	for(i=0;i<infptr->nSubInf;i++)
	    {
	    subinf = infptr->SubInf[i];
	    if (stStructType(subinf) == ST_T_ATTRIB)
		{
		strval = NULL;
		stAttrValue(subinf, &intval, &strval, 0);
		rowtext[0] = subinf->Name;
		if (strval)
		    {
		    rowtext[1] = strval;
		    }
		else
		    {
		    snprintf(intbuf, 32, "%d", intval);
		    rowtext[1] = intbuf;
		    }
		gtk_clist_append(GTK_CLIST(SFE_Globals.AttrsCList), rowtext);
		}
	    }

    return;
    }
Exemple #12
0
void
selection_received (GtkWidget *widget, GtkSelectionData *data)
{
  int position;
  int i;
  SelType seltype;
  char *str;
  
  if (data->length < 0)
    {
      g_print("Error retrieving selection\n");
      return;
    }

  seltype = SEL_TYPE_NONE;
  for (i=0; i<LAST_SEL_TYPE; i++)
    {
      if (seltypes[i] == data->type)
	{
	  seltype = i;
	  break;
	}
    }

  if (seltype == SEL_TYPE_NONE)
    {
      char *name = gdk_atom_name (data->type);
      g_print("Don't know how to handle type: %s\n",
	      name?name:"<unknown>");
      return;
    }

  if (selection_string != NULL)
    g_string_free (selection_string, TRUE);

  selection_string = g_string_new (NULL);

  gtk_text_freeze (GTK_TEXT (selection_text));
  gtk_text_set_point (GTK_TEXT (selection_text), 0);
  gtk_text_forward_delete (GTK_TEXT (selection_text), 
			   gtk_text_get_length (GTK_TEXT (selection_text)));

  position = 0;
  while (position < data->length)
    {
      switch (seltype)
	{
	case ATOM:
	  str = stringify_atom (data->data, &position);
	  break;
	case COMPOUND_TEXT:
	case STRING:
	case TEXT:
	  str = stringify_text (data->data, &position);
	  break;
	case BITMAP:
	case DRAWABLE:
	case PIXMAP:
	case WINDOW:
	case COLORMAP:
	  str = stringify_xid (data->data, &position);
	  break;
	case INTEGER:
	case PIXEL:
	  str = stringify_integer (data->data, &position);
	  break;
	case SPAN:
	  str = stringify_span (data->data, &position);
	  break;
	default:
	  {
	    char *name = gdk_atom_name (data->type);
	    g_print("Can't convert type %s to string\n",
		    name?name:"<unknown>");
	    position = data->length;
	    continue;
	  }
	}
      gtk_text_insert (GTK_TEXT (selection_text), NULL, 
		       &selection_text->style->black, 
		       NULL, str, -1);
      gtk_text_insert (GTK_TEXT (selection_text), NULL, 
		       &selection_text->style->black, 
		       NULL, "\n", -1);
      g_string_append (selection_string, str);
      g_free (str);
    }
  gtk_text_thaw (GTK_TEXT (selection_text));
}
Exemple #13
0
static void
fdriverchooser_switch_page (GtkNotebook * notebook, GtkNotebookPage * page,
    gint page_num, TFDRIVERCHOOSER * choose_t)
{
  guint len;
  char  buff[1024];
  char *dsn = {""};
  char *drv = {""};
  char *curr;

  if (choose_t)
    {
      switch (page_num)
	{
	case 0:
	  if (choose_t->b_back)
	    gtk_widget_set_sensitive (choose_t->b_back, FALSE);
	  if (choose_t->b_continue)
            gtk_label_parse_uline(GTK_LABEL(GTK_BIN (choose_t->b_continue)->child),
               "Continue");
	  break;

	case 1:
	  if (choose_t->driverlist && choose_t->tab_panel && GTK_CLIST (choose_t->driverlist)->selection == NULL)
	    {
	      _iodbcdm_messagebox(choose_t->mainwnd, NULL, "Driver wasn't selected!");
              gtk_notebook_set_page (GTK_NOTEBOOK (choose_t->tab_panel), 0);
              break;
	    }
	  if (choose_t->b_back)
	    gtk_widget_set_sensitive (choose_t->b_back, TRUE);
	  if (choose_t->b_continue)
            gtk_label_parse_uline(GTK_LABEL(GTK_BIN (choose_t->b_continue)->child),
               "Co_ntinue");
	  break;
	case 2:
	  if (choose_t->driverlist && choose_t->tab_panel && choose_t->dsn_entry)
	    {
              if (GTK_CLIST (choose_t->driverlist)->selection != NULL)
                {
	          gtk_clist_get_text (GTK_CLIST (choose_t->driverlist),
	            GPOINTER_TO_INT(GTK_CLIST(choose_t->driverlist)->selection->data),
	            0, &drv);
	        }
	      else
	        {
	          _iodbcdm_messagebox(choose_t->mainwnd, NULL, "Driver wasn't selected!");
                  gtk_notebook_set_page (GTK_NOTEBOOK (choose_t->tab_panel), 0);
                  break;
	        }

              dsn = gtk_entry_get_text(GTK_ENTRY(choose_t->dsn_entry));
              if (strlen(dsn) < 1)
                {
	          _iodbcdm_messagebox(choose_t->mainwnd, NULL, "Enter File DSN Name...");
                  gtk_notebook_set_page (GTK_NOTEBOOK (choose_t->tab_panel), 1);
                  break;
                }
            }

	  if (choose_t->b_back)
	    gtk_widget_set_sensitive (choose_t->b_back, TRUE);
	  if (choose_t->b_continue)
            gtk_label_parse_uline(GTK_LABEL(GTK_BIN (choose_t->b_continue)->child),
                 "_Finish");

          if (choose_t->mess_entry)
            {
#if GTK_CHECK_VERSION(2,0,0)
              GtkTextBuffer *gbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(choose_t->mess_entry));
              GtkTextIter *iter;

              gtk_text_buffer_set_text(gbuf, "", 0);

              if (strchr(dsn, '/') != NULL)
                snprintf(buff, sizeof(buff), "Filename: %s\n", dsn);
              else
                snprintf(buff, sizeof(buff), "Filename: %s/%s\n", choose_t->curr_dir, dsn);

              gtk_text_buffer_insert_at_cursor(gbuf, buff, -1);

              snprintf(buff, sizeof(buff), "Driver: %s\n", drv);
              gtk_text_buffer_insert_at_cursor(gbuf, buff, -1);

              gtk_text_buffer_insert_at_cursor(gbuf, "Driver-specific Keywords:\n", -1);

              if (choose_t->attrs)
                {
                  for (curr = choose_t->attrs; *curr; curr += (STRLEN (curr) + 1))
                    {
                      if (!strncasecmp (curr, "PWD=", STRLEN ("PWD=")))
	                continue;

                      if (curr)
                        gtk_text_buffer_insert_at_cursor(gbuf, curr, -1);

                      gtk_text_buffer_insert_at_cursor(gbuf, "\n", -1);
                    }
                }
#else
              gtk_text_set_point(GTK_TEXT(choose_t->mess_entry), 0);
              len = gtk_text_get_length(GTK_TEXT(choose_t->mess_entry));
              gtk_text_forward_delete(GTK_TEXT(choose_t->mess_entry), len);
              gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, "File Data Source\n", -1);

              if (strchr(dsn, '/') != NULL)
                snprintf(buff, sizeof(buff), "Filename: %s\n", dsn);
              else
                snprintf(buff, sizeof(buff), "Filename: %s/%s\n", choose_t->curr_dir, dsn);
              gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, buff, -1);

              snprintf(buff, sizeof(buff), "Driver: %s\n", drv);
              gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, buff, -1);

              gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, "Driver-specific Keywords:\n", -1);

              if (choose_t->attrs)
                {
                  for (curr = choose_t->attrs; *curr; curr += (STRLEN (curr) + 1))
                    {
                      if (!strncasecmp (curr, "PWD=", STRLEN ("PWD=")))
                        {
	                  continue;
   	                }
                      gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, curr, -1);
                      gtk_text_insert(GTK_TEXT(choose_t->mess_entry), NULL, NULL, NULL, "\n", -1);
                    }
                }
#endif
            }
	  break;
	}
    }
}
static void
handle_input(gpointer client_data, gint source, GdkInputCondition ic)
{
    int message;

    gtk_pipe_int_read(&message);

    switch (message) {
    case REFRESH_MESSAGE:
	g_warning("REFRESH MESSAGE IS OBSOLETE !!!");
	break;

    case TOTALTIME_MESSAGE:
	{
	    int tt;
	    int minutes,seconds;
	    char local_string[20];
	    GtkObject *adj;

	    gtk_pipe_int_read(&tt);

	    seconds=max_sec=tt/play_mode->rate;
	    minutes=seconds/60;
	    seconds-=minutes*60;
	    sprintf(local_string,"/ %i:%02i",minutes,seconds);
	    gtk_label_set(GTK_LABEL(tot_lbl), local_string);

	    /* Readjust the time scale */
	    adj = gtk_adjustment_new(0., 0., (gfloat)max_sec,
				     1., 10., 0.);
	    gtk_signal_connect(GTK_OBJECT(adj), "value_changed",
			       GTK_SIGNAL_FUNC(generic_scale_cb),
			       (gpointer)GTK_CHANGE_LOCATOR);
	    gtk_range_set_adjustment(GTK_RANGE(locator),
				     GTK_ADJUSTMENT(adj));
	}
	break;

    case MASTERVOL_MESSAGE:
	{
	    int volume;
	    GtkAdjustment *adj;

	    gtk_pipe_int_read(&volume);
	    adj = gtk_range_get_adjustment(GTK_RANGE(vol_scale));
	    my_adjustment_set_value(adj, MAX_AMPLIFICATION - volume);
	}
	break;

    case FILENAME_MESSAGE:
	{
	    char filename[255], title[255];
	    char *pc;

	    gtk_pipe_string_read(filename);

	    /* Extract basename of the file */
	    pc = strrchr(filename, '/');
	    if (pc == NULL)
		pc = filename;
	    else
		pc++;

	    sprintf(title, "Timidity %s - %s", timidity_version, pc);
	    gtk_window_set_title(GTK_WINDOW(window), title);

	    /* Clear the text area. */
#ifdef HAVE_GTK_2
	    textbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
	    gtk_text_buffer_get_start_iter(textbuf, &start_iter);
	    gtk_text_buffer_get_end_iter(textbuf, &end_iter);
	    iter = start_iter;
#else
	    gtk_text_freeze(GTK_TEXT(text));
	    gtk_text_set_point(GTK_TEXT(text), 0);
	    gtk_text_forward_delete(GTK_TEXT(text),
				    gtk_text_get_length(GTK_TEXT(text)));
	    gtk_text_thaw(GTK_TEXT(text));
#endif
	}
	break;

    case FILE_LIST_MESSAGE:
	{
	    gchar filename[255], *fnames[2];
	    gint i, number_of_files;

	    /* reset the playing list : play from the start */
	    file_number_to_play = -1;

	    gtk_pipe_int_read(&number_of_files);
	    for (i = 0; i < number_of_files; i++)
	    {
		gtk_pipe_string_read(filename);
		fnames[0] = filename;
		fnames[1] = NULL;
		gtk_clist_append(GTK_CLIST(clist), fnames);
	    }
	    gtk_clist_columns_autosize(GTK_CLIST(clist));
	}
	break;

    case NEXT_FILE_MESSAGE:
    case PREV_FILE_MESSAGE:
    case TUNE_END_MESSAGE:
	{
	    int nbfile;

	    /* When a file ends, launch next if auto_next toggle */
	    if ( (message==TUNE_END_MESSAGE) &&
		 !GTK_CHECK_MENU_ITEM(auto_next)->active )
		return;

	    /* Total number of file to play in the list */
	    nbfile = GTK_CLIST(clist)->rows;

	    if (message == PREV_FILE_MESSAGE)
		file_number_to_play--;
	    else
		file_number_to_play++;

	    /* Do nothing if requested file is before first one */
	    if (file_number_to_play < 0) {
		file_number_to_play = 0;
		return;
	    }

	    /* Stop after playing the last file */
	    if (file_number_to_play >= nbfile) {
		file_number_to_play = nbfile - 1;
		return;
	    }

	    if(gtk_clist_row_is_visible(GTK_CLIST(clist),
					file_number_to_play) !=
	       GTK_VISIBILITY_FULL) {
		gtk_clist_moveto(GTK_CLIST(clist), file_number_to_play,
				 -1, 1.0, 0.0);
	    }
	    gtk_clist_select_row(GTK_CLIST(clist), file_number_to_play, 0);
	}
	break;

    case CURTIME_MESSAGE:
	{
	    int		seconds, minutes;
	    int		nbvoice;
	    char	local_string[20];

	    gtk_pipe_int_read(&seconds);
	    gtk_pipe_int_read(&nbvoice);

	    if( is_quitting )
		return;

	    minutes=seconds/60;

	    sprintf(local_string,"%2d:%02d", minutes, (int)(seconds % 60));

	    gtk_label_set(GTK_LABEL(cnt_lbl), local_string);

	    /* Readjust the time scale if not dragging the scale */
	    if( !locating && (seconds <= max_sec)) {
		GtkAdjustment *adj;

		adj = gtk_range_get_adjustment(GTK_RANGE(locator));
		my_adjustment_set_value(adj, (gfloat)seconds);
	    }
	}
	break;

    case NOTE_MESSAGE:
	{
	    int channel;
	    int note;

	    gtk_pipe_int_read(&channel);
	    gtk_pipe_int_read(&note);
	    g_warning("NOTE chn%i %i", channel, note);
	}
	break;

    case PROGRAM_MESSAGE:
	{
	    int channel;
	    int pgm;

	    gtk_pipe_int_read(&channel);
	    gtk_pipe_int_read(&pgm);
	    g_warning("NOTE chn%i %i", channel, pgm);
	}
	break;

    case VOLUME_MESSAGE:
	{
	    int channel;
	    int volume;

	    gtk_pipe_int_read(&channel);
	    gtk_pipe_int_read(&volume);
	    g_warning("VOLUME= chn%i %i", channel, volume);
	}
	break;


    case EXPRESSION_MESSAGE:
	{
	    int channel;
	    int express;

	    gtk_pipe_int_read(&channel);
	    gtk_pipe_int_read(&express);
	    g_warning("EXPRESSION= chn%i %i", channel, express);
	}
	break;

    case PANNING_MESSAGE:
	{
	    int channel;
	    int pan;

	    gtk_pipe_int_read(&channel);
	    gtk_pipe_int_read(&pan);
	    g_warning("PANNING= chn%i %i", channel, pan);
	}
	break;

    case SUSTAIN_MESSAGE:
	{
	    int channel;
	    int sust;

	    gtk_pipe_int_read(&channel);
	    gtk_pipe_int_read(&sust);
	    g_warning("SUSTAIN= chn%i %i", channel, sust);
	}
	break;

    case PITCH_MESSAGE:
	{
	    int channel;
	    int bend;

	    gtk_pipe_int_read(&channel);
	    gtk_pipe_int_read(&bend);
	    g_warning("PITCH BEND= chn%i %i", channel, bend);
	}
	break;

    case RESET_MESSAGE:
	g_warning("RESET_MESSAGE");
	break;

    case CLOSE_MESSAGE:
	gtk_exit(0);
	break;

    case CMSG_MESSAGE:
	{
	    int type;
	    char message[1000];
#ifdef HAVE_GTK_2
	    gchar *message_u8;
#endif

	    gtk_pipe_int_read(&type);
	    gtk_pipe_string_read(message);
#ifdef HAVE_GTK_2
	    message_u8 = g_locale_to_utf8( message, -1, NULL, NULL, NULL );
	    gtk_text_buffer_get_bounds(textbuf, &start_iter, &end_iter);
	    gtk_text_buffer_insert(textbuf, &end_iter,
			    message_u8, -1);
	    gtk_text_buffer_insert(textbuf, &end_iter,
			    "\n", 1);
	    gtk_text_buffer_get_bounds(textbuf, &start_iter, &end_iter);

	    mark = gtk_text_buffer_create_mark(textbuf, NULL, &end_iter, 1);
	    gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(text), mark, 0.0, 0, 0.0, 1.0);
	    gtk_text_buffer_delete_mark(textbuf, mark);
	    g_free( message_u8 );
#else
	    gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
			    message, -1);
	    gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
			    "\n", 1);
#endif
	}
	break;
    case LYRIC_MESSAGE:
	{
	    char message[1000];
#ifdef HAVE_GTK_2
	    gchar *message_u8;
#endif

	    gtk_pipe_string_read(message);

#ifdef HAVE_GTK_2
	    message_u8 = g_locale_to_utf8( message, -1, NULL, NULL, NULL );
	    gtk_text_buffer_get_bounds(textbuf, &start_iter, &end_iter);
	    // mod JN iter -> end_iter
	    gtk_text_buffer_insert(textbuf, &end_iter,
			    message_u8, -1);
	    gtk_text_buffer_get_bounds(textbuf, &start_iter, &end_iter);

	    mark = gtk_text_buffer_create_mark(textbuf, NULL, &end_iter, 1);
	    gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(text), mark, 0.0, 0, 0.0, 1.0);
	    gtk_text_buffer_delete_mark(textbuf, mark);
#else
	    gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
			    message, -1);
#endif
	}
	break;
    default:
	g_warning("UNKNOWN Gtk+ MESSAGE %i", message);
    }
}
Exemple #15
0
static void logbox_reload_single(GtkWidget *window, GtkWidget *text, char *default_text)
{
    FILE *handle;
    struct wave_logfile_lines_t *wlog_head=NULL, *wlog_curr=NULL;
    int wlog_size = 0;

    handle = fopen(default_text, "rb");
    if(!handle)
	{
	char *buf = malloc_2(strlen(default_text)+128);
	sprintf(buf, "Could not open logfile '%s'\n", default_text);
	status_text(buf);
	free_2(buf);
	return;
	}

#if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN)
    {
    GtkTextIter st_iter, en_iter;
  
    gtk_text_buffer_get_start_iter(GTK_TEXT_VIEW (text)->buffer, &st_iter);
    gtk_text_buffer_get_end_iter(GTK_TEXT_VIEW (text)->buffer, &en_iter);
    gtk_text_buffer_delete(GTK_TEXT_VIEW (text)->buffer, &st_iter, &en_iter);

    gtk_text_buffer_get_start_iter (GTK_TEXT_VIEW (text)->buffer, &GLOBALS->iter_logfile_c_2);
    }
#else
    {
    guint len = gtk_text_get_length(GTK_TEXT(text));
    gtk_text_set_point(GTK_TEXT(text), 0);

    gtk_text_freeze(GTK_TEXT(text)); 
    gtk_text_forward_delete (GTK_TEXT(text), len);
    }
#endif

    log_text_bold(text, NULL, "Click-select");
    log_text(text, NULL, " on numbers to jump to that time value in the wave viewer.\n");
    log_text(text, NULL, " \n");

    while(!feof(handle))
	{
	char *pnt = fgetmalloc(handle);
	if(pnt)
		{
		struct wave_logfile_lines_t *w = calloc_2(1, sizeof(struct wave_logfile_lines_t));

		wlog_size += (GLOBALS->fgetmalloc_len+1);
		w->text = pnt;
		if(!wlog_curr) { wlog_head = wlog_curr = w; } else { wlog_curr->next = w; wlog_curr = w; }
		}
	}

    if(wlog_curr)
	{
	struct wave_logfile_lines_t *w = wlog_head;
	struct wave_logfile_lines_t *wt;
	char *pnt = malloc_2(wlog_size + 1);
	char *pnt2 = pnt;

	while(w)
		{
		int len = strlen(w->text);
		memcpy(pnt2, w->text, len);
		pnt2 += len;
		*pnt2 = '\n';
		pnt2++;

		free_2(w->text);
		wt = w;
		w = w->next;
		free_2(wt);
		}
	/* wlog_head = */ wlog_curr = NULL; /* scan-build */
	*pnt2 = 0;
	log_text(text, GLOBALS->font_logfile_c_1, pnt);
	free_2(pnt);
	}

#if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN)
#else
    gtk_text_thaw(GTK_TEXT(text));
#endif

    fclose(handle);
}