예제 #1
0
JNIEXPORT jboolean JNICALL
Java_org_gnome_gtk_GtkSelectionData_gtk_1selection_1data_1targets_1include_1text
(
	JNIEnv* env,
	jclass cls,
	jlong _self
)
{
	gboolean result;
	jboolean _result;
	GtkSelectionData* self;

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

	// call function
	result = gtk_selection_data_targets_include_text(self);

	// cleanup parameter self

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

	// and finally
	return _result;
}
예제 #2
0
NS_IMETHODIMP
nsClipboard::HasDataMatchingFlavors(nsISupportsArray *aFlavorList,
                                    PRInt32 aWhichClipboard, PRBool *_retval)
{
    *_retval = PR_FALSE;

    PRUint32 length = 0;
    aFlavorList->Count(&length);
    if (!length)
        return NS_OK;

    GtkSelectionData *selection_data =
        GetTargets(GetSelectionAtom(aWhichClipboard));
    if (!selection_data)
        return NS_OK;

    gint n_targets = 0;
    GdkAtom *targets = NULL;

    if (!gtk_selection_data_get_targets(selection_data,
                                        &targets, &n_targets) ||
            !n_targets)
        return NS_OK;

    // Walk through the provided types and try to match it to a
    // provided type.
    for (PRUint32 i = 0; i < length && !*_retval; i++) {
        nsCOMPtr<nsISupports> genericFlavor;
        aFlavorList->GetElementAt(i, getter_AddRefs(genericFlavor));
        nsCOMPtr<nsISupportsCString> flavorWrapper;
        flavorWrapper = do_QueryInterface(genericFlavor);

        if (flavorWrapper) {
            nsXPIDLCString myStr;
            flavorWrapper->ToString(getter_Copies(myStr));

            // We special case text/unicode here.
            if (!strcmp(myStr, kUnicodeMime) &&
                    gtk_selection_data_targets_include_text(selection_data)) {
                *_retval = PR_TRUE;
                break;
            }

            for (PRInt32 j = 0; j < n_targets; j++) {
                gchar *atom_name = gdk_atom_name(targets[j]);
                if (!strcmp(atom_name, (const char *)myStr))
                    *_retval = PR_TRUE;

                g_free(atom_name);

                if (*_retval)
                    break;
            }
        }
    }
    gtk_selection_data_free(selection_data);
    g_free(targets);

    return NS_OK;
}
예제 #3
0
NS_IMETHODIMP
nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength,
                                    PRInt32 aWhichClipboard, PRBool *_retval)
{
    if (!aFlavorList || !_retval)
        return NS_ERROR_NULL_POINTER;

    *_retval = PR_FALSE;

    GtkSelectionData *selection_data =
        GetTargets(GetSelectionAtom(aWhichClipboard));
    if (!selection_data)
        return NS_OK;

    gint n_targets = 0;
    GdkAtom *targets = NULL;

    if (!gtk_selection_data_get_targets(selection_data, 
                                        &targets, &n_targets) ||
        !n_targets)
        return NS_OK;

    // Walk through the provided types and try to match it to a
    // provided type.
    for (PRUint32 i = 0; i < aLength && !*_retval; i++) {
        // We special case text/unicode here.
        if (!strcmp(aFlavorList[i], kUnicodeMime) && 
            gtk_selection_data_targets_include_text(selection_data)) {
            *_retval = PR_TRUE;
            break;
        }

        for (PRInt32 j = 0; j < n_targets; j++) {
            gchar *atom_name = gdk_atom_name(targets[j]);
            if (!atom_name)
                continue;

            if (!strcmp(atom_name, aFlavorList[i]))
                *_retval = PR_TRUE;

            // X clipboard wants image/jpeg, not image/jpg
            if (!strcmp(aFlavorList[i], kJPEGImageMime) && !strcmp(atom_name, "image/jpeg"))
                *_retval = PR_TRUE;

            g_free(atom_name);

            if (*_retval)
                break;
        }
    }
    gtk_selection_data_free(selection_data);
    g_free(targets);

    return NS_OK;
}
예제 #4
0
static void
popup_targets_received (GtkClipboard     *clipboard,
                        GtkSelectionData *data,
                        gpointer          user_data)
{
  PopupInfo *popup_info = user_data;
  g_autoptr(IdeTerminal) self = NULL;
  g_autoptr(GdkEvent) event = NULL;
  IdeTerminalPrivate *priv;

  g_assert (popup_info != NULL);
  g_assert (IDE_IS_TERMINAL (popup_info->terminal));

  self = g_steal_pointer (&popup_info->terminal);
  priv = ide_terminal_get_instance_private (self);
  event = g_steal_pointer (&popup_info->event);

  if (gtk_widget_get_realized (GTK_WIDGET (self)))
    {
      DzlWidgetActionGroup *group;
      GMenu *menu;
      gboolean clipboard_contains_text;
      gboolean have_selection;

      clipboard_contains_text = gtk_selection_data_targets_include_text (data);
      have_selection = vte_terminal_get_has_selection (VTE_TERMINAL (self));

      g_clear_pointer (&priv->popup_menu, gtk_widget_destroy);

      priv->url = vte_terminal_match_check_event (VTE_TERMINAL (self), event, NULL);

      menu = dzl_application_get_menu_by_id (DZL_APPLICATION_DEFAULT, "ide-terminal-view-popup-menu");
      priv->popup_menu = gtk_menu_new_from_model (G_MENU_MODEL (menu));

      group = DZL_WIDGET_ACTION_GROUP (gtk_widget_get_action_group (GTK_WIDGET (self), "terminal"));

      dzl_widget_action_group_set_action_enabled (group, "copy-link-address", priv->url != NULL);
      dzl_widget_action_group_set_action_enabled (group, "open-link", priv->url != NULL);
      dzl_widget_action_group_set_action_enabled (group, "copy-clipboard", have_selection);
      dzl_widget_action_group_set_action_enabled (group, "paste-clipboard", clipboard_contains_text);

      dzl_gtk_widget_add_style_class (priv->popup_menu, GTK_STYLE_CLASS_CONTEXT_MENU);
      gtk_menu_attach_to_widget (GTK_MENU (priv->popup_menu), GTK_WIDGET (self), popup_menu_detach);

      g_signal_emit (self, signals[POPULATE_POPUP], 0, priv->popup_menu);

      gtk_menu_popup_at_pointer (GTK_MENU (priv->popup_menu), event);
    }

  g_slice_free (PopupInfo, popup_info);
}
static void
received_clipboard_contents (GtkClipboard     *clipboard,
			     GtkSelectionData *selection_data,
			     gpointer          data)
{
	GtkActionGroup *action_group;
	GtkAction *action;

	action_group = data;

	action = gtk_action_group_get_action (action_group,
					      "Paste");
	if (action != NULL) {
		gtk_action_set_sensitive (action,
					  gtk_selection_data_targets_include_text (selection_data));
	}

	g_object_unref (action_group);
}