Commit 5ac373b93499640d185c47af6650572ff2b5a2b0
1 parent
4133ae8b
Exists in
master
and in
1 other branch
Adjustments in the clipboard signal.
Showing
5 changed files
with
21 additions
and
9 deletions
Show diff stats
src/include/internals.h
| ... | ... | @@ -137,6 +137,9 @@ |
| 137 | 137 | /// @brief Emit the "save-settings" signal. |
| 138 | 138 | G_GNUC_INTERNAL void v3270_emit_save_settings(GtkWidget *widget); |
| 139 | 139 | |
| 140 | + /// @brief Emit "has-text" signal. | |
| 141 | + G_GNUC_INTERNAL void v3270_emit_copy_state(GtkWidget *widget); | |
| 142 | + | |
| 140 | 143 | G_GNUC_INTERNAL gchar * v3270_convert_to_3270_charset(GtkWidget *widget, const gchar *text, const gchar *encoding, GError **error); |
| 141 | 144 | |
| 142 | 145 | /// @brief Add current lib3270 selection to a list | ... | ... |
src/include/v3270.h
| ... | ... | @@ -211,13 +211,15 @@ |
| 211 | 211 | LIB3270_EXPORT void v3270_clipboard_set(GtkWidget *widget, V3270_COPY_MODE mode, gboolean cut); |
| 212 | 212 | LIB3270_EXPORT void v3270_clipboard_get_from_url(GtkWidget *widget, const gchar *url); |
| 213 | 213 | |
| 214 | + /// @brief Check if the widget has saved text. | |
| 215 | + LIB3270_EXPORT gboolean v3270_has_copy(GtkWidget *widget); | |
| 216 | + | |
| 214 | 217 | LIB3270_EXPORT void v3270_paste(GtkWidget *widget) G_GNUC_DEPRECATED; |
| 215 | 218 | LIB3270_EXPORT void v3270_paste_text(GtkWidget *widget) G_GNUC_DEPRECATED; |
| 216 | 219 | LIB3270_EXPORT void v3270_paste_from_file(GtkWidget *widget) G_GNUC_DEPRECATED; |
| 217 | 220 | LIB3270_EXPORT void v3270_copy_selection(GtkWidget *widget, V3270_COPY_MODE mode, gboolean cut) G_GNUC_DEPRECATED; |
| 218 | 221 | LIB3270_EXPORT void v3270_append_selection(GtkWidget *widget, gboolean cut) G_GNUC_DEPRECATED; |
| 219 | 222 | |
| 220 | - | |
| 221 | 223 | // Selections |
| 222 | 224 | |
| 223 | 225 | LIB3270_EXPORT gchar * v3270_get_selected(GtkWidget *widget, gboolean cut); | ... | ... |
src/selection/linux/copy.c
| ... | ... | @@ -116,8 +116,7 @@ void v3270_update_system_clipboard(GtkWidget *widget) |
| 116 | 116 | if(!terminal->selection.blocks) |
| 117 | 117 | { |
| 118 | 118 | // No clipboard data, return. |
| 119 | - g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_CLIPBOARD], 0, FALSE); | |
| 120 | - lib3270_action_group_notify(terminal->host,LIB3270_ACTION_GROUP_COPY); | |
| 119 | + v3270_emit_copy_state(widget); | |
| 121 | 120 | return; |
| 122 | 121 | } |
| 123 | 122 | |
| ... | ... | @@ -171,8 +170,7 @@ void v3270_update_system_clipboard(GtkWidget *widget) |
| 171 | 170 | gtk_target_table_free(targets, n_targets); |
| 172 | 171 | gtk_target_list_unref(list); |
| 173 | 172 | |
| 174 | - g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_CLIPBOARD], 0, TRUE); | |
| 175 | - lib3270_action_group_notify(terminal->host,LIB3270_ACTION_GROUP_COPY); | |
| 173 | + v3270_emit_copy_state(widget); | |
| 176 | 174 | |
| 177 | 175 | } |
| 178 | 176 | ... | ... |
src/selection/selection.c
| ... | ... | @@ -61,6 +61,17 @@ const GList * v3270_get_selection_blocks(GtkWidget *widget) |
| 61 | 61 | return GTK_V3270(widget)->selection.blocks; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | +gboolean v3270_has_copy(GtkWidget *widget) | |
| 65 | +{ | |
| 66 | + g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); | |
| 67 | + return GTK_V3270(widget)->selection.blocks != NULL; | |
| 68 | +} | |
| 69 | + | |
| 70 | +void v3270_emit_copy_state(GtkWidget *widget) | |
| 71 | +{ | |
| 72 | + g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_CLIPBOARD], 0, GTK_V3270(widget)->selection.blocks != NULL); | |
| 73 | + lib3270_action_group_notify(GTK_V3270(widget)->host,LIB3270_ACTION_GROUP_COPY); | |
| 74 | +} | |
| 64 | 75 | |
| 65 | 76 | /** |
| 66 | 77 | * Get lib3270 selection as a g_malloc buffer. | ... | ... |
src/selection/windows/copy.c
| ... | ... | @@ -116,8 +116,7 @@ void v3270_update_system_clipboard(GtkWidget *widget) |
| 116 | 116 | if(!terminal->selection.blocks) |
| 117 | 117 | { |
| 118 | 118 | // No clipboard data, return. |
| 119 | - g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_CLIPBOARD], 0, FALSE); | |
| 120 | - lib3270_action_group_notify(terminal->host,LIB3270_ACTION_GROUP_COPY); | |
| 119 | + v3270_emit_copy_state(widget); | |
| 121 | 120 | return; |
| 122 | 121 | } |
| 123 | 122 | |
| ... | ... | @@ -166,8 +165,7 @@ void v3270_update_system_clipboard(GtkWidget *widget) |
| 166 | 165 | gtk_target_table_free(targets, n_targets); |
| 167 | 166 | gtk_target_list_unref(list); |
| 168 | 167 | |
| 169 | - g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_CLIPBOARD], 0, TRUE); | |
| 170 | - lib3270_action_group_notify(terminal->host,LIB3270_ACTION_GROUP_COPY); | |
| 168 | + v3270_emit_copy_state(widget); | |
| 171 | 169 | |
| 172 | 170 | } |
| 173 | 171 | ... | ... |