|
|
0c9110 |
From 88ff2fcdf75ee9a44605847dc7e718cb7b5dedb2 Mon Sep 17 00:00:00 2001
|
|
|
0c9110 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
0c9110 |
Date: Wed, 30 Jul 2014 09:33:54 +0200
|
|
|
0c9110 |
Subject: [LIBREPORT PATCH 48/93] gui: conver report-gtk to GtkApplication
|
|
|
0c9110 |
|
|
|
0c9110 |
- improves compatibility with GNOME
|
|
|
0c9110 |
- allows us to move "Preferences" to the application menu
|
|
|
0c9110 |
|
|
|
0c9110 |
Related to rhbz#1069917
|
|
|
0c9110 |
|
|
|
0c9110 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
0c9110 |
---
|
|
|
0c9110 |
src/gui-wizard-gtk/main.c | 60 ++++++++++++++++++++++++++++++++++++-----
|
|
|
0c9110 |
src/gui-wizard-gtk/wizard.c | 26 ++++--------------
|
|
|
0c9110 |
src/gui-wizard-gtk/wizard.glade | 39 ---------------------------
|
|
|
0c9110 |
src/gui-wizard-gtk/wizard.h | 2 +-
|
|
|
0c9110 |
4 files changed, 60 insertions(+), 67 deletions(-)
|
|
|
0c9110 |
|
|
|
0c9110 |
diff --git a/src/gui-wizard-gtk/main.c b/src/gui-wizard-gtk/main.c
|
|
|
0c9110 |
index 0bfa45c..697b91f 100644
|
|
|
0c9110 |
--- a/src/gui-wizard-gtk/main.c
|
|
|
0c9110 |
+++ b/src/gui-wizard-gtk/main.c
|
|
|
0c9110 |
@@ -72,6 +72,55 @@ void problem_data_reload_from_dump_dir(void)
|
|
|
0c9110 |
g_cd = new_cd;
|
|
|
0c9110 |
}
|
|
|
0c9110 |
|
|
|
0c9110 |
+static void
|
|
|
0c9110 |
+preferences_activated(GSimpleAction *action,
|
|
|
0c9110 |
+ GVariant *parameter,
|
|
|
0c9110 |
+ gpointer data)
|
|
|
0c9110 |
+{
|
|
|
0c9110 |
+ GtkApplication *app = GTK_APPLICATION(data);
|
|
|
0c9110 |
+ show_config_list_dialog(GTK_WINDOW(gtk_application_get_active_window(app)));
|
|
|
0c9110 |
+}
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+static void
|
|
|
0c9110 |
+quit_activated(GSimpleAction *action,
|
|
|
0c9110 |
+ GVariant *parameter,
|
|
|
0c9110 |
+ gpointer data)
|
|
|
0c9110 |
+{
|
|
|
0c9110 |
+ g_application_quit(G_APPLICATION(data));
|
|
|
0c9110 |
+}
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+static GActionEntry app_entries[] =
|
|
|
0c9110 |
+{
|
|
|
0c9110 |
+ { "preferences", preferences_activated, NULL, NULL, NULL },
|
|
|
0c9110 |
+ { "quit", quit_activated, NULL, NULL, NULL }
|
|
|
0c9110 |
+};
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+static void
|
|
|
0c9110 |
+startup_wizard(GApplication *app,
|
|
|
0c9110 |
+ gpointer user_data)
|
|
|
0c9110 |
+{
|
|
|
0c9110 |
+ g_action_map_add_action_entries(G_ACTION_MAP (app),
|
|
|
0c9110 |
+ app_entries, G_N_ELEMENTS (app_entries),
|
|
|
0c9110 |
+ app);
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+ GMenu *app_menu = g_menu_new();
|
|
|
0c9110 |
+ g_menu_append(app_menu, _("Preferences"), "app.preferences");
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+ GMenu *service_app_menu_sec = g_menu_new();
|
|
|
0c9110 |
+ g_menu_append(service_app_menu_sec, _("Quit"), "app.quit");
|
|
|
0c9110 |
+ g_menu_append_section(app_menu, /*no title*/NULL, G_MENU_MODEL(service_app_menu_sec));
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+ gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL(app_menu));
|
|
|
0c9110 |
+}
|
|
|
0c9110 |
+
|
|
|
0c9110 |
+static void
|
|
|
0c9110 |
+activate_wizard(GApplication *app,
|
|
|
0c9110 |
+ gpointer user_data)
|
|
|
0c9110 |
+{
|
|
|
0c9110 |
+ create_assistant(GTK_APPLICATION(app), (bool)user_data);
|
|
|
0c9110 |
+ update_gui_state_from_problem_data(UPDATE_SELECTED_EVENT);
|
|
|
0c9110 |
+}
|
|
|
0c9110 |
+
|
|
|
0c9110 |
int main(int argc, char **argv)
|
|
|
0c9110 |
{
|
|
|
0c9110 |
bool expert_mode = false;
|
|
|
0c9110 |
@@ -166,14 +215,13 @@ int main(int argc, char **argv)
|
|
|
0c9110 |
|
|
|
0c9110 |
problem_data_reload_from_dump_dir();
|
|
|
0c9110 |
|
|
|
0c9110 |
- create_assistant(expert_mode);
|
|
|
0c9110 |
-
|
|
|
0c9110 |
g_custom_logger = &show_error_as_msgbox;
|
|
|
0c9110 |
-
|
|
|
0c9110 |
- update_gui_state_from_problem_data(UPDATE_SELECTED_EVENT);
|
|
|
0c9110 |
-
|
|
|
0c9110 |
+ GtkApplication *app = gtk_application_new("org.freedesktop.libreport.report", G_APPLICATION_FLAGS_NONE);
|
|
|
0c9110 |
+ g_signal_connect(app, "activate", G_CALLBACK(activate_wizard), (gpointer)expert_mode);
|
|
|
0c9110 |
+ g_signal_connect(app, "startup", G_CALLBACK(startup_wizard), NULL);
|
|
|
0c9110 |
/* Enter main loop */
|
|
|
0c9110 |
- gtk_main();
|
|
|
0c9110 |
+ g_application_run(G_APPLICATION(app), argc, argv);
|
|
|
0c9110 |
+ g_object_unref(app);
|
|
|
0c9110 |
|
|
|
0c9110 |
if (opts & OPT_d)
|
|
|
0c9110 |
delete_dump_dir_possibly_using_abrtd(g_dump_dir_name);
|
|
|
0c9110 |
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
|
|
|
0c9110 |
index 1fbe290..7cdd88b 100644
|
|
|
0c9110 |
--- a/src/gui-wizard-gtk/wizard.c
|
|
|
0c9110 |
+++ b/src/gui-wizard-gtk/wizard.c
|
|
|
0c9110 |
@@ -2128,12 +2128,6 @@ static void on_log_changed(GtkTextBuffer *buffer, gpointer user_data)
|
|
|
0c9110 |
gtk_widget_show(GTK_WIDGET(g_exp_report_log));
|
|
|
0c9110 |
}
|
|
|
0c9110 |
|
|
|
0c9110 |
-
|
|
|
0c9110 |
-static void on_show_event_list_cb(GtkWidget *button, gpointer user_data)
|
|
|
0c9110 |
-{
|
|
|
0c9110 |
- show_config_list_dialog(GTK_WINDOW(g_wnd_assistant));
|
|
|
0c9110 |
-}
|
|
|
0c9110 |
-
|
|
|
0c9110 |
#if 0
|
|
|
0c9110 |
static void log_ready_state(void)
|
|
|
0c9110 |
{
|
|
|
0c9110 |
@@ -3192,16 +3186,6 @@ static void add_pages(void)
|
|
|
0c9110 |
gtk_widget_override_font(GTK_WIDGET(g_tv_event_log), g_monospace_font);
|
|
|
0c9110 |
fix_all_wrapped_labels(GTK_WIDGET(g_assistant));
|
|
|
0c9110 |
|
|
|
0c9110 |
- /* Configure btn on select analyzers page */
|
|
|
0c9110 |
- GtkWidget *img_config_btn = gtk_image_new_from_icon_name("preferences-system", GTK_ICON_SIZE_BUTTON);
|
|
|
0c9110 |
- GtkWidget *config_btn = GTK_WIDGET(gtk_builder_get_object(g_builder, "button_cfg1"));
|
|
|
0c9110 |
- if (config_btn)
|
|
|
0c9110 |
- {
|
|
|
0c9110 |
- g_signal_connect(G_OBJECT(config_btn), "clicked", G_CALLBACK(on_show_event_list_cb), NULL);
|
|
|
0c9110 |
- gtk_button_set_image(GTK_BUTTON(config_btn), img_config_btn);
|
|
|
0c9110 |
- gtk_button_set_image_position(GTK_BUTTON(config_btn), GTK_POS_RIGHT);
|
|
|
0c9110 |
- }
|
|
|
0c9110 |
-
|
|
|
0c9110 |
g_signal_connect(g_cb_no_comment, "toggled", G_CALLBACK(on_no_comment_toggled), NULL);
|
|
|
0c9110 |
|
|
|
0c9110 |
g_signal_connect(g_rb_forbidden_words, "toggled", G_CALLBACK(on_forbidden_words_toggled), NULL);
|
|
|
0c9110 |
@@ -3297,7 +3281,7 @@ static void assistant_quit_cb(void *obj, void *data)
|
|
|
0c9110 |
g_loaded_texts = NULL;
|
|
|
0c9110 |
}
|
|
|
0c9110 |
|
|
|
0c9110 |
- gtk_main_quit();
|
|
|
0c9110 |
+ gtk_widget_destroy(GTK_WIDGET(data));
|
|
|
0c9110 |
}
|
|
|
0c9110 |
|
|
|
0c9110 |
static void on_btn_startcast(GtkWidget *btn, gpointer user_data)
|
|
|
0c9110 |
@@ -3353,7 +3337,7 @@ static bool is_screencast_available()
|
|
|
0c9110 |
return status == 0;
|
|
|
0c9110 |
}
|
|
|
0c9110 |
|
|
|
0c9110 |
-void create_assistant(bool expert_mode)
|
|
|
0c9110 |
+void create_assistant(GtkApplication *app, bool expert_mode)
|
|
|
0c9110 |
{
|
|
|
0c9110 |
g_loaded_texts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
|
|
|
0c9110 |
|
|
|
0c9110 |
@@ -3429,7 +3413,7 @@ void create_assistant(bool expert_mode)
|
|
|
0c9110 |
gtk_widget_hide(g_btn_onfail);
|
|
|
0c9110 |
gtk_widget_show(g_btn_next);
|
|
|
0c9110 |
|
|
|
0c9110 |
- g_wnd_assistant = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
|
|
|
0c9110 |
+ g_wnd_assistant = GTK_WINDOW(gtk_application_window_new(app));
|
|
|
0c9110 |
gtk_container_add(GTK_CONTAINER(g_wnd_assistant), GTK_WIDGET(g_box_assistant));
|
|
|
0c9110 |
|
|
|
0c9110 |
gtk_window_set_default_size(g_wnd_assistant, DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
|
|
0c9110 |
@@ -3444,12 +3428,12 @@ void create_assistant(bool expert_mode)
|
|
|
0c9110 |
|
|
|
0c9110 |
create_details_treeview();
|
|
|
0c9110 |
|
|
|
0c9110 |
- g_signal_connect(g_btn_close, "clicked", G_CALLBACK(assistant_quit_cb), NULL);
|
|
|
0c9110 |
+ g_signal_connect(g_btn_close, "clicked", G_CALLBACK(assistant_quit_cb), g_wnd_assistant);
|
|
|
0c9110 |
g_signal_connect(g_btn_stop, "clicked", G_CALLBACK(on_btn_cancel_event), NULL);
|
|
|
0c9110 |
g_signal_connect(g_btn_onfail, "clicked", G_CALLBACK(on_btn_failed_cb), NULL);
|
|
|
0c9110 |
g_signal_connect(g_btn_next, "clicked", G_CALLBACK(on_next_btn_cb), NULL);
|
|
|
0c9110 |
|
|
|
0c9110 |
- g_signal_connect(g_wnd_assistant, "destroy", G_CALLBACK(assistant_quit_cb), NULL);
|
|
|
0c9110 |
+ g_signal_connect(g_wnd_assistant, "destroy", G_CALLBACK(assistant_quit_cb), g_wnd_assistant);
|
|
|
0c9110 |
g_signal_connect(g_assistant, "switch-page", G_CALLBACK(on_page_prepare), NULL);
|
|
|
0c9110 |
|
|
|
0c9110 |
g_signal_connect(g_tb_approve_bt, "toggled", G_CALLBACK(on_bt_approve_toggle), NULL);
|
|
|
0c9110 |
diff --git a/src/gui-wizard-gtk/wizard.glade b/src/gui-wizard-gtk/wizard.glade
|
|
|
0c9110 |
index 9a179f4..9296bca 100644
|
|
|
0c9110 |
--- a/src/gui-wizard-gtk/wizard.glade
|
|
|
0c9110 |
+++ b/src/gui-wizard-gtk/wizard.glade
|
|
|
0c9110 |
@@ -430,45 +430,6 @@
|
|
|
0c9110 |
<property name="position">1</property>
|
|
|
0c9110 |
</packing>
|
|
|
0c9110 |
</child>
|
|
|
0c9110 |
- <child>
|
|
|
0c9110 |
- <object class="GtkHBox" id="hbox2">
|
|
|
0c9110 |
- <property name="visible">True</property>
|
|
|
0c9110 |
- <property name="can_focus">False</property>
|
|
|
0c9110 |
- <child>
|
|
|
0c9110 |
- <object class="GtkButton" id="button_cfg1">
|
|
|
0c9110 |
- <property name="label">_Preferences</property>
|
|
|
0c9110 |
- <property name="visible">True</property>
|
|
|
0c9110 |
- <property name="can_focus">True</property>
|
|
|
0c9110 |
- <property name="receives_default">True</property>
|
|
|
0c9110 |
- <property name="use_underline">True</property>
|
|
|
0c9110 |
- </object>
|
|
|
0c9110 |
- <packing>
|
|
|
0c9110 |
- <property name="expand">False</property>
|
|
|
0c9110 |
- <property name="fill">False</property>
|
|
|
0c9110 |
- <property name="position">0</property>
|
|
|
0c9110 |
- </packing>
|
|
|
0c9110 |
- </child>
|
|
|
0c9110 |
- <child>
|
|
|
0c9110 |
- <object class="GtkAlignment" id="alignment3">
|
|
|
0c9110 |
- <property name="visible">True</property>
|
|
|
0c9110 |
- <property name="can_focus">False</property>
|
|
|
0c9110 |
- <child>
|
|
|
0c9110 |
- <placeholder/>
|
|
|
0c9110 |
- </child>
|
|
|
0c9110 |
- </object>
|
|
|
0c9110 |
- <packing>
|
|
|
0c9110 |
- <property name="expand">True</property>
|
|
|
0c9110 |
- <property name="fill">True</property>
|
|
|
0c9110 |
- <property name="position">1</property>
|
|
|
0c9110 |
- </packing>
|
|
|
0c9110 |
- </child>
|
|
|
0c9110 |
- </object>
|
|
|
0c9110 |
- <packing>
|
|
|
0c9110 |
- <property name="expand">False</property>
|
|
|
0c9110 |
- <property name="fill">False</property>
|
|
|
0c9110 |
- <property name="position">2</property>
|
|
|
0c9110 |
- </packing>
|
|
|
0c9110 |
- </child>
|
|
|
0c9110 |
</object>
|
|
|
0c9110 |
</child>
|
|
|
0c9110 |
</object>
|
|
|
0c9110 |
diff --git a/src/gui-wizard-gtk/wizard.h b/src/gui-wizard-gtk/wizard.h
|
|
|
0c9110 |
index a6d8b5d..4c891dc 100644
|
|
|
0c9110 |
--- a/src/gui-wizard-gtk/wizard.h
|
|
|
0c9110 |
+++ b/src/gui-wizard-gtk/wizard.h
|
|
|
0c9110 |
@@ -21,7 +21,7 @@
|
|
|
0c9110 |
|
|
|
0c9110 |
#include "internal_libreport_gtk.h"
|
|
|
0c9110 |
|
|
|
0c9110 |
-void create_assistant(bool expert_mode);
|
|
|
0c9110 |
+void create_assistant(GtkApplication *app, bool expert_mode);
|
|
|
0c9110 |
|
|
|
0c9110 |
enum
|
|
|
0c9110 |
{
|
|
|
0c9110 |
--
|
|
|
0c9110 |
1.8.3.1
|
|
|
0c9110 |
|