mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Allow the context menu when GncCellRendererTextView is in edit mode.
This commit is contained in:
@@ -71,13 +71,20 @@ gcrtv_editing_done (GtkCellEditable *editable,
|
||||
gchar *path;
|
||||
const gchar *new_text;
|
||||
|
||||
if (GNC_CELL_VIEW (editable)->focus_out_id > 0)
|
||||
if (GNC_CELL_VIEW(editable)->focus_out_id > 0)
|
||||
{
|
||||
g_signal_handler_disconnect (GNC_CELL_VIEW(editable)->text_view,
|
||||
GNC_CELL_VIEW(editable)->focus_out_id);
|
||||
GNC_CELL_VIEW(editable)->focus_out_id = 0;
|
||||
}
|
||||
|
||||
if (GNC_CELL_VIEW(editable)->populate_popup_id > 0)
|
||||
{
|
||||
g_signal_handler_disconnect (GNC_CELL_VIEW(editable)->text_view,
|
||||
GNC_CELL_VIEW(editable)->populate_popup_id);
|
||||
GNC_CELL_VIEW(editable)->populate_popup_id = 0;
|
||||
}
|
||||
|
||||
if (GNC_CELL_VIEW(editable)->editing_canceled)
|
||||
{
|
||||
gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER(cell_tv), TRUE);
|
||||
@@ -120,9 +127,8 @@ gcrtv_start_editing (GtkCellRenderer *cell,
|
||||
g_object_get (G_OBJECT(cell_tv), "editable", &iseditable, NULL);
|
||||
|
||||
/* If the cell isn't editable we return NULL. */
|
||||
if (iseditable == FALSE) {
|
||||
if (iseditable == FALSE)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
editable = g_object_new (GNC_TYPE_CELL_VIEW, NULL);
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ gnc_cell_view_init (GncCellView *cv)
|
||||
gtk_widget_show (cv->text_view);
|
||||
|
||||
cv->focus_out_id = 0;
|
||||
cv->populate_popup_id = 0;
|
||||
cv->tooltip_id = 0;
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET(cv->text_view), TRUE);
|
||||
@@ -167,9 +168,28 @@ gtk_cell_editable_key_press_event (GtkTextView *text_view,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gcv_popup_unmap (GtkMenu *menu, GncCellView *cv)
|
||||
{
|
||||
cv->in_popup_menu = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gcv_populate_popup (GtkTextView *text_view,
|
||||
GtkWidget *popup,
|
||||
GncCellView *cv)
|
||||
{
|
||||
cv->in_popup_menu = TRUE;
|
||||
g_signal_connect (popup, "unmap",
|
||||
G_CALLBACK (gcv_popup_unmap), cv);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gcv_focus_out_event (GtkWidget *widget, GdkEvent *event, GncCellView *cv)
|
||||
{
|
||||
if (cv->in_popup_menu)
|
||||
return FALSE;
|
||||
|
||||
cv->editing_canceled = TRUE;
|
||||
|
||||
if (cv->focus_out_id > 0)
|
||||
@@ -177,6 +197,11 @@ gcv_focus_out_event (GtkWidget *widget, GdkEvent *event, GncCellView *cv)
|
||||
g_signal_handler_disconnect (cv->text_view, cv->focus_out_id);
|
||||
cv->focus_out_id = 0;
|
||||
}
|
||||
if (cv->populate_popup_id > 0)
|
||||
{
|
||||
g_signal_handler_disconnect (cv->text_view, cv->populate_popup_id);
|
||||
cv->populate_popup_id = 0;
|
||||
}
|
||||
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE(cv));
|
||||
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE(cv));
|
||||
|
||||
@@ -217,6 +242,11 @@ gcv_start_editing (GtkCellEditable *cell_editable,
|
||||
cv->focus_out_id = g_signal_connect (G_OBJECT(cv->text_view),
|
||||
"focus-out-event",
|
||||
G_CALLBACK(gcv_focus_out_event), cv);
|
||||
|
||||
cv->populate_popup_id = g_signal_connect (G_OBJECT(cv->text_view),
|
||||
"populate-popup",
|
||||
G_CALLBACK(gcv_populate_popup),
|
||||
cv);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -43,7 +43,9 @@ struct _GncCellView
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
gulong focus_out_id;
|
||||
gulong populate_popup_id;
|
||||
guint tooltip_id;
|
||||
gboolean in_popup_menu;
|
||||
gboolean editing_canceled;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user