Change find-account from GtkDialog to GtkWindow

Change the find account dialogue from a GtkDialog to GtkWindow. This
removes the need for setting the transient parent which allows the
dialogue to be placed behind the main application when jumping to the
account if the the tick box to keep the dialogue open is used.
This commit is contained in:
Robert Fewell 2018-07-19 10:16:04 +01:00
parent 93030c61f1
commit 193176cc25
2 changed files with 77 additions and 98 deletions

View File

@ -44,7 +44,7 @@ enum GncFindAccountColumn {ACC_FULL_NAME, ACCOUNT, PLACE_HOLDER, HIDDEN, NOT_USE
typedef struct
{
GtkWidget *dialog;
GtkWidget *window;
GtkWidget *parent;
QofSession *session;
Account *account;
@ -65,11 +65,7 @@ typedef struct
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_GUI;
void gnc_find_account_dialog_window_destroy_cb (GtkWidget *object, gpointer user_data);
void gnc_find_account_dialog_close_cb (GtkDialog *dialog, gpointer user_data);
void gnc_find_account_dialog_response_cb (GtkDialog *dialog, gint response_id, gpointer user_data);
void
static void
gnc_find_account_dialog_window_destroy_cb (GtkWidget *object, gpointer user_data)
{
FindAccountDialog *facc_dialog = user_data;
@ -77,25 +73,15 @@ gnc_find_account_dialog_window_destroy_cb (GtkWidget *object, gpointer user_data
ENTER(" ");
gnc_unregister_gui_component_by_data (DIALOG_FIND_ACCOUNT_CM_CLASS, facc_dialog);
if (facc_dialog->dialog)
if (facc_dialog->window)
{
gtk_widget_destroy (facc_dialog->dialog);
facc_dialog->dialog = NULL;
gtk_widget_destroy (facc_dialog->window);
facc_dialog->window = NULL;
}
g_free (facc_dialog);
LEAVE(" ");
}
void
gnc_find_account_dialog_close_cb (GtkDialog *dialog, gpointer user_data)
{
FindAccountDialog *facc_dialog = user_data;
ENTER(" ");
gnc_close_gui_component_by_data (DIALOG_FIND_ACCOUNT_CM_CLASS, facc_dialog);
LEAVE(" ");
}
static void
jump_to_account (FindAccountDialog *facc_dialog, Account *jump_account)
{
@ -103,7 +89,7 @@ jump_to_account (FindAccountDialog *facc_dialog, Account *jump_account)
gnc_plugin_page_account_tree_open (jump_account, GTK_WINDOW(facc_dialog->parent));
if (facc_dialog->jump_close == TRUE)
gnc_find_account_dialog_close_cb (GTK_DIALOG(facc_dialog->dialog), facc_dialog);
gnc_close_gui_component_by_data (DIALOG_FIND_ACCOUNT_CM_CLASS, facc_dialog);
}
static void
@ -148,26 +134,25 @@ row_double_clicked (GtkTreeView *treeview, GtkTreePath *path,
jump_to_account (facc_dialog, jump_account);
}
void
gnc_find_account_dialog_response_cb (GtkDialog *dialog, gint response_id, gpointer user_data)
static void
gnc_find_account_dialog_jump_button_cb (GtkWidget * widget, gpointer user_data)
{
FindAccountDialog *facc_dialog = user_data;
gnc_find_account_dialog_jump_to (facc_dialog);
}
switch (response_id)
{
case GTK_RESPONSE_APPLY:
gnc_find_account_dialog_jump_to (facc_dialog);
return;
static void
gnc_find_account_dialog_check_button_cb (GtkWidget * widget, gpointer user_data)
{
FindAccountDialog *facc_dialog = user_data;
gnc_find_account_dialog_jump_set (facc_dialog);
}
case GTK_RESPONSE_YES:
gnc_find_account_dialog_jump_set (facc_dialog);
return;
case GTK_RESPONSE_CLOSE:
default:
gnc_close_gui_component_by_data (DIALOG_FIND_ACCOUNT_CM_CLASS, facc_dialog);
return;
}
static void
gnc_find_account_dialog_close_button_cb (GtkWidget * widget, gpointer user_data)
{
FindAccountDialog *facc_dialog = user_data;
gnc_close_gui_component_by_data (DIALOG_FIND_ACCOUNT_CM_CLASS, facc_dialog);
}
static void
@ -252,34 +237,29 @@ filter_button_cb (GtkButton *button, FindAccountDialog *facc_dialog)
static void
gnc_find_account_dialog_create (GtkWidget *parent, FindAccountDialog *facc_dialog)
{
GtkWidget *dialog;
GtkWidget *window;
GtkBuilder *builder;
GtkTreeSelection *selection;
GtkTreeViewColumn *tree_column;
GtkCellRenderer *cr;
GtkWidget *button;
ENTER(" ");
builder = gtk_builder_new();
gnc_builder_add_from_file (builder, "dialog-find-account.glade", "list-store");
gnc_builder_add_from_file (builder, "dialog-find-account.glade", "find_account_dialog");
gnc_builder_add_from_file (builder, "dialog-find-account.glade", "find_account_window");
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "find_account_dialog"));
facc_dialog->dialog = dialog;
window = GTK_WIDGET(gtk_builder_get_object (builder, "find_account_window"));
facc_dialog->window = window;
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncFindAccountDialog");
gnc_widget_set_style_context (GTK_WIDGET(window), "GncFindAccountDialog");
facc_dialog->session = gnc_get_current_session();
facc_dialog->parent = parent;
/* parent */
if (parent != NULL)
{
facc_dialog->parent = parent;
gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(parent));
}
else
facc_dialog->parent = NULL;
gtk_window_set_title (GTK_WINDOW(facc_dialog->window), _("Find Account"));
/* Connect the radio buttons...*/
facc_dialog->radio_root = GTK_WIDGET(gtk_builder_get_object (builder, "radio-root"));
@ -292,6 +272,13 @@ gnc_find_account_dialog_create (GtkWidget *parent, FindAccountDialog *facc_dialo
g_signal_connect (facc_dialog->filter_button, "clicked",
G_CALLBACK(filter_button_cb), (gpointer)facc_dialog);
button = GTK_WIDGET(gtk_builder_get_object (builder, "jumpto_button"));
g_signal_connect(button, "clicked", G_CALLBACK(gnc_find_account_dialog_jump_button_cb), facc_dialog);
button = GTK_WIDGET(gtk_builder_get_object (builder, "check_button"));
g_signal_connect(button, "clicked", G_CALLBACK(gnc_find_account_dialog_check_button_cb), facc_dialog);
button = GTK_WIDGET(gtk_builder_get_object (builder, "close_button"));
g_signal_connect(button, "clicked", G_CALLBACK(gnc_find_account_dialog_close_button_cb), facc_dialog);
facc_dialog->view = GTK_WIDGET(gtk_builder_get_object (builder, "treeview"));
g_signal_connect (facc_dialog->view, "row-activated",
G_CALLBACK(row_double_clicked), (gpointer)facc_dialog);
@ -299,9 +286,6 @@ gnc_find_account_dialog_create (GtkWidget *parent, FindAccountDialog *facc_dialo
// Set grid lines option to preference
gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(facc_dialog->view), gnc_tree_view_get_grid_lines_pref ());
/* default to 'close' button */
gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(facc_dialog->view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
@ -350,11 +334,17 @@ gnc_find_account_dialog_create (GtkWidget *parent, FindAccountDialog *facc_dialo
gtk_tree_view_column_set_attributes (tree_column, cr, "icon-name", BAL_ZERO, NULL);
gtk_cell_renderer_set_alignment (cr, 0.5, 0.5);
g_signal_connect (facc_dialog->window, "destroy",
G_CALLBACK(gnc_find_account_dialog_window_destroy_cb), facc_dialog);
gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, facc_dialog);
g_object_unref (G_OBJECT(builder));
gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(facc_dialog->dialog));
gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(facc_dialog->window));
gtk_widget_show_all (GTK_WIDGET(facc_dialog->window));
if (facc_dialog->account != NULL)
{
@ -368,7 +358,6 @@ gnc_find_account_dialog_create (GtkWidget *parent, FindAccountDialog *facc_dialo
g_free (sub_label);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(facc_dialog->radio_subroot), TRUE);
gtk_widget_show_all (facc_dialog->radio_hbox);
}
else
gtk_widget_hide (facc_dialog->radio_hbox);
@ -377,7 +366,6 @@ gnc_find_account_dialog_create (GtkWidget *parent, FindAccountDialog *facc_dialo
gtk_entry_set_text (GTK_ENTRY(facc_dialog->filter_text_entry), "");
get_account_info (facc_dialog);
LEAVE(" ");
}
@ -387,8 +375,8 @@ close_handler (gpointer user_data)
FindAccountDialog *facc_dialog = user_data;
ENTER(" ");
gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(facc_dialog->dialog));
gtk_widget_destroy (GTK_WIDGET(facc_dialog->dialog));
gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(facc_dialog->window));
gtk_widget_destroy (GTK_WIDGET(facc_dialog->window));
LEAVE(" ");
}
@ -411,7 +399,7 @@ show_handler (const char *klass, gint component_id,
LEAVE("No data strucure");
return(FALSE);
}
gtk_window_present (GTK_WINDOW(facc_dialog->dialog));
gtk_window_present (GTK_WINDOW(facc_dialog->window));
LEAVE(" ");
return(TRUE);
}
@ -447,7 +435,5 @@ gnc_find_account_dialog (GtkWidget *parent, Account *account)
facc_dialog);
gnc_gui_component_set_session (component_id, facc_dialog->session);
gtk_widget_show (facc_dialog->dialog);
LEAVE(" ");
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.20.4 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkListStore" id="list-store">
@ -18,21 +18,30 @@
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="find_account_dialog">
<object class="GtkWindow" id="find_account_window">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Find Account Dialog</property>
<property name="default_width">600</property>
<property name="default_height">400</property>
<property name="type_hint">dialog</property>
<signal name="destroy" handler="gnc_find_account_dialog_window_destroy_cb" swapped="no"/>
<signal name="response" handler="gnc_find_account_dialog_response_cb" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox2">
<child>
<object class="GtkBox" id="dialog-vbox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">6</property>
<property name="label" translatable="yes">&lt;b&gt;Search the Account List&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButtonBox" id="buttonbox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
@ -89,20 +98,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">6</property>
<property name="label" translatable="yes">&lt;b&gt;Search the Account List&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="hbox-radio">
<property name="visible">True</property>
@ -130,7 +125,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">radio-root</property>
</object>
@ -148,7 +142,7 @@
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<object class="GtkScrolledWindow" id="scrollwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
@ -156,15 +150,16 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">list-store</property>
<property name="search_column">0</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
<object class="GtkTreeSelection"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="account_full_name">
<property name="resizable">True</property>
<property name="title" translatable="yes">Account Full Name</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<object class="GtkCellRendererText" id="cellrenderertext"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
@ -194,11 +189,11 @@
</packing>
</child>
<child>
<object class="GtkBox" id="hbox2">
<object class="GtkBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label3">
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
@ -237,7 +232,7 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
@ -255,7 +250,7 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Select a row and then press 'jump to' to jump to account in the Account Tree,
@ -273,10 +268,8 @@ if account should not be shown, this will be temporarily overridden.</property>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-8">check_button</action-widget>
<action-widget response="-10">jumpto_button</action-widget>
<action-widget response="-6">close_button</action-widget>
</action-widgets>
<child type="titlebar">
<placeholder/>
</child>
</object>
</interface>