Merge pull request #71 from gergelypolonkai/bug-51

Remove parentless dialogs
This commit is contained in:
Gergely Polonkai 2014-09-02 09:43:01 +02:00
commit af22424f5e
3 changed files with 55 additions and 51 deletions

View File

@ -78,10 +78,10 @@ static void
preferences_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
AgApp *app = AG_APP(user_data);
GtkWindow *window;
window = ag_app_peek_first_window(app);
ag_preferences_show_dialog(window);
ag_preferences_show_dialog(
gtk_application_get_active_window(GTK_APPLICATION(app))
);
}
static void
@ -97,10 +97,12 @@ about_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
NULL
};
const gchar *translator_credits = _("translator_credits");
AgApp *app = AG_APP(user_data);
/* i18n: Please don't translate "Astrognome" (it's marked as translatable
* for transliteration only */
gtk_show_about_dialog(NULL,
gtk_show_about_dialog(
gtk_application_get_active_window(GTK_APPLICATION(app)),
"name", _("Astrognome"),
"version", PACKAGE_VERSION,
"comments", _("Astrologers' software for GNOME"),
@ -116,7 +118,8 @@ about_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
"website-label", _("Astrognome Website"),
"license-type", GTK_LICENSE_GPL_3_0,
"logo-icon-name", PACKAGE_TARNAME,
NULL);
NULL
);
}
static void
@ -158,7 +161,7 @@ ag_app_import_file(AgApp *app, GFile *file, AgAppImportType type)
if (chart == NULL) {
ag_app_message_dialog(
NULL,
gtk_application_get_active_window(GTK_APPLICATION(app)),
GTK_MESSAGE_ERROR,
"Error while loading: %s",
err->message
@ -183,6 +186,7 @@ ag_app_import_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
GSList *filenames = NULL;
const gchar *target_type = g_variant_get_string(parameter, NULL);
AgAppImportType type = AG_APP_IMPORT_NONE;
AgApp *app = AG_APP(user_data);
if (strncmp("agc", target_type, 3) == 0) {
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!");
}
fs = gtk_file_chooser_dialog_new(_("Select charts"),
NULL,
fs = gtk_file_chooser_dialog_new(
_("Select charts"),
gtk_application_get_active_window(GTK_APPLICATION(app)),
GTK_FILE_CHOOSER_ACTION_OPEN,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_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);
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)) {
ag_app_message_dialog(
GTK_WIDGET(parent),
GTK_WINDOW(parent),
GTK_MESSAGE_WARNING,
"Unable to display help: %s",
err->message
@ -462,8 +468,8 @@ ag_app_class_init(AgAppClass *klass)
application_class->open = ag_app_import;
}
gint
ag_app_buttoned_dialog(GtkWidget *window,
GtkResponseType
ag_app_buttoned_dialog(GtkWindow *window,
GtkMessageType message_type,
const gchar *message,
const gchar *first_button_text,
@ -475,9 +481,7 @@ ag_app_buttoned_dialog(GtkWidget *window,
GtkWidget *dialog;
GtkWindow *parent = NULL;
if (window) {
parent = GTK_WINDOW(window);
}
g_return_val_if_fail(GTK_IS_WINDOW(window), GTK_RESPONSE_NONE);
dialog = gtk_message_dialog_new(
parent,
@ -510,7 +514,7 @@ ag_app_buttoned_dialog(GtkWidget *window,
}
void
ag_app_message_dialog(GtkWidget *window,
ag_app_message_dialog(GtkWindow *window,
GtkMessageType message_type,
gchar *fmt, ...)
{

View File

@ -53,12 +53,12 @@ void ag_app_run_action(AgApp *app,
gboolean is_remote,
const AstrognomeOptions *options);
gint ag_app_buttoned_dialog(GtkWidget *window,
gint ag_app_buttoned_dialog(GtkWindow *window,
GtkMessageType message_type,
const gchar *message,
const gchar *first_button_text, ...);
void ag_app_message_dialog(GtkWidget *window,
void ag_app_message_dialog(GtkWindow *window,
GtkMessageType message_type,
gchar *fmt, ...);

View File

@ -422,7 +422,7 @@ ag_window_redraw_chart(AgWindow *window)
if (svg_content == NULL) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_WARNING,
"Unable to draw chart: %s",
err->message
@ -741,7 +741,7 @@ ag_window_export_svg(AgWindow *window, GError **err)
// We should never enter here, but who knows...
if (priv->chart == NULL) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
_("Chart cannot be calculated.")
);
@ -758,7 +758,7 @@ ag_window_export_svg(AgWindow *window, GError **err)
if ((name == NULL) || (*name == 0)) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
_("You must enter a name before saving a chart.")
);
@ -809,7 +809,7 @@ ag_window_export_svg_action(GSimpleAction *action,
if (err) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
"%s",
err->message
@ -831,7 +831,7 @@ ag_window_export(AgWindow *window, GError **err)
// We should never enter here, but who knows...
if (priv->chart == NULL) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
_("Chart cannot be calculated.")
);
@ -848,7 +848,7 @@ ag_window_export(AgWindow *window, GError **err)
if ((name == NULL) || (*name == 0)) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
_("You must enter a name before saving a chart.")
);
@ -900,7 +900,7 @@ ag_window_export_action(GSimpleAction *action,
if (err) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
"%s", err->message
);
@ -934,7 +934,7 @@ ag_window_can_close(AgWindow *window, gboolean display_dialog)
gint response;
response = ag_app_buttoned_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_QUESTION,
_("Chart is not saved. Do you want to save it?"),
_("Save and close"), GTK_RESPONSE_YES,
@ -947,7 +947,7 @@ ag_window_can_close(AgWindow *window, gboolean display_dialog)
case GTK_RESPONSE_YES:
if (!ag_db_save_chart(db, save_data, &err)) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
"Unable to save chart: %s",
err->message
@ -1001,7 +1001,7 @@ ag_window_save_action(GSimpleAction *action,
if (!ag_db_save_chart(db, save_data, &err)) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
_("Unable to save: %s"),
err->message
@ -1160,7 +1160,7 @@ ag_window_new_chart_action(GSimpleAction *action,
if (priv->chart) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
"This window already has a chart. " \
"This should not happen, " \
@ -1282,7 +1282,7 @@ ag_window_delete_action(GSimpleAction *action,
if (!ag_db_delete_chart(db, id, &err)) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
"Unable to delete chart: %s",
(err && err->message)
@ -1417,7 +1417,7 @@ ag_window_list_item_activated_cb(GdMainView *view,
if (priv->saved_data != NULL) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
"Window chart is not saved. " \
"This is a bug, it should not happen here. " \
@ -1436,7 +1436,7 @@ ag_window_list_item_activated_cb(GdMainView *view,
row_id,
&err)) == NULL) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
"Could not open chart."
);
@ -1453,7 +1453,7 @@ ag_window_list_item_activated_cb(GdMainView *view,
&err
)) == NULL) {
ag_app_message_dialog(
GTK_WIDGET(window),
GTK_WINDOW(window),
GTK_MESSAGE_ERROR,
"Error: %s",
err->message