Exemplo n.º 1
0
static void
do_highlight (GtkWidget *widget, gboolean highlight)
{
	gboolean have_drag;

	/* FIXME: what's going on here ? How are we highlighting
	 *        the toplevel widget ? I don't think we are ...
	 */

	have_drag = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
							"have-drag"));
	if(highlight) {
		if(!have_drag) {
			g_object_set_data (G_OBJECT (widget), "have-drag",
					   GINT_TO_POINTER (TRUE));
			gtk_drag_highlight (widget);
		}
	} else {
		if(have_drag) {
			g_object_set_data (G_OBJECT (widget),
					   "have-drag", NULL);
			gtk_drag_unhighlight (widget);
		}
	}
}
Exemplo n.º 2
0
static gboolean
gpview_document_view_drag_motion_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, GPViewSymbolView *view)
{
    GPViewDocumentViewPrivate *privat = GPVIEW_DOCUMENT_VIEW_GET_PRIVATE(view);

    if (privat != NULL)
    {
        GdkAtom target;

        gtk_drag_highlight(widget);

        target = gtk_drag_dest_find_target(widget, context, NULL);

        if (target == GDK_NONE)
        {
            gdk_drag_status(context, 0, time);
        }
        else
        {
            gdk_drag_status(context, gdk_drag_context_get_suggested_action(context), time);
        }
    }

    return TRUE;
}
Exemplo n.º 3
0
static gboolean
statusbar_flash_temporary_msg(gpointer data _U_)
{
    gboolean retval = TRUE;

    if (flash_time > 0) {
        flash_highlight = !flash_highlight;
    } else {
        flash_highlight = FALSE;
        retval = FALSE;
    }

    /*
     * As of 2.18.3 gtk_drag_highlight just draws a border around the widget
     * so we can abuse it here.
     */
    if (flash_highlight) {
        gtk_drag_highlight(info_bar);
    } else {
        gtk_drag_unhighlight(info_bar);
    }

    flash_time -= TEMPORARY_FLASH_INTERVAL;

    return retval;
}
JNIEXPORT void JNICALL 
Java_gnu_java_awt_dnd_peer_gtk_GtkDragSourceContextPeer_nativeStartDrag
  (JNIEnv *env, jobject obj, jobject img, jint x, jint y, jint act,
   jstring target)
{
  void *ptr;
  const gchar *data;
  GtkTargetEntry tar[1];
  GdkEvent *event;
  GdkPixbuf *image = NULL;
  GdkDragContext *context = NULL;
  GdkDragAction action = GDK_ACTION_DEFAULT;
  
  gdk_threads_enter ();

  ptr = NSA_GET_GLOBAL_REF (env, obj);

  data = (*env)->GetStringUTFChars (env, target, NULL);
  tar[0].target = (gchar *) data;  
  event = gdk_event_new (GDK_ALL_EVENTS_MASK);
  
  switch (act)
    {
    case ACTION_COPY:
      action = GDK_ACTION_COPY;
      break;
    case ACTION_MOVE:
      action = GDK_ACTION_MOVE;
      break;
    case ACTION_COPY_OR_MOVE:
      action = GDK_ACTION_COPY | GDK_ACTION_MOVE;
      break;
    case ACTION_LINK:
      action = GDK_ACTION_LINK;
      break;
    default:
      action = GDK_ACTION_DEFAULT;
    }

  gtk_drag_highlight (widget);
  context = gtk_drag_begin (widget, 
             gtk_target_list_new (tar, sizeof (tar) / sizeof (GtkTargetEntry)), 
             action, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, event);

  if (img != NULL)
  {
    image = cp_gtk_image_get_pixbuf (env, img);
    gtk_drag_set_icon_pixbuf (context, image, x, y);
  }

  gdk_event_free (event);
  (*env)->ReleaseStringUTFChars (env, target, data);  
  
  gdk_threads_leave ();
}
Exemplo n.º 5
0
/**
 * gimp_highlight_widget:
 * @widget:
 * @highlight:
 *
 * Calls gtk_drag_highlight() on @widget if @highlight is %TRUE,
 * calls gtk_drag_unhighlight() otherwise.
 **/
void
gimp_highlight_widget (GtkWidget *widget,
                       gboolean   highlight)
{
  g_return_if_fail (GTK_IS_WIDGET (widget));

  if (highlight)
    gtk_drag_highlight (widget);
  else
    gtk_drag_unhighlight (widget);
}
Exemplo n.º 6
0
int
clip_GTK_DRAGHIGHLIGHT(ClipMachine * cm)
{
        C_widget     *cwid = _fetch_cw_arg(cm);

	CHECKCWID(cwid, GTK_IS_WIDGET);

        gtk_drag_highlight(GTK_WIDGET(cwid->widget));

	return 0;
err:
	return 1;
}
Exemplo n.º 7
0
static gboolean
gstyle_color_widget_on_drag_motion (GtkWidget      *widget,
                                    GdkDragContext *context,
                                    gint            x,
                                    gint            y,
                                    guint           time)
{
  GstyleColorWidget *self = (GstyleColorWidget *)widget;
  GstylePaletteWidgetDndLockFlags dnd_lock;
  GdkAtom target;
  GdkDragAction drag_action;

  g_assert (GSTYLE_IS_COLOR_WIDGET (self));
  g_assert (GDK_IS_DRAG_CONTEXT (context));

  target = gtk_drag_dest_find_target (widget, context, NULL);
  dnd_lock = get_palette_widget_dnd_lock (self);
  if ((dnd_lock & GSTYLE_PALETTE_WIDGET_DND_LOCK_FLAGS_DRAG) != 0)
    {
      gdk_drag_status (context, 0, time);
      return FALSE;
    }

  if ((target == gdk_atom_intern_static_string ("GSTYLE_COLOR_WIDGET") ||
       target == gdk_atom_intern_static_string ("application/x-color") ||
       gtk_targets_include_text (&target, 1)) &&
      (dnd_lock & GSTYLE_PALETTE_WIDGET_DND_LOCK_FLAGS_DROP) == 0 &&
      is_in_drop_zone (self, x, y))
    {
      gtk_drag_highlight (widget);

      drag_action = gdk_drag_context_get_actions (context);
      if ((drag_action | GDK_ACTION_COPY) != 0)
        {
          gdk_drag_status (context, GDK_ACTION_COPY, time);
          return TRUE;
        }
    }

  gdk_drag_status (context, 0, time);
  return FALSE;
}
Exemplo n.º 8
0
static gboolean
slot_proxy_drag_motion (GtkWidget          *widget,
                        GdkDragContext     *context,
                        int                 x,
                        int                 y,
                        unsigned int        time,
                        gpointer            user_data)
{
    NautilusDragSlotProxyInfo *drag_info;
    NautilusWindowSlot *target_slot;
    GtkWidget *window;
    GdkAtom target;
    int action;
    char *target_uri;
    GFile *location;
    gboolean valid_text_drag;
    gboolean valid_xds_drag;

    drag_info = user_data;

    action = 0;
    valid_text_drag = FALSE;
    valid_xds_drag = FALSE;

    if (gtk_drag_get_source_widget (context) == widget) {
        goto out;
    }

    window = gtk_widget_get_toplevel (widget);
    g_assert (NAUTILUS_IS_WINDOW (window));

    if (!drag_info->have_data) {
        target = gtk_drag_dest_find_target (widget, context, NULL);

        if (target == GDK_NONE) {
            goto out;
        }

        gtk_drag_get_data (widget, context, target, time);
    }

    target_uri = NULL;
    if (drag_info->target_file != NULL) {
        target_uri = nautilus_file_get_uri (drag_info->target_file);
    } else {
        if (drag_info->target_slot != NULL) {
            target_slot = drag_info->target_slot;
        } else {
            target_slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window));
        }

        if (target_slot != NULL) {
            location = nautilus_window_slot_get_location (target_slot);
            target_uri = g_file_get_uri (location);
        }
    }

    if (target_uri != NULL) {
        NautilusFile *file;
        gboolean can;
        file = nautilus_file_get_existing_by_uri (target_uri);
        can = nautilus_file_can_write (file);
        g_object_unref (file);
        if (!can) {
            action = 0;
            goto out;
        }
    }

    if (drag_info->have_data &&
            drag_info->have_valid_data) {
        if (drag_info->info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
            nautilus_drag_default_drop_action_for_icons (context, target_uri,
                    drag_info->data.selection_list,
                    0,
                    &action);
        } else if (drag_info->info == NAUTILUS_ICON_DND_URI_LIST) {
            action = nautilus_drag_default_drop_action_for_uri_list (context, target_uri);
        } else if (drag_info->info == NAUTILUS_ICON_DND_NETSCAPE_URL) {
            action = nautilus_drag_default_drop_action_for_netscape_url (context);
        } else if (drag_info->info == NAUTILUS_ICON_DND_TEXT) {
            valid_text_drag = TRUE;
        } else if (drag_info->info == NAUTILUS_ICON_DND_XDNDDIRECTSAVE ||
                   drag_info->info == NAUTILUS_ICON_DND_RAW) {
            valid_xds_drag = TRUE;
        }
    }

    g_free (target_uri);

out:
    if (action != 0 || valid_text_drag || valid_xds_drag) {
        gtk_drag_highlight (widget);
        slot_proxy_check_switch_location_timer (drag_info, widget);
    } else {
        gtk_drag_unhighlight (widget);
        slot_proxy_remove_switch_location_timer (drag_info);
    }

    gdk_drag_status (context, action, time);

    return TRUE;
}
Exemplo n.º 9
0
static gboolean
slot_proxy_drag_motion (GtkWidget          *widget,
			GdkDragContext     *context,
			int                 x,
			int                 y,
			unsigned int        time,
			gpointer            user_data)
{
  NemoDragSlotProxyInfo *drag_info;
  NemoWindowSlot *target_slot;
  GtkWidget *window;
  GdkAtom target;
  int action = 0;
  char *target_uri;

  if (gtk_drag_get_source_widget (context) == widget) {
    goto out;
  }

  drag_info = user_data;

  window = gtk_widget_get_toplevel (widget);
  g_assert (NEMO_IS_WINDOW (window));

  if (!drag_info->have_data) {
    target = gtk_drag_dest_find_target (widget, context, NULL);

    if (target == GDK_NONE) {
      goto out;
    }

    gtk_drag_get_data (widget, context, target, time);
  }

  target_uri = NULL;
  if (drag_info->target_file != NULL) {
    target_uri = nemo_file_get_uri (drag_info->target_file);
  } else {
    if (drag_info->target_slot != NULL) {
      target_slot = drag_info->target_slot;
    } else {
      target_slot = nemo_window_get_active_slot (NEMO_WINDOW (window));
    }

    if (target_slot != NULL) {
      target_uri = nemo_window_slot_get_current_uri (target_slot);
    }
  }

  if (drag_info->have_data &&
      drag_info->have_valid_data) {
    if (drag_info->info == NEMO_ICON_DND_GNOME_ICON_LIST) {
      nemo_drag_default_drop_action_for_icons (context,
                                               target_uri,
                                               drag_info->data.selection_list,
                                               &action,
                                               &drag_info->desktop_dnd_source_fs,
                                               &drag_info->desktop_dnd_can_delete_source);
    } else if (drag_info->info == NEMO_ICON_DND_URI_LIST) {
      action = nemo_drag_default_drop_action_for_uri_list (context, target_uri);
    } else if (drag_info->info == NEMO_ICON_DND_NETSCAPE_URL) {
      action = nemo_drag_default_drop_action_for_netscape_url (context);
    }
  }

  g_free (target_uri);

 out:
  if (action != 0) {
    gtk_drag_highlight (widget);
  } else {
    gtk_drag_unhighlight (widget);
  }

  gdk_drag_status (context, action, time);

  return TRUE;
}
Exemplo n.º 10
0
static VALUE
rg_m_highlight(VALUE self, VALUE widget)
{
    gtk_drag_highlight(RVAL2WIDGET(widget));
    return self;
}