示例#1
0
/**
 * e_dialog_editable_get:
 * @widget: A #GtkEditable widget.
 *
 * Queries the string value inside a #GtkEditable-derived widget.
 *
 * Return value: String value.  You should free it when you are done with it.
 * This function can return NULL if the string could not be converted from
 * GTK+'s encoding into UTF8.
 **/
gchar *
e_dialog_editable_get (GtkWidget *widget)
{
	g_return_val_if_fail (GTK_IS_EDITABLE (widget), NULL);

	return gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
}
示例#2
0
/**
 * gtk_editable_get_position:
 * @editable: a #GtkEditable
 *
 * Retrieves the current position of the cursor relative to the start
 * of the content of the editable. 
 * 
 * Note that this position is in characters, not in bytes.
 *
 * Return value: the cursor position
 */
gint
gtk_editable_get_position (GtkEditable *editable)
{
  g_return_val_if_fail (GTK_IS_EDITABLE (editable), 0);

  return GTK_EDITABLE_GET_IFACE (editable)->get_position (editable);
}
示例#3
0
/**
 * gtk_editable_paste_clipboard:
 * @editable: a #GtkEditable
 *
 * Pastes the content of the clipboard to the current position of the
 * cursor in the editable.
 */
void
gtk_editable_paste_clipboard (GtkEditable *editable)
{
  g_return_if_fail (GTK_IS_EDITABLE (editable));
  
  g_signal_emit_by_name (editable, "paste-clipboard");
}
示例#4
0
/**
 * gtk_editable_set_position:
 * @editable: a #GtkEditable
 * @position: the position of the cursor 
 *
 * Sets the cursor position in the editable to the given value.
 *
 * The cursor is displayed before the character with the given (base 0) 
 * index in the contents of the editable. The value must be less than or 
 * equal to the number of characters in the editable. A value of -1 
 * indicates that the position should be set after the last character 
 * of the editable. Note that @position is in characters, not in bytes.
 */
void
gtk_editable_set_position (GtkEditable      *editable,
			   gint              position)
{
  g_return_if_fail (GTK_IS_EDITABLE (editable));

  GTK_EDITABLE_GET_IFACE (editable)->set_position (editable, position);
}
示例#5
0
/**
 * gtk_editable_select_region: (virtual set_selection_bounds)
 * @editable: a #GtkEditable
 * @start_pos: start of region
 * @end_pos: end of region
 *
 * Selects a region of text. The characters that are selected are 
 * those characters at positions from @start_pos up to, but not 
 * including @end_pos. If @end_pos is negative, then the
 * characters selected are those characters from @start_pos to 
 * the end of the text.
 * 
 * Note that positions are specified in characters, not bytes.
 */
void
gtk_editable_select_region (GtkEditable *editable,
			    gint         start_pos,
			    gint         end_pos)
{
  g_return_if_fail (GTK_IS_EDITABLE (editable));
  
  GTK_EDITABLE_GET_IFACE (editable)->set_selection_bounds (editable, start_pos, end_pos);
}
示例#6
0
/**
 * gtk_editable_delete_text: (virtual do_delete_text)
 * @editable: a #GtkEditable
 * @start_pos: start position
 * @end_pos: end position
 *
 * Deletes a sequence of characters. The characters that are deleted are 
 * those characters at positions from @start_pos up to, but not including 
 * @end_pos. If @end_pos is negative, then the characters deleted
 * are those from @start_pos to the end of the text.
 *
 * Note that the positions are specified in characters, not bytes.
 */
void
gtk_editable_delete_text (GtkEditable *editable,
			  gint         start_pos,
			  gint         end_pos)
{
  g_return_if_fail (GTK_IS_EDITABLE (editable));

  GTK_EDITABLE_GET_IFACE (editable)->do_delete_text (editable, start_pos, end_pos);
}
示例#7
0
static void
editable_undo_delete_text (GObject *object,
                           gint position_start,
                           gint position_end)
{
	g_return_if_fail (GTK_IS_EDITABLE (object));

	gtk_editable_delete_text (GTK_EDITABLE (object), position_start, position_end);
}
示例#8
0
static void
editable_undo_insert_text (GObject *object,
                           const gchar *text,
                           gint position)
{
	g_return_if_fail (GTK_IS_EDITABLE (object));

	gtk_editable_insert_text (GTK_EDITABLE (object), text, -1, &position);
}
示例#9
0
gchar *    
gtk_editable_get_chars (GtkEditable *editable,
			gint         start,
			gint         end)
{
  g_return_val_if_fail (GTK_IS_EDITABLE (editable), NULL);

  return GTK_EDITABLE_GET_CLASS (editable)->get_chars (editable, start, end);
}
示例#10
0
void
gtk_editable_select_region (GtkEditable *editable,
			    gint         start,
			    gint         end)
{
  g_return_if_fail (GTK_IS_EDITABLE (editable));
  
  GTK_EDITABLE_GET_CLASS (editable)->set_selection_bounds (editable,  start, end);
}
示例#11
0
/**
 * gtk_editable_get_chars:
 * @editable: a #GtkEditable
 * @start_pos: start of text
 * @end_pos: end of text
 *
 * Retrieves a sequence of characters. The characters that are retrieved 
 * are those characters at positions from @start_pos up to, but not 
 * including @end_pos. If @end_pos is negative, then the characters
 * retrieved are those characters from @start_pos to the end of the text.
 * 
 * Note that positions are specified in characters, not bytes.
 *
 * Return value: a pointer to the contents of the widget as a
 *      string. This string is allocated by the #GtkEditable
 *      implementation and should be freed by the caller.
 */
gchar *    
gtk_editable_get_chars (GtkEditable *editable,
			gint         start_pos,
			gint         end_pos)
{
  g_return_val_if_fail (GTK_IS_EDITABLE (editable), NULL);

  return GTK_EDITABLE_GET_IFACE (editable)->get_chars (editable, start_pos, end_pos);
}
示例#12
0
static void on_break_ignore_editing_started(G_GNUC_UNUSED GtkCellRenderer *cell,
	GtkCellEditable *editable, G_GNUC_UNUSED const gchar *path, G_GNUC_UNUSED gpointer gdata)
{
	if (GTK_IS_EDITABLE(editable))
		validator_attach(GTK_EDITABLE(editable), VALIDATOR_NUMERIC);

	if (GTK_IS_ENTRY(editable))
		gtk_entry_set_max_length(GTK_ENTRY(editable), 10);
}
示例#13
0
/**
 * gtk_editable_delete_selection:
 * @editable: a #GtkEditable
 *
 * Deletes the currently selected text of the editable.
 * This call doesn’t do anything if there is no selected text.
 */
void
gtk_editable_delete_selection (GtkEditable *editable)
{
  gint start, end;

  g_return_if_fail (GTK_IS_EDITABLE (editable));

  if (gtk_editable_get_selection_bounds (editable, &start, &end))
    gtk_editable_delete_text (editable, start, end);
}
示例#14
0
/**
 * gtk_editable_set_editable:
 * @editable: a #GtkEditable
 * @is_editable: %TRUE if the user is allowed to edit the text
 *   in the widget
 *
 * Determines if the user can edit the text in the editable
 * widget or not. 
 */
void
gtk_editable_set_editable (GtkEditable    *editable,
			   gboolean        is_editable)
{
  g_return_if_fail (GTK_IS_EDITABLE (editable));

  g_object_set (editable,
		"editable", is_editable != FALSE,
		NULL);
}
示例#15
0
static void
edit_copy_activated (GtkAction  * action,
                     CMainWindow* self)
{
	if (GTK_IS_EDITABLE (gtk_window_get_focus (GTK_WINDOW (self)))) {
		gtk_editable_copy_clipboard (GTK_EDITABLE (gtk_window_get_focus (GTK_WINDOW (self))));
	} else if (C_IS_TASK_WIDGET (gtk_window_get_focus (GTK_WINDOW (self)))) {
                c_task_widget_copy_clipboard (C_TASK_WIDGET (gtk_window_get_focus (GTK_WINDOW (self))));
	}
}
示例#16
0
/**
 * gtk_editable_get_editable:
 * @editable: a #GtkEditable
 *
 * Retrieves whether @editable is editable. See
 * gtk_editable_set_editable().
 *
 * Return value: %TRUE if @editable is editable.
 */
gboolean
gtk_editable_get_editable (GtkEditable *editable)
{
  gboolean value;

  g_return_val_if_fail (GTK_IS_EDITABLE (editable), FALSE);

  g_object_get (editable, "editable", &value, NULL);

  return value;
}
示例#17
0
/**
 * e_dialog_editable_set:
 * @widget: A #GtkEditable widget.
 * @value: String value.
 *
 * Sets the string value inside a #GtkEditable-derived widget.
 **/
void
e_dialog_editable_set (GtkWidget *widget,
                       const gchar *value)
{
	gint pos = 0;

	g_return_if_fail (GTK_IS_EDITABLE (widget));

	gtk_editable_delete_text (GTK_EDITABLE (widget), 0, -1);

	if (value)
		gtk_editable_insert_text (GTK_EDITABLE (widget), value, strlen (value), &pos);
}
示例#18
0
void on_paste(GtkAction* act, FmMainWin* win)
{
    GtkWidget* focus = gtk_window_get_focus((GtkWindow*)win);
    if(GTK_IS_EDITABLE(focus) )
    {
        gtk_editable_paste_clipboard((GtkEditable*)focus);
    }
    else
    {
        FmPath* path = fm_folder_view_get_cwd(FM_FOLDER_VIEW(win->folder_view));
        fm_clipboard_paste_files(win->folder_view, path);
    }
}
示例#19
0
/**
 * gtk_editable_insert_text: (virtual do_insert_text)
 * @editable: a #GtkEditable
 * @new_text: the text to append
 * @new_text_length: the length of the text in bytes, or -1
 * @position: (inout): location of the position text will be inserted at
 *
 * Inserts @new_text_length bytes of @new_text into the contents of the
 * widget, at position @position.
 *
 * Note that the position is in characters, not in bytes. 
 * The function updates @position to point after the newly inserted text.
 */
void
gtk_editable_insert_text (GtkEditable *editable,
			  const gchar *new_text,
			  gint         new_text_length,
			  gint        *position)
{
  g_return_if_fail (GTK_IS_EDITABLE (editable));
  g_return_if_fail (position != NULL);

  if (new_text_length < 0)
    new_text_length = strlen (new_text);
  
  GTK_EDITABLE_GET_IFACE (editable)->do_insert_text (editable, new_text, new_text_length, position);
}
示例#20
0
文件: views.c 项目: BYC/geany-plugins
static void on_display_editing_started(G_GNUC_UNUSED GtkCellRenderer *cell,
	GtkCellEditable *editable, const gchar *path_str, ScpTreeStore *store)
{
	GtkTreeIter iter;
	const char *value;
	gint hb_mode;

	g_assert(GTK_IS_EDITABLE(editable));
	scp_tree_store_get_iter_from_string(store, &iter, path_str);
	scp_tree_store_get(store, &iter, COLUMN_VALUE, &value, COLUMN_HB_MODE, &hb_mode, -1);
	/* scrolling editable to the proper position is left as an exercise for the reader */
	g_signal_connect(editable, "map-event", G_CALLBACK(on_display_editable_map_event),
		parse_get_display_from_7bit(value, hb_mode, MR_EDITVC));
}
void
caja_clipboard_set_up_editable (GtkEditable *target,
                                GtkUIManager *ui_manager,
                                gboolean shares_selection_changes)
{
    g_return_if_fail (GTK_IS_EDITABLE (target));
    g_return_if_fail (GTK_IS_UI_MANAGER (ui_manager));

    caja_clipboard_real_set_up (target, ui_manager,
                                shares_selection_changes,
                                editable_select_all_callback,
                                editable_connect_callbacks,
                                editable_disconnect_callbacks);
}
示例#22
0
void on_copy1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));

	if (GTK_IS_EDITABLE(focusw))
		gtk_editable_copy_clipboard(GTK_EDITABLE(focusw));
	else if (IS_SCINTILLA(focusw))
		sci_copy(SCINTILLA(focusw));
	else if (GTK_IS_TEXT_VIEW(focusw))
	{
		GtkTextBuffer *buffer = gtk_text_view_get_buffer(
			GTK_TEXT_VIEW(focusw));
		gtk_text_buffer_copy_clipboard(buffer, gtk_clipboard_get(GDK_NONE));
	}
}
示例#23
0
void on_delete1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));

	if (GTK_IS_EDITABLE(focusw))
		gtk_editable_delete_selection(GTK_EDITABLE(focusw));
	else if (IS_SCINTILLA(focusw) && sci_has_selection(SCINTILLA(focusw)))
		sci_clear(SCINTILLA(focusw));
	else if (GTK_IS_TEXT_VIEW(focusw))
	{
		GtkTextBuffer *buffer = gtk_text_view_get_buffer(
			GTK_TEXT_VIEW(focusw));
		gtk_text_buffer_delete_selection(buffer, TRUE, TRUE);
	}
}
示例#24
0
static void
widget_undo_place_cursor_at (GObject *object,
                             gint char_pos)
{
	if (GTK_IS_EDITABLE (object))
		gtk_editable_set_position (GTK_EDITABLE (object), char_pos);
	else if (GTK_IS_TEXT_BUFFER (object)) {
		GtkTextBuffer *buffer;
		GtkTextIter pos;

		buffer = GTK_TEXT_BUFFER (object);

		gtk_text_buffer_get_iter_at_offset (buffer, &pos, char_pos);
		gtk_text_buffer_place_cursor (buffer, &pos);
	}
}
示例#25
0
static void on_break_ignore_editing_started(G_GNUC_UNUSED GtkCellRenderer *cell,
	GtkCellEditable *editable, const gchar *path_str, G_GNUC_UNUSED gpointer gdata)
{
	GtkTreeIter iter;
	const gchar *ignore;

	if (GTK_IS_EDITABLE(editable))
		validator_attach(GTK_EDITABLE(editable), VALIDATOR_NUMERIC);

	if (GTK_IS_ENTRY(editable))
		gtk_entry_set_max_length(GTK_ENTRY(editable), 10);

	scp_tree_store_get_iter_from_string(store, &iter, path_str);
	scp_tree_store_get(store, &iter, BREAK_IGNORE, &ignore, -1);
	g_signal_connect(editable, "map", G_CALLBACK(on_view_editable_map), g_strdup(ignore));
}
示例#26
0
/* Edit->Select All */
void
action_select_all(GtkAction *action, I7Document *document)
{
	GtkWidget *widget = gtk_window_get_focus(GTK_WINDOW(document));

	/* What actually happens depends on the type of widget that is focused */
	if(WEBKIT_IS_WEB_VIEW(widget))
		webkit_web_view_select_all(WEBKIT_WEB_VIEW(widget));
	else if(GTK_IS_LABEL(widget) && gtk_label_get_selectable(GTK_LABEL(widget)))
		gtk_label_select_region(GTK_LABEL(widget), 0, -1);
	else if(GTK_IS_EDITABLE(widget))
		gtk_editable_select_region(GTK_EDITABLE(widget), 0, -1);
	else if(GTK_IS_TEXT_VIEW(widget))
		g_signal_emit_by_name(widget, "select-all", TRUE, NULL);
	else /* If we don't know how to select it, just select all in the source */
		g_signal_emit_by_name(i7_document_get_default_view(document), "select-all", TRUE, NULL);
}
示例#27
0
void on_copy(GtkAction* act, FmMainWin* win)
{
    GtkWidget* focus = gtk_window_get_focus((GtkWindow*)win);
    if(GTK_IS_EDITABLE(focus) &&
       gtk_editable_get_selection_bounds((GtkEditable*)focus, NULL, NULL) )
    {
        gtk_editable_copy_clipboard((GtkEditable*)focus);
    }
    else
    {
        FmPathList* files = fm_folder_view_get_selected_file_paths(FM_FOLDER_VIEW(win->folder_view));
        if(files)
        {
            fm_clipboard_copy_files(win, files);
            fm_list_unref(files);
        }
    }
}
示例#28
0
/**
 * gtk_test_text_set:
 * @widget:     valid widget pointer.
 * @string:     a 0-terminated C string
 *
 * Set the text string of @widget to @string if it is a GtkLabel,
 * GtkEditable (entry and text widgets) or GtkTextView.
 *
 * Since: 2.14
 **/
void
gtk_test_text_set (GtkWidget   *widget,
                   const gchar *string)
{
    if (GTK_IS_LABEL (widget))
        gtk_label_set_text (GTK_LABEL (widget), string);
    else if (GTK_IS_EDITABLE (widget))
    {
        int pos = 0;
        gtk_editable_delete_text (GTK_EDITABLE (widget), 0, -1);
        gtk_editable_insert_text (GTK_EDITABLE (widget), string, -1, &pos);
    }
    else if (GTK_IS_TEXT_VIEW (widget))
    {
        GtkTextBuffer *tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
        gtk_text_buffer_set_text (tbuffer, string, -1);
    }
}
示例#29
0
static void remmina_file_editor_on_realize(GtkWidget* widget, gpointer user_data)
{
	RemminaFileEditor* gfe;
	GtkWidget* defaultwidget;

	gfe = REMMINA_FILE_EDITOR(widget);

	defaultwidget = gfe->priv->name_entry;

	if (defaultwidget)
	{
		if (GTK_IS_EDITABLE(defaultwidget))
		{
			gtk_editable_select_region(GTK_EDITABLE(defaultwidget), 0, -1);
		}
		gtk_widget_grab_focus(defaultwidget);
	}
}
示例#30
0
/**
 * gtk_editable_get_selection_bounds:
 * @editable: a #GtkEditable
 * @start_pos: (out) (allow-none): location to store the starting position, or %NULL
 * @end_pos: (out) (allow-none): location to store the end position, or %NULL
 *
 * Retrieves the selection bound of the editable. start_pos will be filled
 * with the start of the selection and @end_pos with end. If no text was
 * selected both will be identical and %FALSE will be returned.
 *
 * Note that positions are specified in characters, not bytes.
 *
 * Return value: %TRUE if an area is selected, %FALSE otherwise
 */
gboolean
gtk_editable_get_selection_bounds (GtkEditable *editable,
				   gint        *start_pos,
				   gint        *end_pos)
{
  gint tmp_start, tmp_end;
  gboolean result;
  
  g_return_val_if_fail (GTK_IS_EDITABLE (editable), FALSE);

  result = GTK_EDITABLE_GET_IFACE (editable)->get_selection_bounds (editable, &tmp_start, &tmp_end);

  if (start_pos)
    *start_pos = MIN (tmp_start, tmp_end);
  if (end_pos)
    *end_pos = MAX (tmp_start, tmp_end);

  return result;
}