aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-10-28 05:25:57 +0200
committerPřemysl Eric Janouch <p@janouch.name>2021-10-28 05:25:57 +0200
commit6cd6ddbd1c25b9b78aaa0b1690b0ca748e2da810 (patch)
tree908dc635465990b96ea3585efeb745d9be6a93b0 /src
parenta4a0dd2106bc183408441c20a17d5d1c53fa52b9 (diff)
downloadlogdiag-6cd6ddbd1c25b9b78aaa0b1690b0ca748e2da810.tar.gz
logdiag-6cd6ddbd1c25b9b78aaa0b1690b0ca748e2da810.tar.xz
logdiag-6cd6ddbd1c25b9b78aaa0b1690b0ca748e2da810.zip
ld-window-main.c: clean up
Diffstat (limited to 'src')
-rw-r--r--src/ld-window-main.c80
1 files changed, 45 insertions, 35 deletions
diff --git a/src/ld-window-main.c b/src/ld-window-main.c
index 169d3fb..c68ff3d 100644
--- a/src/ld-window-main.c
+++ b/src/ld-window-main.c
@@ -56,6 +56,8 @@ struct _LdWindowMainPrivate
static void ld_window_main_finalize (GObject *gobject);
static void load_library_directories (LdLibrary *library);
+static void display_and_free_error (LdWindowMain *self, const gchar *title,
+ GError *error);
static void on_ui_proxy_connected (GtkUIManager *ui, GtkAction *action,
GtkWidget *proxy, LdWindowMain *window);
@@ -107,6 +109,8 @@ static void on_action_save_as (GtkAction *action, LdWindowMain *self);
static void on_action_quit (GtkAction *action, LdWindowMain *self);
static void on_action_user_guide (GtkAction *action, LdWindowMain *self);
static void on_action_about (GtkAction *action, LdWindowMain *self);
+static gboolean on_action_about_activate_link (GtkAboutDialog *dialog,
+ gchar *uri, LdWindowMain *self);
static void on_action_undo (GtkAction *action, LdWindowMain *self);
static void on_action_redo (GtkAction *action, LdWindowMain *self);
@@ -444,6 +448,21 @@ load_library_directories (LdLibrary *library)
g_free (user_dir);
}
+static void
+display_and_free_error (LdWindowMain *self, const gchar *title, GError *error)
+{
+ GtkWidget *message_dialog;
+
+ message_dialog = gtk_message_dialog_new (GTK_WINDOW (self),
+ GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", title);
+ gtk_message_dialog_format_secondary_text
+ (GTK_MESSAGE_DIALOG (message_dialog), "%s", error->message);
+ g_error_free (error);
+
+ gtk_dialog_run (GTK_DIALOG (message_dialog));
+ gtk_widget_destroy (message_dialog);
+}
+
/*
* on_delete:
*
@@ -1040,21 +1059,36 @@ on_action_user_guide (GtkAction *action, LdWindowMain *self)
if (!open_file (file, gtk_window_get_screen (GTK_WINDOW (self)), &error))
{
- GtkWidget *message_dialog;
-
- message_dialog = gtk_message_dialog_new (GTK_WINDOW (self),
- GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Failed to open the user guide"));
- gtk_message_dialog_format_secondary_text
- (GTK_MESSAGE_DIALOG (message_dialog), "%s", error->message);
- g_error_free (error);
-
- gtk_dialog_run (GTK_DIALOG (message_dialog));
- gtk_widget_destroy (message_dialog);
+ display_and_free_error (self,
+ _("Failed to open the user guide"), error);
}
g_object_unref (file);
}
+static void
+on_action_about (GtkAction *action, LdWindowMain *self)
+{
+ GtkWidget *about_dialog;
+
+ about_dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
+ "program-name", PROJECT_NAME,
+ "logo-icon-name", PROJECT_NAME,
+ "version", PROJECT_VERSION,
+ "translator-credits", _("translator-credits"),
+ "copyright", "Copyright 2010 - 2021 Přemysl Eric Janouch",
+ "website", PROJECT_URL,
+ NULL);
+
+ g_signal_connect (about_dialog, "activate-link",
+ G_CALLBACK (on_action_about_activate_link), self);
+
+ gtk_window_set_transient_for (GTK_WINDOW (about_dialog), GTK_WINDOW (self));
+ gtk_window_set_modal (GTK_WINDOW (about_dialog), TRUE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (about_dialog), TRUE);
+ gtk_dialog_run (GTK_DIALOG (about_dialog));
+ gtk_widget_destroy (about_dialog);
+}
+
static gboolean
on_action_about_activate_link (GtkAboutDialog *dialog, gchar *uri,
LdWindowMain *self)
@@ -1081,30 +1115,6 @@ on_action_about_activate_link (GtkAboutDialog *dialog, gchar *uri,
}
static void
-on_action_about (GtkAction *action, LdWindowMain *self)
-{
- GtkWidget *about_dialog;
-
- about_dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
- "program-name", PROJECT_NAME,
- "logo-icon-name", PROJECT_NAME,
- "version", PROJECT_VERSION,
- "translator-credits", _("translator-credits"),
- "copyright", "Copyright 2010 - 2021 Přemysl Eric Janouch",
- "website", PROJECT_URL,
- NULL);
-
- g_signal_connect (about_dialog, "activate-link",
- G_CALLBACK (on_action_about_activate_link), self);
-
- gtk_window_set_transient_for (GTK_WINDOW (about_dialog), GTK_WINDOW (self));
- gtk_window_set_modal (GTK_WINDOW (about_dialog), TRUE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (about_dialog), TRUE);
- gtk_dialog_run (GTK_DIALOG (about_dialog));
- gtk_widget_destroy (about_dialog);
-}
-
-static void
on_action_undo (GtkAction *action, LdWindowMain *self)
{
ld_diagram_undo (self->priv->diagram);