antiright-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Antiright-devel] antiright/gtkshell Makefile button.c gtkshell.h...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/gtkshell Makefile button.c gtkshell.h...
Date: Sat, 24 Feb 2007 08:49:27 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/02/24 08:49:27

Modified files:
        gtkshell       : Makefile button.c gtkshell.h label.c 
Added files:
        gtkshell       : dragdrop.c dragdrop.h 

Log message:
        Added preliminary drag and drop support.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/Makefile?cvsroot=antiright&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.c?cvsroot=antiright&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.h?cvsroot=antiright&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/label.c?cvsroot=antiright&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/dragdrop.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/dragdrop.h?cvsroot=antiright&rev=1.1

Patches:
Index: Makefile
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/Makefile,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- Makefile    22 Feb 2007 23:16:45 -0000      1.7
+++ Makefile    24 Feb 2007 08:49:27 -0000      1.8
@@ -10,12 +10,12 @@
 objects=gtkshell.o arguments.o options.o callbacks.o updated.o\
                                label.o button.o text.o updated_label.o 
updated_progress.o\
                                updated_options.o add_options.o 
option_options.o dialog_options.o\
-                               file_dialog.o row.o containers.o geometry.o 
font.o
+                               file_dialog.o row.o containers.o geometry.o 
font.o dragdrop.o
 
 sources=gtkshell.c arguments.c options.c callbacks.c updated.c\
                                label.c button.c text.c updated_label.c 
updated_progress.c\
                                updated_options.c add_options.c 
option_options.c dialog_options.c\
-                               file_dialog.c row.c containers.c geometry.c 
font.c
+                               file_dialog.c row.c containers.c geometry.c 
font.c dragdrop.c
 
 all: $(objects) main.o
        $(CC) -o gtkshell $(objects) main.o $(LDFLAGS)

Index: button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/button.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- button.c    23 Feb 2007 03:11:52 -0000      1.11
+++ button.c    24 Feb 2007 08:49:27 -0000      1.12
@@ -21,9 +21,6 @@
 */
 
 #include "gtkshell.h"
-
-GtkWidget *gsh_button;
-
 void
 gsh_command_button (struct GSH * gsh, char *command)
 {
@@ -45,6 +42,8 @@
   gsh->button = gtk_button_new_with_label (label_text);
   g_free (label_text);
 
+       gsh_setup_drag_drop(gsh->button);
+
        /address@hidden@*/
   (void)g_signal_connect (G_OBJECT (gsh->button), "clicked",
                    G_CALLBACK (system_cb), cb);

Index: gtkshell.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- gtkshell.h  23 Feb 2007 21:23:27 -0000      1.17
+++ gtkshell.h  24 Feb 2007 08:49:27 -0000      1.18
@@ -81,6 +81,7 @@
 #include "containers.h"
 #include "geometry.h"
 #include "font.h"
+#include "dragdrop.h"
 
 void
   gsh_stack_init (struct GSH * gsh, int *argc, char ***argv);

Index: label.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/label.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- label.c     23 Feb 2007 19:15:05 -0000      1.9
+++ label.c     24 Feb 2007 08:49:27 -0000      1.10
@@ -33,6 +33,8 @@
   else
     gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
 
+       gtk_label_set_selectable (GTK_LABEL (label), TRUE);
+
        gsh_widget_set_font_mono(label);
 }
 

Index: dragdrop.c
===================================================================
RCS file: dragdrop.c
diff -N dragdrop.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ dragdrop.c  24 Feb 2007 08:49:27 -0000      1.1
@@ -0,0 +1,143 @@
+/*
+  AntiRight
+  (c) 2002-2006 Jeffrey Bedard
+  address@hidden
+
+  This file is part of AntiRight.
+
+  AntiRight is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  AntiRight is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with AntiRight; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+*/
+
+#include "gtkshell.h"
+
+/* Portions Copyright 2005 Ryan McDougall, GNU GPL terms.
+ * Based on drag and drop tutorial: 
+ * http://live.gnome.org/GnomeLove/DragNDropTutorial */
+
+enum {
+       TARGET_STRING
+};
+
+static GtkTargetEntry target_list[] = 
+{
+               { "text/plain", 0, TARGET_STRING }
+};
+
+static guint n_targets = G_N_ELEMENTS (target_list);
+
+static void
+drag_received(GtkWidget * widget, GdkDragContext *context, gint x,
+                                                       gint y, 
GtkSelectionData *selection, guint target_type,
+                                                       guint time, gpointer 
data);
+
+static gboolean 
+drag_drop(GtkWidget * widget, GdkDragContext *context, gint x,
+                                       gint y, guint time, gpointer data);
+
+static void
+drag_data_get(GtkWidget * widget, GdkDragContext *context, 
+                                                       GtkSelectionData 
*selection, guint target_type,
+                                                       guint time, gpointer 
data);
+
+static void
+drag_begin (GtkWidget * widget, GdkDragContext *context, gpointer data);
+
+static void
+drag_end (GtkWidget * widget, GdkDragContext *context, gpointer data);
+
+void
+gsh_setup_drag_drop(GtkWidget * widget)
+{
+       gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_MOTION 
+                                                                               
        | GTK_DEST_DEFAULT_HIGHLIGHT, target_list, n_targets,
+                                                                               
        GDK_ACTION_COPY);
+       gtk_drag_source_set (widget, GDK_BUTTON1_MASK, target_list, n_targets,
+                                                                               
         GDK_ACTION_COPY);
+
+       (void) g_signal_connect (widget, "drag-data-received",
+                                                                               
                         G_CALLBACK(drag_received), NULL);
+       (void) g_signal_connect (widget, "drag-drop", G_CALLBACK(drag_drop), 
NULL);
+       (void) g_signal_connect (widget, "drag-data-get",
+                                                                               
                         G_CALLBACK(drag_data_get), NULL);
+
+}
+
+static void
+drag_received(GtkWidget * widget, GdkDragContext *context, gint x,
+                                                       gint y, 
GtkSelectionData *selection, guint target_type,
+                                                       guint time, gpointer 
data)
+{
+       gboolean drag_status;
+
+       switch (target_type)
+               {
+               case TARGET_STRING:
+                       g_print("%s", (gchar *) selection->data);
+                       drag_status=TRUE;
+                       break;
+               default:
+                       drag_status=FALSE;
+                       ARWARN("invalid data dropped");
+               }
+
+       gtk_drag_finish(context, drag_status, FALSE, time);
+}
+
+static gboolean
+drag_drop(GtkWidget * widget, GdkDragContext *context, gint x,
+                                       gint y, guint time, gpointer data)
+{
+       GdkAtom target_type;
+
+       target_type = 
+               GDK_POINTER_TO_ATOM (g_list_nth_data (context->targets,
+                                                                               
                                                                                
        TARGET_STRING));
+
+       ARIFP(context->targets)
+               {
+                       gtk_drag_get_data ( widget, context, target_type, time 
);
+                       return TRUE;
+               }
+       else
+               return FALSE;
+}
+
+static void
+drag_data_get(GtkWidget * widget, GdkDragContext *context, 
+                                                       GtkSelectionData 
*selection, guint target_type,
+                                                       guint time, gpointer 
data)
+{
+       const gchar * source_data;
+
+
+       source_data=gtk_button_get_label(GTK_BUTTON(widget));
+
+       gtk_selection_data_set(selection, selection->target, sizeof(gchar), 
+                                                                               
                 (guchar*)source_data, strlen(source_data));
+}
+
+/* Use to set icon.  */
+static void
+drag_begin (GtkWidget * widget, GdkDragContext *context, gpointer data)
+{
+}
+
+static void
+drag_end (GtkWidget * widget, GdkDragContext *context, gpointer data)
+{
+}
+
+
+

Index: dragdrop.h
===================================================================
RCS file: dragdrop.h
diff -N dragdrop.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ dragdrop.h  24 Feb 2007 08:49:27 -0000      1.1
@@ -0,0 +1,30 @@
+/*
+  AntiRight
+  (c) 2002-2006 Jeffrey Bedard
+  address@hidden
+
+  This file is part of AntiRight.
+
+  AntiRight is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  AntiRight is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with AntiRight; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+*/
+
+#ifndef GSH_DRAGDROP_H
+#define GSH_DRAGDROP_H
+
+void
+gsh_setup_drag_drop(GtkWidget * widget);
+
+#endif /* GSH_DRAGDROP_H */
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]