Commit d6577d48b2d2dc047202c1db0f325beedba3711c

Authored by perry.werneck@gmail.com
1 parent a19024d3

Iniciando implementação de clipboard

src/gtk/actions.c
@@ -60,6 +60,12 @@ static void activate_action(GtkAction *action, GtkWidget *widget) @@ -60,6 +60,12 @@ static void activate_action(GtkAction *action, GtkWidget *widget)
60 gtk_widget_activate(widget); 60 gtk_widget_activate(widget);
61 } 61 }
62 62
  63 +static void copy_action(GtkAction *action, GtkWidget *widget)
  64 +{
  65 + trace("Action %s activated on widget %p",gtk_action_get_name(action),widget);
  66 + v3270_copy(GTK_V3270(widget));
  67 +}
  68 +
63 void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id) 69 void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id)
64 { 70 {
65 #undef DECLARE_LIB3270_ACTION 71 #undef DECLARE_LIB3270_ACTION
@@ -92,6 +98,7 @@ void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, @@ -92,6 +98,7 @@ void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name,
92 { 98 {
93 { "activate", activate_action }, 99 { "activate", activate_action },
94 { "connect", connect_action }, 100 { "connect", connect_action },
  101 + { "copy", copy_action },
95 { "disconnect", disconnect_action }, 102 { "disconnect", disconnect_action },
96 }; 103 };
97 104
src/gtk/v3270/clipboard.c 0 → 100644
@@ -0,0 +1,88 @@ @@ -0,0 +1,88 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
  19 + * Place, Suite 330, Boston, MA, 02111-1307, USA
  20 + *
  21 + * Este programa está nomeado como clipboard.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include <gtk/gtk.h>
  31 + #include <pw3270.h>
  32 + #include "v3270.h"
  33 + #include "private.h"
  34 +
  35 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  36 +
  37 + enum
  38 + {
  39 + CLIPBOARD_TYPE_TEXT,
  40 + };
  41 +
  42 + static const GtkTargetEntry targets[] =
  43 + {
  44 + { "STRING", 0, CLIPBOARD_TYPE_TEXT },
  45 + { "text/plain", 0, CLIPBOARD_TYPE_TEXT },
  46 + };
  47 +
  48 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  49 +
  50 +static void clipboard_clear(GtkClipboard *clipboard, GObject *obj)
  51 +{
  52 + trace("%s widget=%p",__FUNCTION__,obj);
  53 +
  54 +}
  55 +
  56 +void clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint target, GObject *obj)
  57 +{
  58 + v3270 *widget = GTK_V3270(obj);
  59 +
  60 + trace("%s: widget=%p target=\"%s\"",__FUNCTION__,obj,targets[target].target);
  61 +
  62 + switch(target)
  63 + {
  64 + case CLIPBOARD_TYPE_TEXT:
  65 + gtk_clipboard_set_text(clipboard,"TESTE",-1);
  66 + break;
  67 +
  68 + default:
  69 + g_warning("Unexpected clipboard type %d\n",target);
  70 + }
  71 +}
  72 +
  73 +gboolean v3270_copy(v3270 *widget)
  74 +{
  75 + GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
  76 + if(gtk_clipboard_set_with_owner( clipboard,
  77 + targets,
  78 + G_N_ELEMENTS(targets),
  79 + (GtkClipboardGetFunc) clipboard_get,
  80 + (GtkClipboardClearFunc) clipboard_clear,
  81 + G_OBJECT(widget)
  82 + ))
  83 + {
  84 + gtk_clipboard_set_can_store(clipboard,targets,1);
  85 + trace("%s: Clipboard set",__FUNCTION__);
  86 + }
  87 +}
  88 +
src/gtk/v3270/private.h
@@ -121,6 +121,10 @@ void v3270_update_message(v3270 *widget, LIB3270_MESSAGE id); @@ -121,6 +121,10 @@ void v3270_update_message(v3270 *widget, LIB3270_MESSAGE id);
121 void v3270_update_cursor(H3270 *session, unsigned short row, unsigned short col, unsigned char c, unsigned short attr); 121 void v3270_update_cursor(H3270 *session, unsigned short row, unsigned short col, unsigned char c, unsigned short attr);
122 void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on); 122 void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on);
123 123
  124 +// Clipboard
  125 +void v3270_clipboard_set(v3270 *widget);
  126 +void v3270_clipboard_clear(v3270 *widget);
  127 +
124 // Keyboard & Mouse 128 // Keyboard & Mouse
125 gboolean v3270_key_press_event(GtkWidget *widget, GdkEventKey *event); 129 gboolean v3270_key_press_event(GtkWidget *widget, GdkEventKey *event);
126 gboolean v3270_key_release_event(GtkWidget *widget, GdkEventKey *event); 130 gboolean v3270_key_release_event(GtkWidget *widget, GdkEventKey *event);
src/gtk/v3270/sources.mak
1 -V3270_SRC=marshal.c widget.c oia.c iocallback.c keyboard.c draw.c mouse.c 1 +V3270_SRC=marshal.c widget.c oia.c iocallback.c keyboard.c draw.c mouse.c clipboard.c
2 2
src/gtk/v3270/v3270.h
@@ -198,6 +198,9 @@ @@ -198,6 +198,9 @@
198 int v3270_connect(GtkWidget *widget, const gchar *host); 198 int v3270_connect(GtkWidget *widget, const gchar *host);
199 void v3270_disconnect(GtkWidget *widget); 199 void v3270_disconnect(GtkWidget *widget);
200 200
  201 + // Clipboard
  202 + gboolean v3270_copy(v3270 *widget);
  203 +
201 G_END_DECLS 204 G_END_DECLS
202 205
203 #endif // V3270_H_INCLUDED 206 #endif // V3270_H_INCLUDED
src/lib3270/selection.c
@@ -172,6 +172,9 @@ LIB3270_ACTION(unselect) @@ -172,6 +172,9 @@ LIB3270_ACTION(unselect)
172 172
173 CHECK_SESSION_HANDLE(hSession); 173 CHECK_SESSION_HANDLE(hSession);
174 174
  175 + if(!hSession->selected)
  176 + return;
  177 +
175 hSession->selected = 0; 178 hSession->selected = 0;
176 179
177 for(a = 0; a < hSession->rows*hSession->cols; a++) 180 for(a = 0; a < hSession->rows*hSession->cols; a++)
ui/default.xml
@@ -66,7 +66,7 @@ @@ -66,7 +66,7 @@
66 66
67 <separator/> 67 <separator/>
68 <menuitem action='clear' group='online' key='Pause' label='Clear' /> 68 <menuitem action='clear' group='online' key='Pause' label='Clear' />
69 - <menuitem action='eraseinput' icon='clear' group='online' label='Erase input' /> 69 + <menuitem action='EraseInput' icon='clear' group='online' label='Erase input' />
70 <!--- <menuitem action='EraseField' key='<Ctrl>u' group='online' /> --> 70 <!--- <menuitem action='EraseField' key='<Ctrl>u' group='online' /> -->
71 <menuitem action='EraseEOF' group='online' label='Erase to end of field' /> 71 <menuitem action='EraseEOF' group='online' label='Erase to end of field' />
72 <menuitem action='EraseEOL' group='online' label='Erase to end of line' /> 72 <menuitem action='EraseEOL' group='online' label='Erase to end of line' />