Пример #1
0
void wxTextCtrl::SetInsertionPoint( long pos )
{
    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );

    if ( IsMultiLine() )
    {
        gtk_signal_disconnect_by_func( GTK_OBJECT(m_text),
                                       GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);

        /* we fake a set_point by inserting and deleting. as the user
           isn't supposed to get to know about this non-sense, we
           disconnect so that no events are sent to the user program. */

        gint tmp = (gint)pos;
        gtk_editable_insert_text( GTK_EDITABLE(m_text), " ", 1, &tmp );
        gtk_editable_delete_text( GTK_EDITABLE(m_text), tmp-1, tmp );

        gtk_signal_connect( GTK_OBJECT(m_text), "changed",
                            GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);

        // bring editable's cursor uptodate. Bug in GTK.
        SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
    }
    else
    {
        gtk_entry_set_position( GTK_ENTRY(m_text), (int)pos );

        // Bring editable's cursor uptodate. Bug in GTK.
        SET_EDITABLE_POS(m_text, (guint32)pos);
    }
}
int
x_create_input (Dlg_head *h, widget_data parent, WInput *in)
{
	GtkWidget *gnome_entry;
	GtkEntry *entry;

	/* The widget might have been initialized manually.
	 * Look in gscreen.c for an example
	 */
	if (in->widget.wdata)
		return 1;

#ifdef USE_GNOME_ENTRY
	gnome_entry = gnome_entry_new (in->widget.tkname);
#else
	entry = GTK_ENTRY (gnome_entry = gtk_entry_new ());
	gtk_entry_set_visibility (entry, !in->is_password);
#endif
	gtk_widget_show (gnome_entry);
	in->widget.wdata = (widget_data) gnome_entry;

#ifdef USE_GNOME_ENTRY
	entry = GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (gnome_entry)));
#endif
	gtk_entry_set_text (entry, in->buffer);
	gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
	gtk_entry_set_position (entry, in->point);
	
	gtk_signal_connect (GTK_OBJECT (entry), "button_press_event",
			    GTK_SIGNAL_FUNC (entry_click), in);

	gtk_signal_connect (GTK_OBJECT (entry), "button_release_event",
			    GTK_SIGNAL_FUNC (entry_release), in);
	return 1;
}
Пример #3
0
GtkWidget *MakeStrEntry(GtkWidget **entry,char *var,char *name,
			int len,gboolean editable)
{
  GtkWidget *widget;
  GtkWidget *label;
  GtkWidget *hbox;

  hbox=gtk_hbox_new(FALSE,5);

  label=gtk_label_new(name);
  gtk_label_set_justify(GTK_LABEL(label),GTK_JUSTIFY_LEFT);
  gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
  gtk_widget_show(label);

  widget=gtk_entry_new_with_max_length(len);
  gtk_entry_set_editable(GTK_ENTRY(widget),editable);
  if(var) {
    gtk_entry_set_text(GTK_ENTRY(widget),var);

    gtk_signal_connect(GTK_OBJECT(widget),"changed",
		       GTK_SIGNAL_FUNC(ChangeStrVal),(gpointer)var);
  }

  gtk_box_pack_start(GTK_BOX(hbox),widget,TRUE,TRUE,0);

  gtk_entry_set_position(GTK_ENTRY(widget),0);

  gtk_widget_show(widget);

  if(entry) *entry=widget;

  return hbox;
}
Пример #4
0
void combo_set_vals (GtkWidget *combo, GList *strlist, const char *str) {

	g_return_if_fail(GTK_IS_COMBO(combo));

	if (!strlist) {
		gtk_list_clear_items (GTK_LIST (GTK_COMBO (combo)->list), 0, -1);
	} else {
		/*
		 *  gtk_combo_set_popdown_strings (actually gtk_list_insert_items) 
		 *  automatically selects the first one and puts it into entry.  
		 *  That should not happen.  Drop selection mode for a moment 
		 *  to prevent that.
		 */

		gtk_list_set_selection_mode (GTK_LIST (GTK_COMBO (combo)->list),
				GTK_SELECTION_SINGLE);
		gtk_combo_set_popdown_strings (GTK_COMBO (combo), strlist);
		gtk_list_set_selection_mode (GTK_LIST (GTK_COMBO (combo)->list),
				GTK_SELECTION_BROWSE);
	}

	if (str) {
		gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry), str);
		gtk_entry_set_position (GTK_ENTRY (GTK_COMBO (combo)->entry), 0);
	}
	else {
		gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry), "");
	}
}
Пример #5
0
// performs actions for key down events (esc, tab)
static gboolean check_key_down(GtkWidget* wisget, GdkEventKey *event, gpointer data)
{
	const gchar* entry = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
	
	int numMatches = g_list_length(matches);
	gchar* match;

	switch (event->keyval)
	{
		case GDK_KEY_Escape:
			#if DEBUG
				printf("ESC pressed!\n");
			#endif
			die();		
		case GDK_KEY_Tab:
			
			#if DEBUG
				printf("Tab DOWN. Found %d matches\n", numMatches);
			#endif
			
			// if there were no matches just delete the entry text
			if (numMatches == 0)
			{
				gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), "");
				break;
			}
			
			match = matches->data;

			// has the entry changed since hitting tab?
			if (g_strcmp0(old_entry, entry) == 0)
			{
				#if DEBUG
					printf("Entry has not changed! ");
					printf("%d < %d? %d\n", current_match_index, numMatches-1, (current_match_index < numMatches-1));
				#endif

				if (current_match_index < numMatches-1)
				{
					match = g_list_nth(matches, ++current_match_index)->data;
				}
				else // at the end, wrap around
				{	
					current_match_index = 0;
					match = g_list_nth(matches, current_match_index)->data;
				}
			}
			
			// whatever has been found, set it in the entry box
			gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), match);		
			gtk_entry_set_position(GTK_ENTRY(GTK_COMBO(combo)->entry), strlen(match));
			break;
	}
	
	old_entry = g_strdup(entry);
	return FALSE;
}
Пример #6
0
void wxComboBox::SetInsertionPoint( long pos )
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );

    if ( pos == GetLastPosition() )
        pos = -1;

    GtkWidget *entry = GTK_COMBO(m_widget)->entry;
    gtk_entry_set_position( GTK_ENTRY(entry), (int)pos );
}
Пример #7
0
void wxTextCtrl::SetInsertionPointEnd()
{
    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );

    if (m_windowStyle & wxTE_MULTILINE)
    {
        SetInsertionPoint(gtk_text_get_length(GTK_TEXT(m_text)));
    }
    else
    {
        gtk_entry_set_position( GTK_ENTRY(m_text), -1 );
    }
}
Пример #8
0
static void
ascii_click (GtkWidget * wid, int c)
{
	int tmp_pos;
	unsigned char str = c;

	if (menu_sess)
	{
		wid = menu_sess->gui->inputgad;
		tmp_pos = gtk_editable_get_position (GTK_EDITABLE (wid));
		gtk_editable_insert_text (GTK_EDITABLE (wid), &str, 1, &tmp_pos);
		gtk_entry_set_position (GTK_ENTRY (wid), tmp_pos);
	}
}
Пример #9
0
void SetArtist(GripInfo *ginfo,char *artist)
{
  g_signal_handlers_block_by_func(G_OBJECT(ginfo->gui_info.artist_edit_entry),
                                  ArtistEditChanged,(gpointer)ginfo);

  gtk_entry_set_text(GTK_ENTRY(ginfo->gui_info.artist_edit_entry),artist);
  gtk_entry_set_position(GTK_ENTRY(ginfo->gui_info.artist_edit_entry),0);

  strcpy(ginfo->ddata.data_artist,artist);
  gtk_label_set(GTK_LABEL(ginfo->gui_info.disc_artist_label),artist);

  g_signal_handlers_unblock_by_func(G_OBJECT(ginfo->gui_info.artist_edit_entry),
                                    ArtistEditChanged,(gpointer)ginfo);
}
Пример #10
0
void SetTitle(GripInfo *ginfo,char *title)
{
  g_signal_handlers_block_by_func(G_OBJECT(ginfo->gui_info.title_edit_entry),
                                  TitleEditChanged,(gpointer)ginfo);

  gtk_entry_set_text(GTK_ENTRY(ginfo->gui_info.title_edit_entry),title);
  gtk_entry_set_position(GTK_ENTRY(ginfo->gui_info.title_edit_entry),0);

  strcpy(ginfo->ddata.data_title,title);
  gtk_label_set(GTK_LABEL(ginfo->gui_info.disc_name_label),title);

  g_signal_handlers_unblock_by_func(G_OBJECT(ginfo->gui_info.title_edit_entry),
                                    TitleEditChanged,(gpointer)ginfo);
}
Пример #11
0
void wxTextCtrl::WriteText( const wxString &text )
{
    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );

    if ( text.empty() )
        return;

    // gtk_text_changed_callback() will set m_modified to true but m_modified
    // shouldn't be changed by the program writing to the text control itself,
    // so save the old value and restore when we're done
    bool oldModified = m_modified;

    if ( m_windowStyle & wxTE_MULTILINE )
    {
        // After cursor movements, gtk_text_get_point() is wrong by one.
        gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) );

        // always use m_defaultStyle, even if it is empty as otherwise
        // resetting the style and appending some more text wouldn't work: if
        // we don't specify the style explicitly, the old style would be used
        gtk_editable_delete_selection( GTK_EDITABLE(m_text) );
        wxGtkTextInsert(m_text, m_defaultStyle, text.c_str(), text.length());

        // we called wxGtkTextInsert with correct font, no need to do anything
        // in UpdateFontIfNeeded() any longer
        if ( !text.empty() )
        {
            SetUpdateFont(false);
        }

        // Bring editable's cursor back uptodate.
        SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
    }
    else // single line
    {
        // First remove the selection if there is one
        gtk_editable_delete_selection( GTK_EDITABLE(m_text) );

        // This moves the cursor pos to behind the inserted text.
        gint len = GET_EDITABLE_POS(m_text);

        gtk_editable_insert_text( GTK_EDITABLE(m_text), text.c_str(), text.length(), &len );

        // Bring entry's cursor uptodate.
        gtk_entry_set_position( GTK_ENTRY(m_text), len );
    }

    m_modified = oldModified;
}
Пример #12
0
void wxComboBox::SetInsertionPoint( long pos )
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );

    if ( pos == GetLastPosition() )
        pos = -1;

    GtkEntry *entry = NULL;
#ifdef __WXGTK24__
    if (!gtk_check_version(2,4,0))
        entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
    else
#endif
        entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );

    gtk_entry_set_position( entry, (int)pos );
}
void
x_update_input (WInput *in)
{
	GnomeEntry *gnome_entry;
	GtkEntry   *entry;
	char       *text;
	int        draw = 0;
	
	/* If the widget has not been initialized yet (done by WIDGET_INIT) */
	if (!in->widget.wdata)
		return;

#ifdef USE_GNOME_ENTRY
	gnome_entry = GNOME_ENTRY (in->widget.wdata);
	entry = GTK_ENTRY (gnome_entry_gtk_entry (gnome_entry));
#else
	entry = GTK_ENTRY (in->widget.wdata);
#endif

	if (in->first == -1){
		gtk_editable_select_region (GTK_EDITABLE (entry), 0, 0);
		in->first = 0;
	}

	text = gtk_entry_get_text (GTK_ENTRY (entry));
	
	if (text && strcmp (text, in->buffer)){
		gtk_entry_set_text (entry, in->buffer);
		draw = 1;
	}      

	if (GTK_EDITABLE (entry)->current_pos != in->point){
		gtk_entry_set_position (entry, in->point);
		draw = 1;
	}
	
	if (draw){
#ifdef USE_GNOME_ENTRY
		gtk_widget_draw (GTK_WIDGET (gnome_entry), NULL);
#else
		gtk_widget_draw (GTK_WIDGET (entry), NULL);
#endif
		gtk_editable_changed (GTK_EDITABLE (entry));
		gtk_widget_queue_draw (GTK_WIDGET (entry));
	}
}
Пример #14
0
static void input_dialog_set(const gchar *title, const gchar *message,
			     const gchar *default_string)
{
	GtkWidget *entry_;

	if (type == INPUT_DIALOG_COMBO)
		entry_ = GTK_COMBO(combo)->entry;
	else
		entry_ = entry;

	gtk_window_set_title(GTK_WINDOW(dialog), title);
	gtk_label_set_text(GTK_LABEL(msg_label), message);
	if (default_string && *default_string) {
		gtk_entry_set_text(GTK_ENTRY(entry_), default_string);
		gtk_entry_set_position(GTK_ENTRY(entry_), 0);
		gtk_entry_select_region(GTK_ENTRY(entry_), 0, -1);
	} else
		gtk_entry_set_text(GTK_ENTRY(entry_), "");

	gtk_widget_grab_focus(ok_button);
	gtk_widget_grab_focus(entry_);
}
Пример #15
0
static gboolean dialog_set_offset(int chan_num)
{
    scope_vert_t *vert;
    scope_chan_t *chan;
    dialog_generic_t dialog;
    gchar *title, msg[BUFLEN], *cptr;
    struct offset_data data;
    GtkWidget *label, *button;
    double tmp;

    vert = &(ctrl_usr->vert);
    chan = &(ctrl_usr->chan[chan_num - 1]);
    title = _("Set Offset");
    snprintf(msg, BUFLEN - 1, _("Set the vertical offset\n"
	"for channel %d."), chan_num);
    /* create dialog window, disable resizing */
    dialog.retval = 0;
    dialog.window = gtk_dialog_new();
    dialog.app_data = &data;
    /* allow user to grow but not shrink the window */
    gtk_window_set_policy(GTK_WINDOW(dialog.window), FALSE, TRUE, FALSE);
    /* window should appear in center of screen */
    gtk_window_set_position(GTK_WINDOW(dialog.window), GTK_WIN_POS_CENTER);
    /* set title */
    gtk_window_set_title(GTK_WINDOW(dialog.window), title);
    /* display message */
    label = gtk_label_new(msg);
    gtk_misc_set_padding(GTK_MISC(label), 15, 5);
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog.window)->vbox), label, FALSE,
	TRUE, 0);
    /* a separator */
    gtk_hseparator_new_in_box(GTK_DIALOG(dialog.window)->vbox, 0);
    /* a checkbox: AC coupled */
    vert->offset_ac = gtk_check_button_new_with_label(_("AC Coupled"));
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog.window)->vbox),
        vert->offset_ac, FALSE, TRUE, 0);
    /* react to changes to the checkbox */
    gtk_signal_connect(GTK_OBJECT(vert->offset_ac), "toggled",
	GTK_SIGNAL_FUNC(offset_changed), &data);
    /* the entry */
    vert->offset_entry = gtk_entry_new();
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog.window)->vbox),
	vert->offset_entry, FALSE, TRUE, 0);
    snprintf(data.buf, BUFLEN, "%f", chan->vert_offset);
    gtk_entry_set_text(GTK_ENTRY(vert->offset_entry), data.buf);
    gtk_entry_set_max_length(GTK_ENTRY(vert->offset_entry), BUFLEN-1);
    /* point at first char */
    gtk_entry_set_position(GTK_ENTRY(vert->offset_entry), 0);
    /* select all chars, so if the user types the original value goes away */
    gtk_entry_select_region(GTK_ENTRY(vert->offset_entry), 0, strlen(data.buf));
    /* make it active so user doesn't have to click on it */
    gtk_widget_grab_focus(GTK_WIDGET(vert->offset_entry));
    gtk_widget_show(vert->offset_entry);
    /* capture entry data to the buffer whenever the user types */
    gtk_signal_connect(GTK_OBJECT(vert->offset_entry), "changed",
	GTK_SIGNAL_FUNC(offset_changed), data.buf);
    /* set up a callback function when the window is destroyed */
    gtk_signal_connect(GTK_OBJECT(dialog.window), "destroy",
	GTK_SIGNAL_FUNC(dialog_generic_destroyed), &dialog);
    /* make OK and Cancel buttons */
    button = gtk_button_new_with_label(_("OK"));
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog.window)->action_area),
	button, TRUE, TRUE, 4);
    gtk_signal_connect(GTK_OBJECT(button), "clicked",
	GTK_SIGNAL_FUNC(dialog_generic_button1), &dialog);
    /* hit the "OK" button if the user hits enter */
    gtk_signal_connect(GTK_OBJECT(vert->offset_entry), "activate",
	GTK_SIGNAL_FUNC(offset_activated), button);
    button = gtk_button_new_with_label(_("Cancel"));
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog.window)->action_area),
	button, TRUE, TRUE, 4);
    gtk_signal_connect(GTK_OBJECT(button), "clicked",
	GTK_SIGNAL_FUNC(dialog_generic_button2), &dialog);
    /* make window transient and modal */
    gtk_window_set_transient_for(GTK_WINDOW(dialog.window),
	GTK_WINDOW(ctrl_usr->main_win));
    gtk_window_set_modal(GTK_WINDOW(dialog.window), TRUE);
    gtk_widget_show_all(dialog.window);
    gtk_main();
    /* we get here when the user makes a selection, hits Cancel, or closes
       the window */
    if ((dialog.retval == 0) || (dialog.retval == 2)) {
	/* user either closed dialog, or hit cancel */
	return FALSE;
    }
    tmp = strtod(data.buf, &cptr);
    if (cptr == data.buf) {
	return FALSE;
    }
    set_vert_offset(tmp, data.ac_coupled);
    return TRUE;
}
Пример #16
0
Файл: entry.c Проект: zdia/gnocl
/**
\brief
    Function associated with the widget.
*/
int entryFunc (
	ClientData data,
	Tcl_Interp *interp,
	int objc,
	Tcl_Obj * const objv[] )
{

#ifdef DEBUG_ENTRY  g_print ( "entryFunc\n" );
#endif


	static const char *cmds[] = { "delete", "configure", "cget", "onChanged", "class", "get", "clear", "set",  "setPosition", NULL };
	enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, OnChangedIdx, ClassIdx, GetIdx, ClearIdx, SetIdx, SetPositionIdx };

	EntryParams *para = ( EntryParams * ) data;
	//GtkWidget *widget = GTK_WIDGET ( para->entry );

	int idx;

	if ( objc < 2 )
	{
		Tcl_WrongNumArgs ( interp, 1, objv, "command" );
		return TCL_ERROR;
	}

	if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command",
							   TCL_EXACT, &idx ) != TCL_OK )
		return TCL_ERROR;

	switch ( idx )
	{
		case SetPositionIdx:
			{


				if ( 1 )
				{
					gtk_entry_set_position ( GTK_WIDGET ( para->entry ) , Tcl_GetString ( objv[2] ) );
				}

				else
				{
					gtk_editable_set_position ( GTK_EDITABLE ( GTK_WIDGET ( para->entry ) ) , Tcl_GetString ( objv[2] ) );
				}
			}

			break;
		case SetIdx:
			{
				/* simply set the text to nothing */
				gtk_entry_set_text ( para->entry, Tcl_GetString ( objv[2] ) );
			}

			break;
		case GetIdx:
			{
				/* equivalent to widget cget -value */
				Tcl_Obj *obj = NULL;

				obj = Tcl_NewStringObj ( gtk_entry_get_text ( para->entry  ), -1 );

				if ( obj != NULL )
				{
					Tcl_SetObjResult ( interp, obj );
					return TCL_OK;
				}
			}

			break;
		case ClearIdx:
			{
				/* simply set the text to nothing */
				gtk_entry_set_text ( para->entry, "" );
			}

			break;
		case ClassIdx:
			{

				Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "entry", -1 ) );
			}
			break;
		case DeleteIdx:
			{
				return gnoclDelete ( interp, GTK_WIDGET ( para->entry ), objc, objv );
			}
		case ConfigureIdx:
			{
#ifdef DEBUG_ENTRY
				g_print ( "entryFunc ConfigureIdx\n" );
#endif
				int ret = TCL_ERROR;

				if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1,
											   entryOptions, G_OBJECT ( para->entry ) ) == TCL_OK )
				{
					ret = configure ( interp, para, entryOptions );
				}

				gnoclClearOptions ( entryOptions );

				return ret;
			}

			break;

		case CgetIdx:
			{
				int     idx;

				switch ( gnoclCget ( interp, objc, objv, G_OBJECT ( para->entry ), entryOptions, &idx ) )
				{
					case GNOCL_CGET_ERROR:
						return TCL_ERROR;
					case GNOCL_CGET_HANDLED:
						return TCL_OK;
					case GNOCL_CGET_NOTHANDLED:
						return cget ( interp, para, entryOptions, idx );
				}
			}

		case OnChangedIdx:
			{
				const char *txt = gtk_entry_get_text ( para->entry );

				if ( objc != 2 )
				{
					Tcl_WrongNumArgs ( interp, 2, objv, NULL );
					return TCL_ERROR;
				}

				return doCommand ( para, txt, 0 );
			}
	}

	return TCL_OK;
}
Пример #17
0
gboolean bind_getkey (GtkNotebook *notebook, GdkEventKey *event)
{
     CreamTabbed *obj;
     gboolean ret = TRUE;

     global.browser.mode = BindMode;

     obj = get_current_creamtabbed ();

     if (bind_buffer == NULL)
          bind_buffer = g_string_new ("");

     switch (event->keyval)
     {
          case GDK_Escape:
          {
               GtkWidget *content = cream_view_get_content (CREAM_VIEW (obj->creamview));

               if (MODULE_IS_WEB_VIEW (content))
               {
                    WebKitWebSettings *settings = module_web_view_get_settings (MODULE_WEB_VIEW (content));
                    g_object_set (settings, "enable-caret-browsing", FALSE, NULL);
                    webkit_web_view_set_settings (WEBKIT_WEB_VIEW (content), settings);
               }

               echo (obj, "");
               gtk_widget_grab_focus (GTK_WIDGET (obj));
               global.browser.mode = BindMode;
               break;
          }

          case GDK_Insert:
          {
               GtkWidget *content = cream_view_get_content (CREAM_VIEW (obj->creamview));

               if (MODULE_IS_WEB_VIEW (content))
               {
                    WebKitWebSettings *settings = module_web_view_get_settings (MODULE_WEB_VIEW (content));
                    g_object_set (settings, "enable-caret-browsing", TRUE, NULL);
                    webkit_web_view_set_settings (WEBKIT_WEB_VIEW (content), settings);
               }

               echo (obj, "-- CARET --");
               gtk_widget_grab_focus (GTK_WIDGET (obj));
               global.browser.mode = InsertMode;
               break;
          }

          case GDK_colon:
               if (!gtk_entry_get_text (GTK_ENTRY (obj->inputbox)))
               {
                    echo (obj, ":");
                    gtk_widget_grab_focus (obj->inputbox);
                    gtk_entry_set_position (GTK_ENTRY (obj->inputbox), -1);
                    global.browser.mode = CmdMode;
               }
               break;

          case GDK_slash:
               if (!gtk_entry_get_text (GTK_ENTRY (obj->inputbox)))
               {
                    echo (obj, "/");
                    gtk_widget_grab_focus (obj->inputbox);
                    gtk_entry_set_position (GTK_ENTRY (obj->inputbox), -1);
                    global.browser.mode = CmdMode;
               }
               break;

          default:
               if (event->string != NULL)
                    bind_buffer = g_string_append (bind_buffer, event->string);
               ret = FALSE;
               break;
     }

     if (ret)
     {
          g_string_free (bind_buffer, TRUE);
          bind_buffer = NULL;
     }
     else
          ret = bind_parse_buffer (obj);

     return ret;
}
Пример #18
0
GtkWidget *MakeEditBox(GripInfo *ginfo)
{
  GripGUI *uinfo;
  GtkWidget *vbox,*hbox;
  GtkWidget *button;
  GtkWidget *label;
  GtkWidget *frame;
  GtkWidget *item;
  GtkWidget *check;
  GtkWidget *entry;
  GtkObject *adj;
  ID3Genre *id3_genre;
  gint id3_genre_count;
  int len;
  int dub_size;
  PangoLayout *layout;

  uinfo=&(ginfo->gui_info);

  frame=gtk_frame_new(NULL);

  vbox=gtk_vbox_new(FALSE,0);

  hbox=gtk_hbox_new(FALSE,3);

  label=gtk_label_new(_("Disc title"));

  /* This should be the longest string in the track edit section */



  layout=gtk_widget_create_pango_layout(GTK_WIDGET(label),
					_("Track name"));


  pango_layout_get_size(layout,&len,NULL);

  len/=PANGO_SCALE;

  g_object_unref(layout);

  layout=gtk_widget_create_pango_layout(GTK_WIDGET(label),
					_("W"));

  pango_layout_get_size(layout,&dub_size,NULL);

  dub_size/=PANGO_SCALE;

  g_object_unref(layout);


  gtk_widget_set_usize(label,len,0);

  gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
  gtk_widget_show(label);

  uinfo->title_edit_entry=gtk_entry_new_with_max_length(256);
  gtk_signal_connect(GTK_OBJECT(uinfo->title_edit_entry),"changed",
		     GTK_SIGNAL_FUNC(TitleEditChanged),(gpointer)ginfo);
  gtk_entry_set_position(GTK_ENTRY(uinfo->title_edit_entry),0);
  gtk_box_pack_start(GTK_BOX(hbox),uinfo->title_edit_entry,TRUE,TRUE,0);
  gtk_widget_show(uinfo->title_edit_entry);

  gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
  gtk_widget_show(hbox);

  hbox=gtk_hbox_new(FALSE,3);

  label=gtk_label_new(_("Disc artist"));
  gtk_widget_set_usize(label,len,0);
  gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
  gtk_widget_show(label);

  uinfo->artist_edit_entry=gtk_entry_new_with_max_length(256);
  gtk_signal_connect(GTK_OBJECT(uinfo->artist_edit_entry),"changed",
		     GTK_SIGNAL_FUNC(ArtistEditChanged),(gpointer)ginfo);
  gtk_entry_set_position(GTK_ENTRY(uinfo->artist_edit_entry),0);
  gtk_box_pack_start(GTK_BOX(hbox),uinfo->artist_edit_entry,TRUE,TRUE,0);
  gtk_widget_show(uinfo->artist_edit_entry);

  gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
  gtk_widget_show(hbox);

  hbox=gtk_hbox_new(FALSE,3);

  label=gtk_label_new(_("ID3 genre:"));
  gtk_widget_set_usize(label,len,0);
  gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
  gtk_widget_show(label);

  uinfo->id3_genre_combo=gtk_combo_new();

  for(id3_genre_count=0;(id3_genre=ID3GenreByNum(id3_genre_count));
      id3_genre_count++) {
    item = gtk_list_item_new_with_label(id3_genre->name);
    gtk_object_set_user_data(GTK_OBJECT(item),
			     (gpointer)(id3_genre->num));
    uinfo->id3_genre_item_list=g_list_append(uinfo->id3_genre_item_list,item);
    gtk_signal_connect(GTK_OBJECT(item),"select",
		       GTK_SIGNAL_FUNC(ID3GenreChanged),
		       (gpointer)ginfo);
    gtk_container_add(GTK_CONTAINER(GTK_COMBO(uinfo->id3_genre_combo)->list),
		      item);
    gtk_widget_show(item);
  }

  gtk_box_pack_start(GTK_BOX(hbox),uinfo->id3_genre_combo,TRUE,TRUE,0);
  gtk_widget_show(uinfo->id3_genre_combo);

  SetID3Genre(ginfo,ginfo->ddata.data_id3genre);

  gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
  gtk_widget_show(hbox);

  hbox=gtk_hbox_new(FALSE,3);

  label=gtk_label_new(_("Disc year"));
  gtk_widget_set_usize(label,len,0);
  gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
  gtk_widget_show(label);

  adj=gtk_adjustment_new(0,0,9999,1.0,5.0,0);

  uinfo->year_spin_button=gtk_spin_button_new(GTK_ADJUSTMENT(adj),0.5,0);
  gtk_signal_connect(GTK_OBJECT(uinfo->year_spin_button),"value_changed",
		     GTK_SIGNAL_FUNC(YearEditChanged),(gpointer)ginfo);
  gtk_box_pack_start(GTK_BOX(hbox),uinfo->year_spin_button,TRUE,TRUE,0);
  gtk_widget_show(uinfo->year_spin_button);

  gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
  gtk_widget_show(hbox);

  hbox=gtk_hbox_new(FALSE,3);

  label=gtk_label_new(_("Track name"));
  gtk_widget_set_usize(label,len,0);
  gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
  gtk_widget_show(label);

  uinfo->track_edit_entry=gtk_entry_new_with_max_length(256);
  gtk_signal_connect(GTK_OBJECT(uinfo->track_edit_entry),"changed",
		     GTK_SIGNAL_FUNC(TrackEditChanged),(gpointer)ginfo);
  gtk_signal_connect(GTK_OBJECT(uinfo->track_edit_entry),"activate",
		     GTK_SIGNAL_FUNC(EditNextTrack),(gpointer)ginfo);
  gtk_box_pack_start(GTK_BOX(hbox),uinfo->track_edit_entry,TRUE,TRUE,0);
  gtk_widget_show(uinfo->track_edit_entry);

  gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
  gtk_widget_show(hbox);

  uinfo->multi_artist_box=gtk_vbox_new(FALSE,0);

  hbox=gtk_hbox_new(FALSE,3);

  label=gtk_label_new(_("Track artist"));
  gtk_widget_set_usize(label,len,0);
  gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
  gtk_widget_show(label);

  uinfo->track_artist_edit_entry=gtk_entry_new_with_max_length(256);
  gtk_signal_connect(GTK_OBJECT(uinfo->track_artist_edit_entry),"changed",
		     GTK_SIGNAL_FUNC(TrackEditChanged),(gpointer)ginfo);
  gtk_box_pack_start(GTK_BOX(hbox),uinfo->track_artist_edit_entry,
		     TRUE,TRUE,0);
  gtk_widget_show(uinfo->track_artist_edit_entry);

  gtk_box_pack_start(GTK_BOX(uinfo->multi_artist_box),hbox,FALSE,FALSE,0);
  gtk_widget_show(hbox);

  hbox=gtk_hbox_new(FALSE,3);

  label=gtk_label_new(_("Split:"));
  gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
  gtk_widget_show(label);

  button=gtk_button_new_with_label(_("Title/Artist"));
  gtk_object_set_user_data(GTK_OBJECT(button),(gpointer)0);
  gtk_signal_connect(GTK_OBJECT(button),"clicked",
		     GTK_SIGNAL_FUNC(SplitTitleArtist),(gpointer)ginfo);
  gtk_box_pack_start(GTK_BOX(hbox),button,FALSE,FALSE,0);
  gtk_widget_show(button);

  button=gtk_button_new_with_label(_("Artist/Title"));
  gtk_object_set_user_data(GTK_OBJECT(button),(gpointer)1);
  gtk_signal_connect(GTK_OBJECT(button),"clicked",
		     GTK_SIGNAL_FUNC(SplitTitleArtist),(gpointer)ginfo);
  gtk_box_pack_start(GTK_BOX(hbox),button,FALSE,FALSE,0);
  gtk_widget_show(button);

  entry=MakeStrEntry(&uinfo->split_chars_entry,ginfo->title_split_chars,
		     _("Split chars"),5,TRUE);

  gtk_widget_set_usize(uinfo->split_chars_entry,
		       5*dub_size,0);



  gtk_box_pack_end(GTK_BOX(hbox),entry,FALSE,FALSE,0);
  gtk_widget_show(entry);

  gtk_box_pack_start(GTK_BOX(uinfo->multi_artist_box),hbox,FALSE,FALSE,2);
  gtk_widget_show(hbox);

  gtk_box_pack_start(GTK_BOX(vbox),uinfo->multi_artist_box,FALSE,FALSE,0);

  if(ginfo->ddata.data_multi_artist)
    gtk_widget_show(uinfo->multi_artist_box);

  hbox=gtk_hbox_new(FALSE,0);

  check=MakeCheckButton(&uinfo->multi_artist_button,
			&(ginfo->ddata.data_multi_artist),
			_("Multi-artist"));
  gtk_signal_connect(GTK_OBJECT(uinfo->multi_artist_button),"clicked",
		     GTK_SIGNAL_FUNC(UpdateMultiArtist),(gpointer)ginfo);
  gtk_box_pack_start(GTK_BOX(hbox),check,TRUE,TRUE,0);
  gtk_widget_show(check);

  button=ImageButton(GTK_WIDGET(uinfo->app),uinfo->save_image);
  gtk_widget_set_style(button,uinfo->style_dark_grey);
  gtk_signal_connect(GTK_OBJECT(button),"clicked",
      GTK_SIGNAL_FUNC(SaveDiscInfo),(gpointer)ginfo);
  gtk_tooltips_set_tip(MakeToolTip(),button,
		       _("Save disc info"),NULL);
  gtk_box_pack_start(GTK_BOX(hbox),button,FALSE,FALSE,0);
  gtk_widget_show(button);

  button=ImageButton(GTK_WIDGET(uinfo->app),uinfo->mail_image);
  gtk_widget_set_style(button,uinfo->style_dark_grey);
  gtk_signal_connect(GTK_OBJECT(button),"clicked",
      GTK_SIGNAL_FUNC(SubmitEntryCB),(gpointer)ginfo);
  gtk_tooltips_set_tip(MakeToolTip(),button,
		       _("Submit disc info"),NULL);
  gtk_box_pack_start(GTK_BOX(hbox),button,FALSE,FALSE,0);
  gtk_widget_show(button);

  gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
  gtk_widget_show(hbox);

  gtk_container_add(GTK_CONTAINER(frame),vbox);
  gtk_widget_show(vbox);

  return frame;
}