Example #1
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))));
	}
}
Example #2
0
static gboolean on_key_press_event(GtkWidget *widget, GdkEventKey *event,
	G_GNUC_UNUSED gpointer gdata)
{
	guint mask = GDK_CONTROL_MASK | GDK_SHIFT_MASK | (column_mode ? 0 : GDK_MOD1_MASK);
	guint state = event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK);

	if (state == mask)
	{
		const command_key *ck;

		for (ck = command_keys; ck->command; ck++)
		{
			if (event->keyval == ck->key || event->keyval == ck->keypad)
			{
				ScintillaObject *sci = scintilla_get_current();

				if (sci && gtk_window_get_focus(GTK_WINDOW(widget)) == GTK_WIDGET(sci))
				{
					column_mode_command(sci, ck->command);
					return TRUE;
				}
				break;
			}
		}
	}
	else if (!column_mode && state == GDK_SHIFT_MASK)
	{
		const command_key *ck;

		for (ck = command_keys; ck->key; ck++)
		{
			if (event->keyval == ck->key || event->keyval == ck->keypad)
			{
				ScintillaObject *sci = scintilla_get_current();

				if (sci && sci_has_selection(sci) && sci_rectangle_selection(sci) &&
					gtk_window_get_focus(GTK_WINDOW(widget)) == GTK_WIDGET(sci))
				{
					/* not exactly a bug, but... */
					convert_selection(sci, FALSE);
				}
				break;
			}
		}
	}

	return FALSE;
}
Example #3
0
static void
gimp_file_dialog_help_func (const gchar *help_id,
                            gpointer     help_data)
{
  GimpFileDialog *dialog = GIMP_FILE_DIALOG (help_data);
  GtkWidget      *focus;

  focus = gtk_window_get_focus (GTK_WINDOW (dialog));

  if (focus == dialog->proc_view)
    {
      gchar *proc_help_id;

      proc_help_id =
        gimp_file_proc_view_get_help_id (GIMP_FILE_PROC_VIEW (dialog->proc_view));

      gimp_standard_help_func (proc_help_id, NULL);

      g_free (proc_help_id);
    }
  else
    {
      gimp_standard_help_func (help_id, NULL);
    }
}
Example #4
0
gboolean iofunctions_autosave_cb (void *user) {
    gint tabtotal, i;
    GtkWidget *focus;
    GuTabContext* tab;
    GuEditor *ec;
    gchar *text;

    GList *tabs = gummi_get_all_tabs();
    tabtotal = g_list_length(tabs);
    
    /* skip the autosave procedure when there are no tabs open */
    if (tabtotal == 0) return TRUE; 

    for (i=0; i < tabtotal; i++) {
        tab = g_list_nth_data (tabs, i);
        ec = tab->editor;
        
        if ((ec->filename) && editor_buffer_changed (ec)) {
            focus = gtk_window_get_focus (gummi_get_gui ()->mainwindow);
            text = editor_grab_buffer (ec);
            gtk_widget_grab_focus (focus);
            iofunctions_save_file (gummi->io, ec->filename, text);
            gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (ec->buffer), FALSE);
            slog (L_DEBUG, "Autosaving document: %s\n", ec->filename);
            gui_set_filename_display (tab, TRUE, TRUE);
       }
    }
    return TRUE;
}
Example #5
0
static void on_menuitem_edit_activate(void)
{
	GtkWidget *widget = gtk_window_get_focus(gui.window);
	bool selectable = false;
	bool editable = false;
	bool selection_ready = false;
	bool clipboard_ready = false;

	if (GTK_IS_ENTRY(widget)) {
		selectable = gtk_entry_get_text_length(GTK_ENTRY(widget));
		editable = gtk_editable_get_editable(GTK_EDITABLE(widget));
		selection_ready = gtk_editable_get_selection_bounds(
			GTK_EDITABLE(widget), NULL, NULL);
		clipboard_ready = gtk_clipboard_wait_is_text_available(
			gtk_clipboard_get(GDK_NONE));
	}

	gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_cut),
		selection_ready && editable);
	gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_copy),
		selection_ready);
	gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_paste),
		editable && clipboard_ready);
	gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_delete),
		selection_ready && editable);
	gtk_widget_set_sensitive(GTK_WIDGET(gui.menuitem_select_all),
		selectable);
}
Example #6
0
static void
popup_edit (GtkWidget      *widget,
            GtkColorEditor *editor)
{
  GtkWidget *popup = NULL;
  GtkWidget *toplevel;
  GtkWidget *focus;

  if (widget == editor->priv->sv_plane)
    {
      popup = editor->priv->sv_popup;
      focus = editor->priv->s_entry;
    }
  else if (widget == editor->priv->h_slider)
    {
      popup = editor->priv->h_popup;
      focus = editor->priv->h_entry;
    }
  else if (widget == editor->priv->a_slider)
    {
      popup = editor->priv->a_popup;
      focus = editor->priv->a_entry;
    }

  if (popup)
    {
      dismiss_current_popup (editor);
      toplevel = gtk_widget_get_toplevel (GTK_WIDGET (editor));
      editor->priv->popdown_focus = gtk_window_get_focus (GTK_WINDOW (toplevel));
      editor->priv->current_popup = popup;
      gtk_widget_show (popup);
      gtk_widget_grab_focus (focus);
    }
}
Example #7
0
static gboolean
compare_focus (gpointer data)
{
  AtkObject *atk_focus;
  AtkObject *gtk_focus;
  GtkWidget *focus_widget;
  GList *list, *l;

  atk_focus = atk_get_focus_object ();

  focus_widget = NULL;
  list = gtk_window_list_toplevels ();
  for (l = list; l; l = l->next)
    {
      GtkWindow *w = l->data;
      if (gtk_window_is_active (w))
        {
          focus_widget = gtk_window_get_focus (w);
          break;
        }
    }
  g_list_free (list);

  if (GTK_IS_WIDGET (focus_widget))
    gtk_focus = gtk_widget_get_accessible (focus_widget);
  else
    gtk_focus = NULL;

  if (gtk_focus != atk_focus)
    g_print ("gtk focus: %s != atk focus: %s\n",
             get_name (gtk_focus), get_name (atk_focus));

  return G_SOURCE_CONTINUE;
}
Example #8
0
static void
save_back_entry (GsShell *shell)
{
	GsShellPrivate *priv = gs_shell_get_instance_private (shell);
	BackEntry *entry;

	entry = g_new0 (BackEntry, 1);
	entry->mode = priv->mode;

	entry->focus = gtk_window_get_focus (priv->main_window);
	if (entry->focus != NULL)
		g_object_add_weak_pointer (G_OBJECT (entry->focus),
					   (gpointer *) &entry->focus);

	if (priv->mode == GS_SHELL_MODE_CATEGORY) {
		entry->category = gs_shell_category_get_category (priv->shell_category);
		g_object_ref (entry->category);
	}
	else if (priv->mode == GS_SHELL_MODE_DETAILS) {
		entry->app = gs_shell_details_get_app (priv->shell_details);
		g_object_ref (entry->app);
	}

	g_queue_push_head (priv->back_entry_stack, entry);
}
Example #9
0
static void on_menuitem_select_all_activate(void)
{
	GtkEditable *widget = GTK_EDITABLE(gtk_window_get_focus(gui.window));

	gtk_editable_set_position(widget, -1);
	gtk_editable_select_region(widget, 0, -1);
}
Example #10
0
void
ViewAutoDrawer_Close(ViewAutoDrawer *that)   // IN
{
   GtkWindow *window;
   GtkWidget *focus;
   GtkWidget *toplevel;

   g_return_if_fail(VIEW_IS_AUTODRAWER(that));
   toplevel = gtk_widget_get_toplevel(GTK_WIDGET(that));

   if (!toplevel || !gtk_widget_is_toplevel(toplevel)) {
      // The autoDrawer cannot function properly without a toplevel.
      return;
   }
   window = GTK_WINDOW(toplevel);

   focus = gtk_window_get_focus(window);
   if (focus && gtk_widget_is_ancestor(focus, that->priv->evBox)) {
      gtk_window_set_focus(window, NULL);
   }

   that->priv->forceClosing = TRUE;
   that->priv->closeConnection =
      g_timeout_add(ViewDrawer_GetCloseTime(&that->parent) +
                    that->priv->delayValue,
      (GSourceFunc)ViewAutoDrawerOnCloseDelay, that);

   /* This change happens programmatically. Always react to it immediately. */
   ViewAutoDrawerUpdate(that, TRUE);
}
Example #11
0
JNIEXPORT jlong JNICALL
Java_org_gnome_gtk_GtkWindow_gtk_1window_1get_1focus
(
	JNIEnv* env,
	jclass cls,
	jlong _self
)
{
	GtkWidget* result;
	jlong _result;
	GtkWindow* self;

	// convert parameter self
	self = (GtkWindow*) _self;

	// call function
	result = gtk_window_get_focus(self);

	// cleanup parameter self

	// translate return value to JNI type
	_result = (jlong) result;

	// cleanup return value
	if (result != NULL) {
		bindings_java_memory_cleanup((GObject*)result, FALSE);
	}

	// and finally
	return _result;
}
Example #12
0
/* typically called when filling the item tree view */
void 
item_list_view_prefocus (ItemListView *ilv)
{
	GtkWidget		*focus_widget;
	GtkTreeSelection	*itemselection;
	
	/* the following is important to prevent setting the unread
	   flag for the first item in the item list when the user does
	   the first click into the treeview, if we don't do a focus and
	   unselect, GTK would always (exception: clicking on first item)
	   generate two selection-change events (one for the clicked and
	   one for the selected item)!!! */

	/* we need to restore the focus after we temporarily select the itemlist */
	focus_widget = gtk_window_get_focus (GTK_WINDOW (liferea_shell_get_window ()));

	/* prevent marking as unread before focussing, which leads to a selection */
	gtk_widget_grab_focus (GTK_WIDGET (ilv->priv->treeview));

	itemselection = gtk_tree_view_get_selection (ilv->priv->treeview);
	if (itemselection)
		gtk_tree_selection_unselect_all (itemselection);
	
	if (focus_widget)
		gtk_widget_grab_focus (focus_widget);
}
Example #13
0
static gboolean
gstyle_slidein_event_box_key_pressed_cb (GstyleSlidein *self,
                                         GdkEventKey   *event,
                                         GtkWidget     *widget)
{
  GtkWidget *focus;

  g_assert (GSTYLE_IS_SLIDEIN (self));
  g_assert (event != NULL);
  g_assert (GTK_IS_WIDGET (widget));

  focus = gtk_window_get_focus (GTK_WINDOW (gtk_widget_get_toplevel (widget)));
  if (focus == NULL)
    return GDK_EVENT_PROPAGATE;

  if (event->keyval == GDK_KEY_Escape && !GTK_IS_ENTRY (focus))
    {
      gstyle_slidein_reveal_slide (self, FALSE);
      return GDK_EVENT_STOP;
    }

  if (gtk_widget_is_ancestor (focus, widget))
    return gtk_widget_event (focus, (GdkEvent*) event);

  return GDK_EVENT_PROPAGATE;
}
Example #14
0
static void
ide_editor_spell_widget__add_button_clicked_cb (IdeEditorSpellWidget *self,
                                                GtkButton            *button)
{
  const gchar *word;
  GtkWidget *item;
  GtkWidget *toplevel;
  GtkWidget *focused_widget;

  g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self));
  g_assert (GTK_IS_BUTTON (button));

  word = gtk_entry_get_text (GTK_ENTRY (self->dict_word_entry));
  /* TODO: check if word already in dict */
  if (check_dict_available (self) && !ide_str_empty0 (word))
    {
      if (!ide_editor_spell_dict_add_word_to_personal (self->dict, word))
        return;

      item = dict_create_word_row (self, word);
      gtk_list_box_insert (GTK_LIST_BOX (self->dict_words_list), item, 0);

      toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
      if (GTK_IS_WINDOW (toplevel) &&
          NULL != (focused_widget = gtk_window_get_focus (GTK_WINDOW (toplevel))))
        {
          if (focused_widget != GTK_WIDGET (self->word_entry) &&
              focused_widget != self->dict_word_entry)
            gtk_widget_grab_focus (self->dict_word_entry);
        }

      gtk_entry_set_text (GTK_ENTRY (self->dict_word_entry), "");

    }
}
Example #15
0
static void
extspinbutton_value_changed (GtkSpinButton *spin)
{
    if(gtk_window_get_focus(GTK_WINDOW(mainwindow))) {
	// Should only do this if this widget is really in the main window.
	gtk_window_set_focus(GTK_WINDOW(mainwindow), NULL);
    }
}
void
caja_navigation_window_pane_set_bar_mode (CajaNavigationWindowPane *pane,
        CajaBarMode mode)
{
    gboolean use_entry;
    GtkWidget *focus_widget;
    CajaNavigationWindow *window;

    switch (mode)
    {

    case CAJA_BAR_PATH:
        gtk_widget_show (pane->path_bar);
        gtk_widget_hide (pane->navigation_bar);
        gtk_widget_hide (pane->search_bar);
        break;

    case CAJA_BAR_NAVIGATION:
        gtk_widget_show (pane->navigation_bar);
        gtk_widget_hide (pane->path_bar);
        gtk_widget_hide (pane->search_bar);
        break;

    case CAJA_BAR_SEARCH:
        gtk_widget_show (pane->search_bar);
        gtk_widget_hide (pane->path_bar);
        gtk_widget_hide (pane->navigation_bar);
        break;
    }
    
    if (mode == CAJA_BAR_NAVIGATION || mode == CAJA_BAR_PATH) {
        use_entry = (mode == CAJA_BAR_NAVIGATION);

        g_signal_handlers_block_by_func (pane->location_button,
                         G_CALLBACK (location_button_toggled_cb),
                         pane);
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pane->location_button),
                          use_entry);
        g_signal_handlers_unblock_by_func (pane->location_button,
                           G_CALLBACK (location_button_toggled_cb),
                           pane);
    }

    window = CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window);
    focus_widget = gtk_window_get_focus (GTK_WINDOW (window));
    if (focus_widget != NULL && !caja_navigation_window_is_in_temporary_navigation_bar (focus_widget, window) &&
            !caja_navigation_window_is_in_temporary_search_bar (focus_widget, window))
    {
        if (mode == CAJA_BAR_NAVIGATION || mode == CAJA_BAR_PATH)
        {
            caja_navigation_window_set_search_button (window, FALSE);
        }
        else
        {
            caja_navigation_window_set_search_button (window, TRUE);
        }
    }
}
Example #17
0
static void
window_set_focus (GtkWindow *window,
		  GtkWidget *widget)
{
	GiggleWindowPriv *priv = GET_PRIV (window);
	gpointer          clipboard_proxy;
	GiggleClipboard  *clipboard;
	GtkTextBuffer    *buffer;

	clipboard_proxy = gtk_window_get_focus (window);

	if (GTK_IS_TEXT_VIEW (clipboard_proxy))
		clipboard_proxy = gtk_text_view_get_buffer (clipboard_proxy);

	if (clipboard_proxy) {
		g_signal_handlers_disconnect_by_func (clipboard_proxy,
						      giggle_clipboard_changed, window);
	}

	GTK_WINDOW_CLASS (giggle_window_parent_class)->set_focus (window, widget);

	clipboard = window_find_clipboard (GIGGLE_WINDOW (window));

	if (GTK_IS_LABEL (widget)) {
		g_signal_connect_swapped (widget, "notify::cursor-position",
					  G_CALLBACK (giggle_clipboard_changed),
					  window);
		g_signal_connect_swapped (widget, "notify::selection-bound",
					  G_CALLBACK (giggle_clipboard_changed),
					  window);
	} else if (GTK_IS_TEXT_VIEW (widget)) {
		buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));

		g_signal_connect_swapped (buffer, "notify::has-selection",
					  G_CALLBACK (giggle_clipboard_changed),
					  window);
	}

	if (clipboard != priv->clipboard) {
		if (priv->clipboard) {
			g_signal_handlers_disconnect_by_func (priv->clipboard,
							      window_clipboard_changed_cb,
							      window);

			priv->clipboard = NULL;
		}

		priv->clipboard = clipboard;

		if (priv->clipboard) {
			g_signal_connect (priv->clipboard, "clipboard-changed",
					  G_CALLBACK (window_clipboard_changed_cb),
					  window);
		}
	}

	window_clipboard_changed_cb (priv->clipboard, GIGGLE_WINDOW (window));
}
Example #18
0
/* GTK+ has an annoying "feature" (I tend to consider it a bug): if
 * you activate a button from keyboard (i.e. Alt+O for "OK" button),
 * then keyboard changes in the currently focused spin button are not
 * saved.  This might be true for some other widgets too.
 *
 * Every dialog with spin buttons should call this function from all
 * button/response handlers.
 */
void
gtk_utils_workaround_focus_bug (GtkWindow *window)
{
  GtkWidget *focused_widget = gtk_window_get_focus (window);

  if (focused_widget) {
    if (GTK_IS_SPIN_BUTTON (focused_widget))
      gtk_spin_button_update (GTK_SPIN_BUTTON (focused_widget));
  }
}
static gboolean on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
	GeanyDocument *doc = document_get_current();
	ScintillaObject *sci = doc != NULL ? doc->editor->sci : NULL;

	if (!sci || gtk_window_get_focus(GTK_WINDOW(geany->main_widgets->window)) != GTK_WIDGET(sci))
		return FALSE;

	return vi_notify_key_press(event);
}
Example #20
0
static void
fit_fetch_entry(FitControls *controls)
{
    GtkWidget *entry;

    entry = gtk_window_get_focus(GTK_WINDOW(controls->dialog));
    if (entry
        && GTK_IS_ENTRY(entry)
        && g_object_get_data(G_OBJECT(entry), "id"))
        gtk_widget_activate(entry);
}
Example #21
0
/**
 * Hack: Whenever the *user* wants the focus on the embed there's always going
 * to be an associated GdkEvent (click on embed, enter on location entry, etc...)
 * If the event doesn't exist (none being processed at the moment) we'll assume
 * it's Mozilla trying to steal the focus after done loading the page.  In that
 * case stop the focus from moving anywhere.
 *
 * Yet another attempt to fix http://bugzilla.gnome.org/show_bug.cgi?id=72125
 * and work around https://bugzilla.mozilla.org/show_bug.cgi?id=210373
 */
static void
mozilla_embed_child_grab_focus_cb (GtkWidget *widget, MozillaEmbed *embed)
{
	GdkEvent *event;
	GtkWidget *focused, *toplevel;
       
	event = gtk_get_current_event ();

	if (event)
	{
		gdk_event_free (event);
		return;
	}

	/* Find the GtkWidget that currently has focus, and if it
	 * is the MozContainer, find the corresponding MozillaEmbed */
	toplevel = gtk_widget_get_toplevel (widget);
	focused = gtk_window_get_focus (GTK_WINDOW (toplevel));

	if (focused && !strcmp ("MozContainer", G_OBJECT_TYPE_NAME (focused)))
	{
		focused = gtk_widget_get_parent (focused);
	}

	if (focused && GTK_WIDGET (embed) != focused)
	{
		g_signal_stop_emission_by_name (widget, "grab-focus");

		/* Focus was trying to move, so deactivate embed which
		 * attempted to grab it */
		if (embed->priv->focus_timeout)
		{
			g_source_remove (embed->priv->focus_timeout);
		}
		embed->priv->focus_timeout =
			g_timeout_add (0, deactivate_focus_timeout_cb, embed);


		if (MOZILLA_IS_EMBED (focused))
		{
			MozillaEmbed *membed = MOZILLA_EMBED (focused);

			if (membed->priv->focus_timeout)
			{
				g_source_remove (membed->priv->focus_timeout);
			}

			/* And if the old widget was a mozille embed, 
			 * let it grab the focus back again */
			membed->priv->focus_timeout = 
				g_timeout_add (0, activate_focus_timeout_cb, membed);
		}
	}
}
Example #22
0
/* Edit->Paste */
void
action_paste(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(GTK_IS_ENTRY(widget) || GTK_IS_TEXT_VIEW(widget))
		g_signal_emit_by_name(widget, "paste-clipboard", NULL);
	else /* If we don't know how to paste to it, just paste to the source */
		g_signal_emit_by_name(i7_document_get_default_view(document), "paste-clipboard", NULL);
}
Example #23
0
GtkWidget *
anjuta_docman_get_current_focus_widget (AnjutaDocman *docman)
{
	GtkWidget *widget;
	widget = gtk_widget_get_toplevel (GTK_WIDGET (docman));
	if (gtk_widget_is_toplevel (widget) &&
		gtk_window_has_toplevel_focus (GTK_WINDOW (widget)))
	{
		return gtk_window_get_focus (GTK_WINDOW (widget));
	}
	return NULL;
}
Example #24
0
/* Workaround GTK+ 2.0 focus slipping problem. */
void
gtk_utils_workaround_set_default_response (GtkDialog *dialog, gint response_id)
{
  GtkWidget *focused_widget = gtk_window_get_focus (GTK_WINDOW (dialog));

  gtk_dialog_set_default_response (dialog, response_id);

  /* Can't use gtk_widget_grab_focus() since `focused_widget' can be
   * NULL.
   */
  gtk_window_set_focus (GTK_WINDOW (dialog), focused_widget);
}
/**
 * ag_chart_edit_update:
 * @chart_edit: an #AgChartEdit
 *
 * If the current widget is a spin button, force it to update. This is
 * required when the user enters a new value in a spin button, but
 * doesn't leave the spin entry before switching tabs with an accel.
 */
void
ag_chart_edit_update(AgChartEdit *chart_edit)
{
    GtkWidget *current;
    GtkWindow *window = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(chart_edit)));

    current = gtk_window_get_focus(window);

    if (GTK_IS_SPIN_BUTTON(current)) {
        gtk_spin_button_update(GTK_SPIN_BUTTON(current));
    }
}
static gboolean
panel_popup_menu (GtkWidget           *treeview,
		  PlumaDocumentsPanel *panel)
{
	/* Only respond if the treeview is the actual focus */
	if (gtk_window_get_focus (GTK_WINDOW (panel->priv->window)) == treeview)
	{
		return show_popup_menu (panel, NULL);
	}

	return FALSE;
}
void notification_trayicon_on_activate(GtkStatusIcon *status_icon, gpointer user_data)
{
  MainWindow *mainwin = mainwindow_get_mainwindow();

  if(mainwin && gtk_widget_get_visible(GTK_WIDGET(mainwin->window)) == TRUE)
    focused_widget = gtk_window_get_focus(GTK_WINDOW(mainwin->window));

  notification_toggle_hide_show_window();

  if(mainwin && gtk_widget_get_visible(GTK_WIDGET(mainwin->window)) == TRUE)
    gtk_window_set_focus(GTK_WINDOW(mainwin->window), focused_widget);
}
Example #28
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);
    }
}
Example #29
0
/*
 * GtkWindow catches keybindings for the menu items _before_ passing them to
 * the focused widget. This is unfortunate and means that pressing ctrl+V
 * in an entry on a panel ends up pasting text in the TextView.
 * Here we override GtkWindow's handler to do the same things that it
 * does, but in the opposite order and then we chain up to the grand
 * parent handler, skipping gtk_window_key_press_event.
 */
static gboolean
anjuta_window_key_press_event (GtkWidget   *widget,
                            GdkEventKey *event)
{
	static gpointer grand_parent_class = NULL;
	GtkWindow *window = GTK_WINDOW (widget);
	GtkWidget *focus = gtk_window_get_focus (window);
	gboolean handled = FALSE;

	if (grand_parent_class == NULL)
		grand_parent_class = g_type_class_peek_parent (parent_class);

	/* Special case the editor - it catches all shortcuts otherwise */
	if (GTK_SOURCE_IS_VIEW (focus))
		if (gtk_window_activate_key (window, event))
			return TRUE;
	switch (event->keyval)
	{
		case GDK_KEY_F1:
		case GDK_KEY_F2:
		case GDK_KEY_F3:
		case GDK_KEY_F4:
		case GDK_KEY_F5:
		case GDK_KEY_F6:
		case GDK_KEY_F7:
		case GDK_KEY_F8:
		case GDK_KEY_F9:
		case GDK_KEY_F10:
		case GDK_KEY_F11:
		case GDK_KEY_F12:
			/* handle mnemonics and accelerators */
			if (!handled)
				handled = gtk_window_activate_key (window, event);
			break;
		default:
			/* handle focus widget key events */
			if (!handled)
				handled = gtk_window_propagate_key_event (window, event);
	}

	/* handle mnemonics and accelerators */
	if (!handled)
		handled = gtk_window_activate_key (window, event);

	/* Chain up, invokes binding set */
	if (!handled)
		handled = GTK_WIDGET_CLASS (grand_parent_class)->key_press_event (widget, event);

	return handled;
}
Example #30
0
/* Edit->Copy */
void
action_copy(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_copy_clipboard(WEBKIT_WEB_VIEW(widget));
	else if((GTK_IS_LABEL(widget) && gtk_label_get_selectable(GTK_LABEL(widget)))
		|| GTK_IS_ENTRY(widget) || GTK_IS_TEXT_VIEW(widget))
		g_signal_emit_by_name(widget, "copy-clipboard", NULL);
	else /* If we don't know how to copy from it, just copy from the source */
		g_signal_emit_by_name(i7_document_get_default_view(document), "copy-clipboard", NULL);
}