[gnac/devel] Better separation between gnac-main and gnac-ui
- From: Benoît Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/devel] Better separation between gnac-main and gnac-ui
- Date: Mon, 18 Oct 2010 23:39:10 +0000 (UTC)
commit ddd2bb4ac6955be33d9200bd0f8677f1d33065dc
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date: Tue Oct 19 00:39:00 2010 +0100
Better separation between gnac-main and gnac-ui
data/ui/gnac.xml | 10 ++--
src/gnac-file-list.c | 16 +-----
src/gnac-main.c | 134 +-------------------------------------------------
src/gnac-main.h | 44 +++-------------
src/gnac-ui.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++++-
src/gnac-ui.h | 26 ++++++++++
6 files changed, 175 insertions(+), 188 deletions(-)
---
diff --git a/data/ui/gnac.xml b/data/ui/gnac.xml
index 415231e..55a29d4 100644
--- a/data/ui/gnac.xml
+++ b/data/ui/gnac.xml
@@ -32,7 +32,7 @@
<property name="stock_id">gtk-properties</property>
<property name="name">properties_item</property>
<property name="sensitive">False</property>
- <signal handler="gnac_on_ui_properties_cb" name="activate"/>
+ <signal handler="gnac_ui_on_properties_cb" name="activate"/>
</object>
<accelerator key="Return" modifiers="GDK_MOD1_MASK"/>
</child>
@@ -53,7 +53,7 @@
<object class="GtkAction" id="add_item">
<property name="stock_id">gtk-add</property>
<property name="name">add_item</property>
- <signal handler="gnac_on_ui_add_cb" name="activate"/>
+ <signal handler="gnac_ui_on_add_cb" name="activate"/>
</object>
<accelerator key="I" modifiers="GDK_CONTROL_MASK"/>
</child>
@@ -62,7 +62,7 @@
<property name="stock_id">gtk-remove</property>
<property name="name">remove_item</property>
<property name="sensitive">False</property>
- <signal handler="gnac_on_ui_remove_cb" name="activate"/>
+ <signal handler="gnac_ui_on_remove_cb" name="activate"/>
</object>
<accelerator key="Delete" />
</child>
@@ -92,7 +92,7 @@
<object class="GtkAction" id="help_item">
<property name="stock_id">gtk-help</property>
<property name="label" translatable="yes">_Contents</property>
- <signal handler="gnac_on_ui_help_cb" name="activate"/>
+ <signal handler="gnac_ui_on_help_cb" name="activate"/>
</object>
<accelerator key="F1"/>
</child>
@@ -231,7 +231,7 @@
<signal handler="gnac_file_list_popup_menu" name="popup_menu"/>
<signal handler="gnac_file_list_on_button_pressed" name="button_press_event"/>
<signal handler="gnac_file_list_on_row_activated_cb" name="row_activated"/>
- <signal handler="gnac_on_ui_drag_data_received_cb" name="drag_data_received"/>
+ <signal handler="gnac_ui_on_drag_data_received_cb" name="drag_data_received"/>
</object>
</child>
</object>
diff --git a/src/gnac-file-list.c b/src/gnac-file-list.c
index 7531237..b0600b2 100644
--- a/src/gnac-file-list.c
+++ b/src/gnac-file-list.c
@@ -651,6 +651,7 @@ gnac_file_list_hide_visual_bar()
gtk_tree_view_column_set_visible(column, FALSE);
}
+
void
gnac_file_list_remove_visual_error(const gchar *uri)
{
@@ -701,7 +702,7 @@ gnac_file_list_on_button_pressed(GtkWidget *treeview,
{
/* left click on an empty line */
if (event->button == 1 && !expanded) {
- gnac_on_ui_add_cb(NULL, NULL);
+ gnac_ui_on_add_cb(NULL, NULL);
ret = TRUE;
}
}
@@ -738,19 +739,6 @@ gnac_file_list_popup_menu(GtkWidget *treeview,
}
-/*
-void
-gnac_file_list_delete_key_pressed(GtkWidget *widget,
- GdkEventKey *key,
- gpointer data)
-{
- if (key->keyval == GDK_Delete) {
- gnac_on_ui_remove_cb(widget, data);
- }
-}
-*/
-
-
void
gnac_file_list_update_cursor(void)
{
diff --git a/src/gnac-main.c b/src/gnac-main.c
index 18d9f78..00c7429 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -54,8 +54,6 @@
#include "profiles/gnac-profiles-utils.h"
-static LibgnacConverter *converter;
-
static gboolean conversion_errors = FALSE;
static guint64 prev_time_left = -1;
//volatile?
@@ -70,7 +68,8 @@ guint nb_files_added;
GnacState state = GNAC_AUDIO_EMPTY_STATE;
GnacState prev_state = GNAC_AUDIO_EMPTY_STATE;
-LibgnacMetadata *metadata;
+LibgnacConverter *converter;
+LibgnacMetadata *metadata;
static const gchar *states[] = {
"GNAC_AUDIO_EMPTY_STATE",
@@ -213,33 +212,6 @@ gnac_add(GFile *file)
static void
-gnac_remove_track(gpointer data,
- gpointer user_data)
-{
- GError *error = NULL;
- GFile *file;
- GtkTreeRowReference *ref;
- gchar *uri = NULL;
-
- ref = (GtkTreeRowReference*) data;
-
- gnac_file_list_get(ref, &uri);
- file = g_file_new_for_uri(uri);
-
- libgnac_converter_remove(converter, file, &error);
- if (error)
- {
- g_printerr("%s: %s\n", _("Error"), error->message);
- g_clear_error(&error);
- }
-
- g_object_unref(file);
- gtk_tree_row_reference_free(ref);
- g_free(uri);
-}
-
-
-static void
gnac_files_names_list_foreach(gpointer data,
gpointer user_data)
{
@@ -409,9 +381,6 @@ gnac_on_ui_destroy_cb(GtkWidget *widget,
if (metadata) g_object_unref(metadata);
gnac_gconf_destroy();
- gnac_properties_destroy();
- gnac_prefs_destroy();
- gnac_profiles_destroy();
gnac_ui_destroy();
/* only call 'gtk_main_quit' if the main loop is running */
@@ -787,36 +756,6 @@ gnac_on_ui_convert_cb(GtkWidget *widget,
void
-gnac_on_ui_profile_changed_cb(GtkComboBox *box,
- gpointer data)
-{
- const gchar *profile_name = NULL;
- profile_name = gnac_profiles_get_name();
- gnac_gconf_set_string(GNAC_GCONF_LAST_USED_PROFILE, profile_name);
-}
-
-
-void
-gnac_on_ui_add_cb(GtkAction *action,
- gpointer data)
-{
- gtk_widget_show_all(gnac_ui_get_file_chooser());
-}
-
-
-void
-gnac_on_ui_remove_cb(GtkAction *action,
- gpointer data)
-{
- GList *rows;
- rows = gnac_file_list_get_selected_rows();
- /* References are freed by gnac_remove_track*/
- g_list_foreach(rows, (GFunc) gnac_remove_track, NULL);
- g_list_free(rows);
-}
-
-
-void
gnac_on_ui_clear_cb(GtkAction *action,
gpointer data)
{
@@ -831,75 +770,6 @@ gnac_on_ui_clear_cb(GtkAction *action,
}
-void
-gnac_on_ui_help_cb(GtkAction *action,
- gpointer data)
-{
- gboolean ret;
- GError *error = NULL;
-
- ret = gtk_show_uri(gtk_widget_get_screen(gnac_ui_get_widget("main_window")),
- "ghelp:gnac", gtk_get_current_event_time(), &error);
-
- if (!ret && error) {
- g_printerr("%s: %s\n", _("Could not display help"), error->message);
- g_error_free(error);
- }
-}
-
-
-void
-gnac_on_ui_properties_cb(GtkAction *action,
- gpointer user_data)
-{
- gnac_properties_window_show();
-}
-
-
-void
-gnac_on_ui_drag_data_received_cb(GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- gpointer data)
-{
- GFile *file;
- GSList *list_uris = NULL;
- gchar **uris;
- gchar *uri;
- gint index = 0;
-
- /* Disable any filtering for DnD. */
- gnac_ui_reset_file_filter();
-
- uris = gtk_selection_data_get_uris(selection_data);
-
- if (uris == NULL) {
- gtk_drag_finish (context, FALSE, FALSE, time);
- return;
- }
-
- uri = uris[0];
- while (uri != NULL) {
- file = g_file_new_for_uri(uri);
- //gnac_add(file);
- //g_object_unref(file);
- list_uris = g_slist_append(list_uris, file);
-
- index = index + 1;
- uri = uris[index];
- }
-
- if (list_uris != NULL) gnac_add_files(list_uris);
-
- gtk_drag_finish(context, TRUE, FALSE, time);
- g_strfreev(uris);
-}
-
-
/*static void
gnac_on_file_monitor_changed_cb(GFileMonitor *monitor,
GFile *file,
diff --git a/src/gnac-main.h b/src/gnac-main.h
index 35b5b29..b32bff0 100644
--- a/src/gnac-main.h
+++ b/src/gnac-main.h
@@ -33,6 +33,8 @@
G_BEGIN_DECLS
+extern LibgnacConverter *converter;
+
typedef enum {
GNAC_AUDIO_EMPTY_STATE,
GNAC_AUDIO_FILE_ACTION_STATE,
@@ -56,29 +58,13 @@ gnac_on_ui_convert_cb(GtkWidget *widget,
gpointer data);
void
-gnac_on_ui_profile_changed_cb(GtkComboBox *box,
- gpointer data);
-
-void
gnac_on_ui_pause_cb(GtkWidget *widget,
gpointer data);
void
-gnac_on_ui_add_cb(GtkAction *action,
- gpointer data);
-
-void
-gnac_on_ui_remove_cb(GtkAction *action,
- gpointer data);
-
-void
gnac_on_ui_clear_cb(GtkAction *action,
gpointer data);
-void
-gnac_on_ui_help_cb(GtkAction *action,
- gpointer data);
-
G_GNUC_NORETURN void
gnac_exit(gint status);
@@ -86,26 +72,12 @@ gboolean
gnac_on_ui_destroy_cb(GtkWidget *widget,
gpointer data);
-void
-gnac_on_ui_properties_cb(GtkAction *action,
- gpointer user_data);
-
-void
-gnac_on_ui_drag_data_received_cb(GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- gpointer data);
-
-void
-gnac_on_file_monitor_changed_cb(GFileMonitor *monitor,
- GFile *file,
- GFile *other_file,
- GFileMonitorEvent event_type,
- gpointer user_data);
+//void
+//gnac_on_file_monitor_changed_cb(GFileMonitor *monitor,
+// GFile *file,
+// GFile *other_file,
+// GFileMonitorEvent event_type,
+// gpointer user_data);
G_END_DECLS
diff --git a/src/gnac-ui.c b/src/gnac-ui.c
index 457b019..2c85eec 100644
--- a/src/gnac-ui.c
+++ b/src/gnac-ui.c
@@ -44,6 +44,8 @@
#include "gnac-gconf.h"
#include "gnac-main.h"
#include "gnac-options.h"
+#include "gnac-prefs.h"
+#include "gnac-properties.h"
#include "gnac-stock-items.h"
#include "gnac-ui.h"
#include "gnac-utils.h"
@@ -409,6 +411,43 @@ gnac_ui_file_chooser_new(void)
}
+static void
+gnac_ui_on_profile_changed_cb(GtkComboBox *box,
+ gpointer data)
+{
+ const gchar *profile_name = NULL;
+ profile_name = gnac_profiles_get_name();
+ gnac_gconf_set_string(GNAC_GCONF_LAST_USED_PROFILE, profile_name);
+}
+
+
+static void
+gnac_remove_track(gpointer data,
+ gpointer user_data)
+{
+ GError *error = NULL;
+ GFile *file;
+ GtkTreeRowReference *ref;
+ gchar *uri = NULL;
+
+ ref = (GtkTreeRowReference*) data;
+
+ gnac_file_list_get(ref, &uri);
+ file = g_file_new_for_uri(uri);
+
+ libgnac_converter_remove(converter, file, &error);
+ if (error)
+ {
+ g_printerr("%s: %s\n", _("Error"), error->message);
+ g_clear_error(&error);
+ }
+
+ g_object_unref(file);
+ gtk_tree_row_reference_free(ref);
+ g_free(uri);
+}
+
+
void
gnac_ui_reset_file_filter(void)
{
@@ -587,7 +626,7 @@ gnac_ui_new(void)
g_signal_connect(G_OBJECT(audio_profile_chooser_combo),
"changed",
- G_CALLBACK(gnac_on_ui_profile_changed_cb),
+ G_CALLBACK(gnac_ui_on_profile_changed_cb),
NULL);
current_profile = gnac_gconf_get_string(GNAC_GCONF_LAST_USED_PROFILE);
@@ -871,6 +910,94 @@ gnac_ui_on_focus_in_event_cb(GtkWidget *widget,
}
+void
+gnac_ui_on_help_cb(GtkAction *action,
+ gpointer user_data)
+{
+ gboolean ret;
+ GError *error = NULL;
+
+ ret = gtk_show_uri(gtk_widget_get_screen(gnac_ui_get_widget("main_window")),
+ "ghelp:gnac", gtk_get_current_event_time(), &error);
+ if (!ret && error) {
+ g_printerr("%s: %s\n", _("Could not display help"), error->message);
+ g_error_free(error);
+ }
+}
+
+
+void
+gnac_ui_on_properties_cb(GtkAction *action,
+ gpointer user_data)
+{
+ gnac_properties_window_show();
+}
+
+
+void
+gnac_ui_on_add_cb(GtkAction *action,
+ gpointer data)
+{
+ gtk_widget_show_all(gnac_ui_get_file_chooser());
+}
+
+
+void
+gnac_ui_on_remove_cb(GtkAction *action,
+ gpointer data)
+{
+ GList *rows;
+ rows = gnac_file_list_get_selected_rows();
+ /* References are freed by gnac_remove_track*/
+ g_list_foreach(rows, (GFunc) gnac_remove_track, NULL);
+ g_list_free(rows);
+}
+
+
+void
+gnac_ui_on_drag_data_received_cb(GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ gpointer data)
+{
+ GFile *file;
+ GSList *list_uris = NULL;
+ gchar **uris;
+ gchar *uri;
+ gint index = 0;
+
+ /* Disable any filtering for DnD. */
+ gnac_ui_reset_file_filter();
+
+ uris = gtk_selection_data_get_uris(selection_data);
+
+ if (uris == NULL) {
+ gtk_drag_finish (context, FALSE, FALSE, time);
+ return;
+ }
+
+ uri = uris[0];
+ while (uri != NULL) {
+ file = g_file_new_for_uri(uri);
+ //gnac_add(file);
+ //g_object_unref(file);
+ list_uris = g_slist_append(list_uris, file);
+
+ index = index + 1;
+ uri = uris[index];
+ }
+
+ if (list_uris != NULL) gnac_add_files(list_uris);
+
+ gtk_drag_finish(context, TRUE, FALSE, time);
+ g_strfreev(uris);
+}
+
+
#ifdef HAVE_LIBUNIQUE
static UniqueResponse
gnac_ui_message_received_cb(UniqueApp *app,
@@ -1035,6 +1162,10 @@ gnac_ui_destroy(void)
GtkWidget *main_window = NULL;
GtkWidget *about_dialog = NULL;
+ gnac_properties_destroy();
+ gnac_prefs_destroy();
+ gnac_profiles_destroy();
+
if (trayicon) {
g_object_unref(trayicon);
trayicon = NULL;
diff --git a/src/gnac-ui.h b/src/gnac-ui.h
index 3218ecf..850b5e8 100644
--- a/src/gnac-ui.h
+++ b/src/gnac-ui.h
@@ -126,6 +126,32 @@ gnac_ui_on_focus_in_event_cb(GtkWidget *widget,
GdkEventFocus *event,
gpointer data);
+void
+gnac_ui_on_help_cb(GtkAction *action,
+ gpointer user_data);
+
+void
+gnac_ui_on_properties_cb(GtkAction *action,
+ gpointer user_data);
+
+void
+gnac_ui_on_add_cb(GtkAction *action,
+ gpointer data);
+
+void
+gnac_ui_on_remove_cb(GtkAction *action,
+ gpointer data);
+
+void
+gnac_ui_on_drag_data_received_cb(GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ gpointer data);
+
void
gnac_ui_destroy(void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]