Change the Prices dialogue to a GtkWindow.

This removes the need for setting the transient parent which allows the
dialogue to be placed behind the main application.
This commit is contained in:
Robert Fewell
2019-04-23 13:46:06 +01:00
parent 93c8535ea9
commit ede281e2a8
2 changed files with 164 additions and 162 deletions

View File

@@ -62,7 +62,6 @@ static QofLogModule log_module = GNC_MOD_GUI;
void gnc_prices_dialog_window_destroy_cb (GtkWidget *object, gpointer data); void gnc_prices_dialog_window_destroy_cb (GtkWidget *object, gpointer data);
void gnc_prices_dialog_close_cb (GtkDialog *dialog, gpointer data); void gnc_prices_dialog_close_cb (GtkDialog *dialog, gpointer data);
void gnc_prices_dialog_response (GtkDialog *dialog, gint response_id, gpointer data);
void gnc_prices_dialog_edit_clicked (GtkWidget *widget, gpointer data); void gnc_prices_dialog_edit_clicked (GtkWidget *widget, gpointer data);
void gnc_prices_dialog_remove_clicked (GtkWidget *widget, gpointer data); void gnc_prices_dialog_remove_clicked (GtkWidget *widget, gpointer data);
void gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data); void gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data);
@@ -72,7 +71,7 @@ void gnc_prices_dialog_get_quotes_clicked (GtkWidget *widget, gpointer data);
typedef struct typedef struct
{ {
GtkWidget * dialog; GtkWidget * window;
QofSession *session; QofSession *session;
QofBook *book; QofBook *book;
GNCPriceDB *price_db; GNCPriceDB *price_db;
@@ -96,10 +95,10 @@ gnc_prices_dialog_window_destroy_cb (GtkWidget *object, gpointer data)
ENTER(" "); ENTER(" ");
gnc_unregister_gui_component_by_data (DIALOG_PRICE_DB_CM_CLASS, pdb_dialog); gnc_unregister_gui_component_by_data (DIALOG_PRICE_DB_CM_CLASS, pdb_dialog);
if (pdb_dialog->dialog) if (pdb_dialog->window)
{ {
gtk_widget_destroy(pdb_dialog->dialog); gtk_widget_destroy(pdb_dialog->window);
pdb_dialog->dialog = NULL; pdb_dialog->window = NULL;
} }
g_free (pdb_dialog); g_free (pdb_dialog);
@@ -118,17 +117,6 @@ gnc_prices_dialog_close_cb (GtkDialog *dialog, gpointer data)
} }
void
gnc_prices_dialog_response (GtkDialog *dialog, gint response_id, gpointer data)
{
PricesDialog *pdb_dialog = data;
ENTER(" ");
gnc_close_gui_component_by_data (DIALOG_PRICE_DB_CM_CLASS, pdb_dialog);
LEAVE(" ");
}
void void
gnc_prices_dialog_edit_clicked (GtkWidget *widget, gpointer data) gnc_prices_dialog_edit_clicked (GtkWidget *widget, gpointer data)
{ {
@@ -149,7 +137,7 @@ gnc_prices_dialog_edit_clicked (GtkWidget *widget, gpointer data)
return; return;
} }
gnc_price_edit_dialog (pdb_dialog->dialog, pdb_dialog->session, gnc_price_edit_dialog (pdb_dialog->window, pdb_dialog->session,
price_list->data, GNC_PRICE_EDIT); price_list->data, GNC_PRICE_EDIT);
g_list_free(price_list); g_list_free(price_list);
LEAVE(" "); LEAVE(" ");
@@ -190,7 +178,7 @@ gnc_prices_dialog_remove_clicked (GtkWidget *widget, gpointer data)
"Are you sure you want to delete the %d selected prices?", "Are you sure you want to delete the %d selected prices?",
length), length),
length); length);
dialog = gtk_message_dialog_new(GTK_WINDOW(pdb_dialog->dialog), dialog = gtk_message_dialog_new(GTK_WINDOW(pdb_dialog->window),
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE, GTK_BUTTONS_NONE,
@@ -378,7 +366,6 @@ get_fiscal_end_date (void)
PINFO("Fiscal end date is %s", datebuff); PINFO("Fiscal end date is %s", datebuff);
return time64_to_gdate (end); return time64_to_gdate (end);
} }
void void
@@ -435,7 +422,7 @@ gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data)
gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, pdb_dialog); gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, pdb_dialog);
gtk_window_set_transient_for (GTK_WINDOW (pdb_dialog->remove_dialog), GTK_WINDOW (pdb_dialog->dialog)); gtk_window_set_transient_for (GTK_WINDOW (pdb_dialog->remove_dialog), GTK_WINDOW (pdb_dialog->window));
pdb_dialog->remove_source = 9; // FQ and Commodities highlighted pdb_dialog->remove_source = 9; // FQ and Commodities highlighted
button = GTK_WIDGET(gtk_builder_get_object (builder, "checkbutton_fq")); button = GTK_WIDGET(gtk_builder_get_object (builder, "checkbutton_fq"));
@@ -533,7 +520,7 @@ gnc_prices_dialog_add_clicked (GtkWidget *widget, gpointer data)
price = price_list->data; price = price_list->data;
g_list_free(price_list); g_list_free(price_list);
} }
gnc_price_edit_dialog (pdb_dialog->dialog, pdb_dialog->session, gnc_price_edit_dialog (pdb_dialog->window, pdb_dialog->session,
price, GNC_PRICE_NEW); price, GNC_PRICE_NEW);
LEAVE(" "); LEAVE(" ");
} }
@@ -562,7 +549,7 @@ gnc_prices_dialog_get_quotes_clicked (GtkWidget *widget, gpointer data)
return; return;
} }
scm_window = SWIG_NewPointerObj(pdb_dialog->dialog, scm_window = SWIG_NewPointerObj(pdb_dialog->window,
SWIG_TypeQuery("_p_GtkWindow"), 0); SWIG_TypeQuery("_p_GtkWindow"), 0);
gnc_set_busy_cursor (NULL, TRUE); gnc_set_busy_cursor (NULL, TRUE);
@@ -670,32 +657,25 @@ row_activated_cb (GtkTreeView *view, GtkTreePath *path,
static void static void
gnc_prices_dialog_create (GtkWidget * parent, PricesDialog *pdb_dialog) gnc_prices_dialog_create (GtkWidget * parent, PricesDialog *pdb_dialog)
{ {
GtkWidget *dialog, *scrolled_window; GtkWidget *window, *scrolled_window;
GtkBuilder *builder; GtkBuilder *builder;
GtkTreeView *view; GtkTreeView *view;
GtkTreeSelection *selection; GtkTreeSelection *selection;
ENTER(" "); ENTER(" ");
builder = gtk_builder_new(); builder = gtk_builder_new();
gnc_builder_add_from_file (builder, "dialog-price.glade", "prices_dialog"); gnc_builder_add_from_file (builder, "dialog-price.glade", "prices_window");
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "prices_dialog")); window = GTK_WIDGET(gtk_builder_get_object (builder, "prices_window"));
pdb_dialog->dialog = dialog; pdb_dialog->window = window;
// Set the style context for this dialog so it can be easily manipulated with css // Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncPriceEditDialog"); gnc_widget_set_style_context (GTK_WIDGET(window), "GncPriceEditDialog");
pdb_dialog->session = gnc_get_current_session(); pdb_dialog->session = gnc_get_current_session();
pdb_dialog->book = qof_session_get_book(pdb_dialog->session); pdb_dialog->book = qof_session_get_book(pdb_dialog->session);
pdb_dialog->price_db = gnc_pricedb_get_db(pdb_dialog->book); pdb_dialog->price_db = gnc_pricedb_get_db(pdb_dialog->book);
/* parent */
if (parent != NULL)
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
/* default to 'close' button */
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
/* price tree */ /* price tree */
scrolled_window = GTK_WIDGET(gtk_builder_get_object (builder, "price_list_window")); scrolled_window = GTK_WIDGET(gtk_builder_get_object (builder, "price_list_window"));
view = gnc_tree_view_price_new(pdb_dialog->book, view = gnc_tree_view_price_new(pdb_dialog->book,
@@ -733,13 +713,20 @@ gnc_prices_dialog_create (GtkWidget * parent, PricesDialog *pdb_dialog)
button = GTK_WIDGET(gtk_builder_get_object (builder, "get_quotes_button")); button = GTK_WIDGET(gtk_builder_get_object (builder, "get_quotes_button"));
gtk_widget_set_sensitive(button, FALSE); gtk_widget_set_sensitive(button, FALSE);
} }
/* default to 'close' button */
button = GTK_WIDGET(gtk_builder_get_object (builder, "close_button"));
gtk_widget_grab_default (button);
gtk_widget_grab_focus (button);
} }
gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, pdb_dialog); g_signal_connect (pdb_dialog->window, "destroy",
G_CALLBACK(gnc_prices_dialog_window_destroy_cb), pdb_dialog);
gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, pdb_dialog);
g_object_unref(G_OBJECT(builder)); g_object_unref(G_OBJECT(builder));
gnc_restore_window_size(GNC_PREFS_GROUP, GTK_WINDOW(pdb_dialog->dialog), GTK_WINDOW (parent)); gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(pdb_dialog->window), GTK_WINDOW (parent));
LEAVE(" "); LEAVE(" ");
} }
@@ -750,9 +737,9 @@ close_handler (gpointer user_data)
PricesDialog *pdb_dialog = user_data; PricesDialog *pdb_dialog = user_data;
ENTER(" "); ENTER(" ");
gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(pdb_dialog->dialog)); gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(pdb_dialog->window));
gtk_widget_destroy (GTK_WIDGET (pdb_dialog->dialog)); gtk_widget_destroy (GTK_WIDGET (pdb_dialog->window));
LEAVE(" "); LEAVE(" ");
} }
@@ -778,7 +765,7 @@ show_handler (const char *klass, gint component_id,
return(FALSE); return(FALSE);
} }
gtk_window_present (GTK_WINDOW(pdb_dialog->dialog)); gtk_window_present (GTK_WINDOW(pdb_dialog->window));
LEAVE(" "); LEAVE(" ");
return(TRUE); return(TRUE);
} }
@@ -815,6 +802,6 @@ gnc_prices_dialog (GtkWidget * parent)
gtk_widget_grab_focus (GTK_WIDGET(pdb_dialog->price_tree)); gtk_widget_grab_focus (GTK_WIDGET(pdb_dialog->price_tree));
gtk_widget_show (pdb_dialog->dialog); gtk_widget_show (pdb_dialog->window);
LEAVE(" "); LEAVE(" ");
} }

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 --> <!-- Generated with glade 3.22.1 -->
<interface> <interface>
<requires lib="gtk+" version="3.10"/> <requires lib="gtk+" version="3.10"/>
<object class="GtkListStore" id="liststore1"> <object class="GtkListStore" id="liststore1">
@@ -54,6 +54,9 @@
<property name="modal">True</property> <property name="modal">True</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<signal name="response" handler="pedit_dialog_response_cb" swapped="no"/> <signal name="response" handler="pedit_dialog_response_cb" swapped="no"/>
<child>
<placeholder/>
</child>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox18"> <object class="GtkBox" id="dialog-vbox18">
<property name="visible">True</property> <property name="visible">True</property>
@@ -366,6 +369,9 @@
<property name="title" translatable="yes">Remove Old Prices</property> <property name="title" translatable="yes">Remove Old Prices</property>
<property name="default_height">500</property> <property name="default_height">500</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox2"> <object class="GtkBox" id="dialog-vbox2">
<property name="visible">True</property> <property name="visible">True</property>
@@ -778,64 +784,30 @@ These prices were added so that there's always a "nearest in time" price for eve
<action-widget response="-5">ok_button</action-widget> <action-widget response="-5">ok_button</action-widget>
</action-widgets> </action-widgets>
</object> </object>
<object class="GtkDialog" id="prices_dialog"> <object class="GtkWindow" id="prices_window">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Price Database</property> <property name="title" translatable="yes">Price Database</property>
<property name="default_width">400</property> <property name="default_width">800</property>
<property name="default_height">400</property> <property name="default_height">400</property>
<property name="type_hint">normal</property> <child>
<signal name="close" handler="gnc_prices_dialog_close_cb" after="yes" swapped="no"/> <placeholder/>
<signal name="destroy" handler="gnc_prices_dialog_window_destroy_cb" swapped="no"/> </child>
<signal name="response" handler="gnc_prices_dialog_response" swapped="no"/> <child>
<child internal-child="vbox"> <object class="GtkBox" id="vbox11">
<object class="GtkBox" id="vbox121">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="spacing">6</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="hbuttonbox4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="close_button">
<property name="label" translatable="yes">_Close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkBox" id="hbox118"> <object class="GtkBox" id="hbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child> <child>
<object class="GtkScrolledWindow" id="price_list_window"> <object class="GtkScrolledWindow" id="price_list_window">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="border_width">3</property> <property name="border_width">3</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child>
<placeholder/>
</child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
@@ -844,22 +816,106 @@ These prices were added so that there's always a "nearest in time" price for eve
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButtonBox" id="vbuttonbox5"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">5</property> <property name="margin_bottom">12</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="layout_style">spread</property>
<child> <child>
<object class="GtkButton" id="get_quotes_button"> <object class="GtkButtonBox" id="vbuttonbox1">
<property name="label" translatable="yes">_Get Quotes</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="can_default">True</property> <property name="border_width">5</property>
<property name="receives_default">False</property> <property name="orientation">vertical</property>
<property name="tooltip_text" translatable="yes">Get new online quotes for stock accounts.</property> <property name="spacing">12</property>
<property name="use_underline">True</property> <property name="layout_style">start</property>
<signal name="clicked" handler="gnc_prices_dialog_get_quotes_clicked" swapped="no"/> <child>
<object class="GtkButton" id="add_button">
<property name="label" translatable="yes">_Add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Add a new price.</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="gnc_prices_dialog_add_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_button">
<property name="label" translatable="yes">_Remove</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Remove the current price.</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="gnc_prices_dialog_remove_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="edit_button">
<property name="label" translatable="yes">_Edit</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Edit the current price.</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="gnc_prices_dialog_edit_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_old_button">
<property name="label" translatable="yes">Remove _Old</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Remove prices older than a user-entered date.</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="gnc_prices_dialog_remove_old_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="get_quotes_button">
<property name="label" translatable="yes">_Get Quotes</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Get new online quotes for stock accounts.</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="gnc_prices_dialog_get_quotes_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
@@ -868,93 +924,52 @@ These prices were added so that there's always a "nearest in time" price for eve
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="add_button"> <object class="GtkButtonBox" id="vbuttonbox2">
<property name="label" translatable="yes">_Add</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="can_default">True</property> <property name="valign">end</property>
<property name="receives_default">False</property> <property name="border_width">5</property>
<property name="tooltip_text" translatable="yes">Add a new price.</property> <property name="orientation">vertical</property>
<property name="use_underline">True</property> <property name="layout_style">start</property>
<signal name="clicked" handler="gnc_prices_dialog_add_clicked" swapped="no"/> <child>
<object class="GtkButton" id="close_button">
<property name="label" translatable="yes">_Close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="valign">start</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="gnc_prices_dialog_close_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_button">
<property name="label" translatable="yes">_Remove</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Remove the current price.</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="gnc_prices_dialog_remove_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkButton" id="edit_button">
<property name="label" translatable="yes">_Edit</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Edit the current price.</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="gnc_prices_dialog_edit_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_old_button">
<property name="label" translatable="yes">Remove _Old</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Remove prices older than a user-entered date.</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="gnc_prices_dialog_remove_old_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
</object> </object>
</child> </child>
<action-widgets>
<action-widget response="-7">close_button</action-widget>
</action-widgets>
</object> </object>
</interface> </interface>