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_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_remove_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
{
GtkWidget * dialog;
GtkWidget * window;
QofSession *session;
QofBook *book;
GNCPriceDB *price_db;
@@ -96,10 +95,10 @@ gnc_prices_dialog_window_destroy_cb (GtkWidget *object, gpointer data)
ENTER(" ");
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);
pdb_dialog->dialog = NULL;
gtk_widget_destroy(pdb_dialog->window);
pdb_dialog->window = NULL;
}
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
gnc_prices_dialog_edit_clicked (GtkWidget *widget, gpointer data)
{
@@ -149,7 +137,7 @@ gnc_prices_dialog_edit_clicked (GtkWidget *widget, gpointer data)
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);
g_list_free(price_list);
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?",
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_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
@@ -378,7 +366,6 @@ get_fiscal_end_date (void)
PINFO("Fiscal end date is %s", datebuff);
return time64_to_gdate (end);
}
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_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
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;
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);
LEAVE(" ");
}
@@ -562,7 +549,7 @@ gnc_prices_dialog_get_quotes_clicked (GtkWidget *widget, gpointer data)
return;
}
scm_window = SWIG_NewPointerObj(pdb_dialog->dialog,
scm_window = SWIG_NewPointerObj(pdb_dialog->window,
SWIG_TypeQuery("_p_GtkWindow"), 0);
gnc_set_busy_cursor (NULL, TRUE);
@@ -670,32 +657,25 @@ row_activated_cb (GtkTreeView *view, GtkTreePath *path,
static void
gnc_prices_dialog_create (GtkWidget * parent, PricesDialog *pdb_dialog)
{
GtkWidget *dialog, *scrolled_window;
GtkWidget *window, *scrolled_window;
GtkBuilder *builder;
GtkTreeView *view;
GtkTreeSelection *selection;
ENTER(" ");
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"));
pdb_dialog->dialog = dialog;
window = GTK_WIDGET(gtk_builder_get_object (builder, "prices_window"));
pdb_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), "GncPriceEditDialog");
gnc_widget_set_style_context (GTK_WIDGET(window), "GncPriceEditDialog");
pdb_dialog->session = gnc_get_current_session();
pdb_dialog->book = qof_session_get_book(pdb_dialog->session);
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 */
scrolled_window = GTK_WIDGET(gtk_builder_get_object (builder, "price_list_window"));
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"));
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));
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(" ");
}
@@ -750,9 +737,9 @@ close_handler (gpointer user_data)
PricesDialog *pdb_dialog = user_data;
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(" ");
}
@@ -778,7 +765,7 @@ show_handler (const char *klass, gint component_id,
return(FALSE);
}
gtk_window_present (GTK_WINDOW(pdb_dialog->dialog));
gtk_window_present (GTK_WINDOW(pdb_dialog->window));
LEAVE(" ");
return(TRUE);
}
@@ -815,6 +802,6 @@ gnc_prices_dialog (GtkWidget * parent)
gtk_widget_grab_focus (GTK_WIDGET(pdb_dialog->price_tree));
gtk_widget_show (pdb_dialog->dialog);
gtk_widget_show (pdb_dialog->window);
LEAVE(" ");
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkListStore" id="liststore1">
@@ -54,6 +54,9 @@
<property name="modal">True</property>
<property name="type_hint">dialog</property>
<signal name="response" handler="pedit_dialog_response_cb" swapped="no"/>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox18">
<property name="visible">True</property>
@@ -366,6 +369,9 @@
<property name="title" translatable="yes">Remove Old Prices</property>
<property name="default_height">500</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox2">
<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-widgets>
</object>
<object class="GtkDialog" id="prices_dialog">
<object class="GtkWindow" id="prices_window">
<property name="can_focus">False</property>
<property name="border_width">6</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="type_hint">normal</property>
<signal name="close" handler="gnc_prices_dialog_close_cb" after="yes" swapped="no"/>
<signal name="destroy" handler="gnc_prices_dialog_window_destroy_cb" swapped="no"/>
<signal name="response" handler="gnc_prices_dialog_response" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox" id="vbox121">
<property name="visible">True</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>
<placeholder/>
</child>
<child>
<object class="GtkBox" id="hbox118">
<object class="GtkBox" id="vbox11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkScrolledWindow" id="price_list_window">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">3</property>
<property name="shadow_type">in</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
@@ -844,29 +816,19 @@ These prices were added so that there's always a "nearest in time" price for eve
</packing>
</child>
<child>
<object class="GtkButtonBox" id="vbuttonbox5">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">12</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButtonBox" id="vbuttonbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="orientation">vertical</property>
<property name="layout_style">spread</property>
<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">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<property name="spacing">12</property>
<property name="layout_style">start</property>
<child>
<object class="GtkButton" id="add_button">
<property name="label" translatable="yes">_Add</property>
@@ -937,6 +899,55 @@ These prices were added so that there's always a "nearest in time" price for eve
<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>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButtonBox" id="vbuttonbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">end</property>
<property name="border_width">5</property>
<property name="orientation">vertical</property>
<property name="layout_style">start</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="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>
<packing>
<property name="expand">False</property>
@@ -946,15 +957,19 @@ These prices were added so that there's always a "nearest in time" price for eve
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-7">close_button</action-widget>
</action-widgets>
</object>
</interface>