Remove parentless dialogs
All dialogs that don’t need a parent are opened for the active window. Fixes #51
This commit is contained in:
parent
7ed0e4d09b
commit
fbcf16cb52
36
src/ag-app.c
36
src/ag-app.c
@ -78,10 +78,10 @@ static void
|
|||||||
preferences_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
preferences_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
||||||
{
|
{
|
||||||
AgApp *app = AG_APP(user_data);
|
AgApp *app = AG_APP(user_data);
|
||||||
GtkWindow *window;
|
|
||||||
|
|
||||||
window = ag_app_peek_first_window(app);
|
ag_preferences_show_dialog(
|
||||||
ag_preferences_show_dialog(window);
|
gtk_application_get_active_window(GTK_APPLICATION(app))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -97,10 +97,12 @@ about_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
const gchar *translator_credits = _("translator_credits");
|
const gchar *translator_credits = _("translator_credits");
|
||||||
|
AgApp *app = AG_APP(user_data);
|
||||||
|
|
||||||
/* i18n: Please don't translate "Astrognome" (it's marked as translatable
|
/* i18n: Please don't translate "Astrognome" (it's marked as translatable
|
||||||
* for transliteration only */
|
* for transliteration only */
|
||||||
gtk_show_about_dialog(NULL,
|
gtk_show_about_dialog(
|
||||||
|
gtk_application_get_active_window(GTK_APPLICATION(app)),
|
||||||
"name", _("Astrognome"),
|
"name", _("Astrognome"),
|
||||||
"version", PACKAGE_VERSION,
|
"version", PACKAGE_VERSION,
|
||||||
"comments", _("Astrologers' software for GNOME"),
|
"comments", _("Astrologers' software for GNOME"),
|
||||||
@ -116,7 +118,8 @@ about_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
|||||||
"website-label", _("Astrognome Website"),
|
"website-label", _("Astrognome Website"),
|
||||||
"license-type", GTK_LICENSE_GPL_3_0,
|
"license-type", GTK_LICENSE_GPL_3_0,
|
||||||
"logo-icon-name", PACKAGE_TARNAME,
|
"logo-icon-name", PACKAGE_TARNAME,
|
||||||
NULL);
|
NULL
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -158,7 +161,7 @@ ag_app_import_file(AgApp *app, GFile *file, AgAppImportType type)
|
|||||||
|
|
||||||
if (chart == NULL) {
|
if (chart == NULL) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
NULL,
|
gtk_application_get_active_window(GTK_APPLICATION(app)),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
"Error while loading: %s",
|
"Error while loading: %s",
|
||||||
err->message
|
err->message
|
||||||
@ -183,6 +186,7 @@ ag_app_import_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
|||||||
GSList *filenames = NULL;
|
GSList *filenames = NULL;
|
||||||
const gchar *target_type = g_variant_get_string(parameter, NULL);
|
const gchar *target_type = g_variant_get_string(parameter, NULL);
|
||||||
AgAppImportType type = AG_APP_IMPORT_NONE;
|
AgAppImportType type = AG_APP_IMPORT_NONE;
|
||||||
|
AgApp *app = AG_APP(user_data);
|
||||||
|
|
||||||
if (strncmp("agc", target_type, 3) == 0) {
|
if (strncmp("agc", target_type, 3) == 0) {
|
||||||
type = AG_APP_IMPORT_AGC;
|
type = AG_APP_IMPORT_AGC;
|
||||||
@ -194,12 +198,14 @@ ag_app_import_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
|||||||
g_error("Unknown import type!");
|
g_error("Unknown import type!");
|
||||||
}
|
}
|
||||||
|
|
||||||
fs = gtk_file_chooser_dialog_new(_("Select charts"),
|
fs = gtk_file_chooser_dialog_new(
|
||||||
NULL,
|
_("Select charts"),
|
||||||
|
gtk_application_get_active_window(GTK_APPLICATION(app)),
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||||
_("_Import"), GTK_RESPONSE_ACCEPT,
|
_("_Import"), GTK_RESPONSE_ACCEPT,
|
||||||
NULL);
|
NULL
|
||||||
|
);
|
||||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fs), filter_all);
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fs), filter_all);
|
||||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fs), filter);
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fs), filter);
|
||||||
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fs), filter);
|
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fs), filter);
|
||||||
@ -263,7 +269,7 @@ show_help(const gchar *topic, GtkWindow *parent)
|
|||||||
|
|
||||||
if (!gtk_show_uri(screen, uri, gtk_get_current_event_time(), &err)) {
|
if (!gtk_show_uri(screen, uri, gtk_get_current_event_time(), &err)) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(parent),
|
GTK_WINDOW(parent),
|
||||||
GTK_MESSAGE_WARNING,
|
GTK_MESSAGE_WARNING,
|
||||||
"Unable to display help: %s",
|
"Unable to display help: %s",
|
||||||
err->message
|
err->message
|
||||||
@ -462,8 +468,8 @@ ag_app_class_init(AgAppClass *klass)
|
|||||||
application_class->open = ag_app_import;
|
application_class->open = ag_app_import;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
GtkResponseType
|
||||||
ag_app_buttoned_dialog(GtkWidget *window,
|
ag_app_buttoned_dialog(GtkWindow *window,
|
||||||
GtkMessageType message_type,
|
GtkMessageType message_type,
|
||||||
const gchar *message,
|
const gchar *message,
|
||||||
const gchar *first_button_text,
|
const gchar *first_button_text,
|
||||||
@ -475,9 +481,7 @@ ag_app_buttoned_dialog(GtkWidget *window,
|
|||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWindow *parent = NULL;
|
GtkWindow *parent = NULL;
|
||||||
|
|
||||||
if (window) {
|
g_return_val_if_fail(GTK_IS_WINDOW(window), GTK_RESPONSE_NONE);
|
||||||
parent = GTK_WINDOW(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new(
|
dialog = gtk_message_dialog_new(
|
||||||
parent,
|
parent,
|
||||||
@ -510,7 +514,7 @@ ag_app_buttoned_dialog(GtkWidget *window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ag_app_message_dialog(GtkWidget *window,
|
ag_app_message_dialog(GtkWindow *window,
|
||||||
GtkMessageType message_type,
|
GtkMessageType message_type,
|
||||||
gchar *fmt, ...)
|
gchar *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -53,12 +53,12 @@ void ag_app_run_action(AgApp *app,
|
|||||||
gboolean is_remote,
|
gboolean is_remote,
|
||||||
const AstrognomeOptions *options);
|
const AstrognomeOptions *options);
|
||||||
|
|
||||||
gint ag_app_buttoned_dialog(GtkWidget *window,
|
gint ag_app_buttoned_dialog(GtkWindow *window,
|
||||||
GtkMessageType message_type,
|
GtkMessageType message_type,
|
||||||
const gchar *message,
|
const gchar *message,
|
||||||
const gchar *first_button_text, ...);
|
const gchar *first_button_text, ...);
|
||||||
|
|
||||||
void ag_app_message_dialog(GtkWidget *window,
|
void ag_app_message_dialog(GtkWindow *window,
|
||||||
GtkMessageType message_type,
|
GtkMessageType message_type,
|
||||||
gchar *fmt, ...);
|
gchar *fmt, ...);
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ ag_window_redraw_chart(AgWindow *window)
|
|||||||
|
|
||||||
if (svg_content == NULL) {
|
if (svg_content == NULL) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_WARNING,
|
GTK_MESSAGE_WARNING,
|
||||||
"Unable to draw chart: %s",
|
"Unable to draw chart: %s",
|
||||||
err->message
|
err->message
|
||||||
@ -741,7 +741,7 @@ ag_window_export_svg(AgWindow *window, GError **err)
|
|||||||
// We should never enter here, but who knows...
|
// We should never enter here, but who knows...
|
||||||
if (priv->chart == NULL) {
|
if (priv->chart == NULL) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
_("Chart cannot be calculated.")
|
_("Chart cannot be calculated.")
|
||||||
);
|
);
|
||||||
@ -758,7 +758,7 @@ ag_window_export_svg(AgWindow *window, GError **err)
|
|||||||
|
|
||||||
if ((name == NULL) || (*name == 0)) {
|
if ((name == NULL) || (*name == 0)) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
_("You must enter a name before saving a chart.")
|
_("You must enter a name before saving a chart.")
|
||||||
);
|
);
|
||||||
@ -809,7 +809,7 @@ ag_window_export_svg_action(GSimpleAction *action,
|
|||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
"%s",
|
"%s",
|
||||||
err->message
|
err->message
|
||||||
@ -831,7 +831,7 @@ ag_window_export(AgWindow *window, GError **err)
|
|||||||
// We should never enter here, but who knows...
|
// We should never enter here, but who knows...
|
||||||
if (priv->chart == NULL) {
|
if (priv->chart == NULL) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
_("Chart cannot be calculated.")
|
_("Chart cannot be calculated.")
|
||||||
);
|
);
|
||||||
@ -848,7 +848,7 @@ ag_window_export(AgWindow *window, GError **err)
|
|||||||
|
|
||||||
if ((name == NULL) || (*name == 0)) {
|
if ((name == NULL) || (*name == 0)) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
_("You must enter a name before saving a chart.")
|
_("You must enter a name before saving a chart.")
|
||||||
);
|
);
|
||||||
@ -900,7 +900,7 @@ ag_window_export_action(GSimpleAction *action,
|
|||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
"%s", err->message
|
"%s", err->message
|
||||||
);
|
);
|
||||||
@ -934,7 +934,7 @@ ag_window_can_close(AgWindow *window, gboolean display_dialog)
|
|||||||
gint response;
|
gint response;
|
||||||
|
|
||||||
response = ag_app_buttoned_dialog(
|
response = ag_app_buttoned_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_QUESTION,
|
GTK_MESSAGE_QUESTION,
|
||||||
_("Chart is not saved. Do you want to save it?"),
|
_("Chart is not saved. Do you want to save it?"),
|
||||||
_("Save and close"), GTK_RESPONSE_YES,
|
_("Save and close"), GTK_RESPONSE_YES,
|
||||||
@ -947,7 +947,7 @@ ag_window_can_close(AgWindow *window, gboolean display_dialog)
|
|||||||
case GTK_RESPONSE_YES:
|
case GTK_RESPONSE_YES:
|
||||||
if (!ag_db_save_chart(db, save_data, &err)) {
|
if (!ag_db_save_chart(db, save_data, &err)) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
"Unable to save chart: %s",
|
"Unable to save chart: %s",
|
||||||
err->message
|
err->message
|
||||||
@ -1001,7 +1001,7 @@ ag_window_save_action(GSimpleAction *action,
|
|||||||
|
|
||||||
if (!ag_db_save_chart(db, save_data, &err)) {
|
if (!ag_db_save_chart(db, save_data, &err)) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
_("Unable to save: %s"),
|
_("Unable to save: %s"),
|
||||||
err->message
|
err->message
|
||||||
@ -1160,7 +1160,7 @@ ag_window_new_chart_action(GSimpleAction *action,
|
|||||||
|
|
||||||
if (priv->chart) {
|
if (priv->chart) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
"This window already has a chart. " \
|
"This window already has a chart. " \
|
||||||
"This should not happen, " \
|
"This should not happen, " \
|
||||||
@ -1282,7 +1282,7 @@ ag_window_delete_action(GSimpleAction *action,
|
|||||||
|
|
||||||
if (!ag_db_delete_chart(db, id, &err)) {
|
if (!ag_db_delete_chart(db, id, &err)) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
"Unable to delete chart: %s",
|
"Unable to delete chart: %s",
|
||||||
(err && err->message)
|
(err && err->message)
|
||||||
@ -1417,7 +1417,7 @@ ag_window_list_item_activated_cb(GdMainView *view,
|
|||||||
|
|
||||||
if (priv->saved_data != NULL) {
|
if (priv->saved_data != NULL) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
"Window chart is not saved. " \
|
"Window chart is not saved. " \
|
||||||
"This is a bug, it should not happen here. " \
|
"This is a bug, it should not happen here. " \
|
||||||
@ -1436,7 +1436,7 @@ ag_window_list_item_activated_cb(GdMainView *view,
|
|||||||
row_id,
|
row_id,
|
||||||
&err)) == NULL) {
|
&err)) == NULL) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
"Could not open chart."
|
"Could not open chart."
|
||||||
);
|
);
|
||||||
@ -1453,7 +1453,7 @@ ag_window_list_item_activated_cb(GdMainView *view,
|
|||||||
&err
|
&err
|
||||||
)) == NULL) {
|
)) == NULL) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
GTK_WIDGET(window),
|
GTK_WINDOW(window),
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
"Error: %s",
|
"Error: %s",
|
||||||
err->message
|
err->message
|
||||||
|
Loading…
Reference in New Issue
Block a user