[gnac/devel] Code cleanup
- From: BenoÃt Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/devel] Code cleanup
- Date: Sat, 22 Oct 2011 18:30:04 +0000 (UTC)
commit b05ed9d83abc4ba8dd54a8d84c99f52b3b779c3c
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date: Fri Oct 21 21:32:57 2011 +0100
Code cleanup
data/profiles/ui/gnac-profiles-aac.xml | 6 +-
data/profiles/ui/gnac-profiles-base-advanced.xml | 4 +-
data/profiles/ui/gnac-profiles-combo.xml | 2 +-
data/profiles/ui/gnac-profiles-lame.xml | 12 +-
data/profiles/ui/gnac-profiles-speex.xml | 4 +-
data/profiles/ui/gnac-profiles-vorbis.xml | 8 +-
data/profiles/ui/gnac-profiles-wavpack.xml | 6 +-
data/ui/gnac.xml | 1 +
libgnac/libgnac-converter.c | 34 +---
libgnac/libgnac-debug.c | 22 +-
libgnac/libgnac-error.c | 8 +-
libgnac/libgnac-gst-utils.c | 2 +-
libgnac/libgnac-gst.c | 93 +-------
libgnac/libgnac-media-item.c | 24 +--
libgnac/libgnac-media-item.h | 2 -
libgnac/libgnac-metadata.c | 9 +-
libgnac/libgnac-output.c | 17 +--
libgnac/libgnac-output.h | 5 -
src/gnac-bars.c | 5 +-
src/gnac-file-list.c | 153 ++----------
src/gnac-file-list.h | 2 +-
src/gnac-main.c | 90 ++------
src/gnac-main.h | 15 +-
src/gnac-options.c | 4 +-
src/gnac-options.h | 3 -
src/gnac-playlist.c | 8 +-
src/gnac-prefs.c | 14 +-
src/gnac-properties.c | 75 ++++---
src/gnac-stock-items.c | 4 +-
src/gnac-ui.c | 72 ++----
src/gnac-ui.h | 5 +
src/gnac-utils.c | 65 +++++-
src/gnac-utils.h | 9 +
src/profiles/formats/gnac-profiles-unknown.c | 3 -
src/profiles/gnac-profiles-default.h | 1 -
src/profiles/gnac-profiles-manager.c | 11 +-
src/profiles/gnac-profiles-manager.h | 3 -
src/profiles/gnac-profiles-properties.c | 286 +++-------------------
src/profiles/gnac-profiles-properties.h | 2 -
src/profiles/gnac-profiles-utils.c | 25 +--
src/profiles/gnac-profiles-xml-engine.c | 3 +-
41 files changed, 294 insertions(+), 823 deletions(-)
---
diff --git a/data/profiles/ui/gnac-profiles-aac.xml b/data/profiles/ui/gnac-profiles-aac.xml
index f2e3393..a67e92c 100755
--- a/data/profiles/ui/gnac-profiles-aac.xml
+++ b/data/profiles/ui/gnac-profiles-aac.xml
@@ -42,7 +42,7 @@
<object class="GtkHBox" id="hbox-outputformat">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-outputformat">
+ <object class="GtkComboBoxText" id="combo-outputformat">
<property name="visible">True</property>
</object>
<packing>
@@ -77,7 +77,7 @@
<object class="GtkHBox" id="hbox-profile">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-profile">
+ <object class="GtkComboBoxText" id="combo-profile">
<property name="visible">True</property>
</object>
<packing>
@@ -140,7 +140,7 @@
<object class="GtkHBox" id="hbox-bitrate">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-bitrate">
+ <object class="GtkComboBoxText" id="combo-bitrate">
<property name="visible">True</property>
</object>
<packing>
diff --git a/data/profiles/ui/gnac-profiles-base-advanced.xml b/data/profiles/ui/gnac-profiles-base-advanced.xml
index e9c8069..7fcac07 100755
--- a/data/profiles/ui/gnac-profiles-base-advanced.xml
+++ b/data/profiles/ui/gnac-profiles-base-advanced.xml
@@ -12,7 +12,7 @@
<object class="GtkHBox" id="hbox-sample-rate">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-sample-rate">
+ <object class="GtkComboBoxText" id="combo-sample-rate">
<property name="visible">True</property>
</object>
<packing>
@@ -35,7 +35,7 @@
<object class="GtkHBox" id="hbox-channels">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-channels">
+ <object class="GtkComboBoxText" id="combo-channels">
<property name="visible">True</property>
</object>
<packing>
diff --git a/data/profiles/ui/gnac-profiles-combo.xml b/data/profiles/ui/gnac-profiles-combo.xml
index 3209977..2bfdc88 100644
--- a/data/profiles/ui/gnac-profiles-combo.xml
+++ b/data/profiles/ui/gnac-profiles-combo.xml
@@ -8,7 +8,7 @@
<property name="visible">True</property>
<property name="spacing">5</property>
<child>
- <object class="GtkComboBox" id="combo-profile">
+ <object class="GtkComboBoxText" id="combo-profile">
<property name="visible">True</property>
<property name="model">liststore-profile</property>
</object>
diff --git a/data/profiles/ui/gnac-profiles-lame.xml b/data/profiles/ui/gnac-profiles-lame.xml
index 208ce7d..4d5b2ae 100755
--- a/data/profiles/ui/gnac-profiles-lame.xml
+++ b/data/profiles/ui/gnac-profiles-lame.xml
@@ -42,7 +42,7 @@
<object class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-mode">
+ <object class="GtkComboBoxText" id="combo-mode">
<property name="visible">True</property>
</object>
<packing>
@@ -138,7 +138,7 @@
<object class="GtkHBox" id="hbox5">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-min-vbr">
+ <object class="GtkComboBoxText" id="combo-min-vbr">
<property name="visible">True</property>
<property name="sensitive">False</property>
</object>
@@ -161,7 +161,7 @@
<object class="GtkHBox" id="hbox6">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-max-vbr">
+ <object class="GtkComboBoxText" id="combo-max-vbr">
<property name="visible">True</property>
<property name="sensitive">False</property>
</object>
@@ -208,7 +208,7 @@
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-encoding-mode">
+ <object class="GtkComboBoxText" id="combo-encoding-mode">
<property name="visible">True</property>
</object>
<packing>
@@ -228,7 +228,7 @@
<object class="GtkHBox" id="hbox-bitrate">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-bitrate">
+ <object class="GtkComboBoxText" id="combo-bitrate">
<property name="visible">True</property>
</object>
<packing>
@@ -251,7 +251,7 @@
<object class="GtkHBox" id="hbox-preset">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-preset">
+ <object class="GtkComboBoxText" id="combo-preset">
<property name="visible">True</property>
</object>
<packing>
diff --git a/data/profiles/ui/gnac-profiles-speex.xml b/data/profiles/ui/gnac-profiles-speex.xml
index a949e39..9d8ec93 100644
--- a/data/profiles/ui/gnac-profiles-speex.xml
+++ b/data/profiles/ui/gnac-profiles-speex.xml
@@ -34,7 +34,7 @@
<object class="GtkHBox" id="hbox-mode">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-mode">
+ <object class="GtkComboBoxText" id="combo-mode">
<property name="visible">True</property>
</object>
<packing>
@@ -224,7 +224,7 @@
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-bitrate-mode">
+ <object class="GtkComboBoxText" id="combo-bitrate-mode">
<property name="visible">True</property>
</object>
<packing>
diff --git a/data/profiles/ui/gnac-profiles-vorbis.xml b/data/profiles/ui/gnac-profiles-vorbis.xml
index e9fc2c1..8b572e2 100755
--- a/data/profiles/ui/gnac-profiles-vorbis.xml
+++ b/data/profiles/ui/gnac-profiles-vorbis.xml
@@ -60,7 +60,7 @@
<object class="GtkHBox" id="hbox-min-bitrate">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-min-vbr">
+ <object class="GtkComboBoxText" id="combo-min-vbr">
<property name="visible">True</property>
<property name="sensitive">False</property>
</object>
@@ -83,7 +83,7 @@
<object class="GtkHBox" id="hbox-max-bitrate">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-max-vbr">
+ <object class="GtkComboBoxText" id="combo-max-vbr">
<property name="visible">True</property>
<property name="sensitive">False</property>
</object>
@@ -130,7 +130,7 @@
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-encoding-mode">
+ <object class="GtkComboBoxText" id="combo-encoding-mode">
<property name="visible">True</property>
</object>
<packing>
@@ -150,7 +150,7 @@
<object class="GtkHBox" id="hbox-bitrate">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-bitrate">
+ <object class="GtkComboBoxText" id="combo-bitrate">
<property name="visible">True</property>
</object>
<packing>
diff --git a/data/profiles/ui/gnac-profiles-wavpack.xml b/data/profiles/ui/gnac-profiles-wavpack.xml
index b81d0d3..9c5c294 100644
--- a/data/profiles/ui/gnac-profiles-wavpack.xml
+++ b/data/profiles/ui/gnac-profiles-wavpack.xml
@@ -81,7 +81,7 @@
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-joint-stereo-mode">
+ <object class="GtkComboBoxText" id="combo-joint-stereo-mode">
<property name="visible">True</property>
<property name="sensitive">False</property>
</object>
@@ -163,7 +163,7 @@
<object class="GtkHBox" id="hbox-control-method">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-bitrate-control">
+ <object class="GtkComboBoxText" id="combo-bitrate-control">
<property name="visible">True</property>
</object>
<packing>
@@ -279,7 +279,7 @@
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<child>
- <object class="GtkComboBox" id="combo-mode">
+ <object class="GtkComboBoxText" id="combo-mode">
<property name="visible">True</property>
</object>
<packing>
diff --git a/data/ui/gnac.xml b/data/ui/gnac.xml
index b0d3847..9ea7eed 100644
--- a/data/ui/gnac.xml
+++ b/data/ui/gnac.xml
@@ -384,6 +384,7 @@ Alexandre Roux <alexroux src gnome org></property>
<signal handler="gtk_widget_hide_on_delete" name="close"/>
<signal handler="gtk_widget_hide_on_delete" name="delete-event"/>
<signal handler="gtk_widget_hide_on_delete" name="response"/>
+ <signal handler="gnac_about_url_hook" name="activate-link"/>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
diff --git a/libgnac/libgnac-converter.c b/libgnac/libgnac-converter.c
index 864130d..80d014e 100644
--- a/libgnac/libgnac-converter.c
+++ b/libgnac/libgnac-converter.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <glib/gi18n.h>
@@ -37,7 +37,6 @@
#include "libgnac-profile.h"
-// TODO add WARNING and PAUSED, and RESUMED ?
enum
{
OVERWRITE,
@@ -77,7 +76,6 @@ struct LibgnacConverterPrivate
GHashTable *file_table;
GQueue *queue;
GQueue *queue_copy;
- //GHashTableIter iter;
LibgnacMediaItem *current;
gint n_converted;
guint64 elapsed_duration;
@@ -108,14 +106,9 @@ libgnac_converter_init(LibgnacConverter *self)
self->priv = priv = LIBGNAC_CONVERTER_GET_PRIVATE(self);
- /* Public */
-
- /* Private */
-
priv->queue = g_queue_new();
priv->queue_copy = NULL;
- /* TODO replace this when profiles */
priv->file_table = g_hash_table_new_full(g_str_hash,
g_str_equal,
g_free,
@@ -248,7 +241,6 @@ libgnac_converter_get_property(GObject *object,
break;
default:
- /* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
@@ -316,7 +308,6 @@ libgnac_converter_set_property(GObject *object,
break;
default:
- /* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
@@ -604,7 +595,6 @@ libgnac_converter_start_next(LibgnacConverter *self)
g_signal_emit(self, signals[ERROR], 0, uri, err->message, err);
}
- // TODO why not retrieveing error ?
tags = libgnac_metadata_extract(metadata, item->source, NULL);
if (libgnac_metadata_tags_exist(tags, GST_TAG_DURATION, NULL))
{
@@ -819,7 +809,6 @@ libgnac_converter_start(LibgnacConverter *self,
}
priv->queue_copy = g_queue_copy(priv->queue);
g_queue_sort(priv->queue_copy, (GCompareDataFunc)g_strcmp0, NULL);
- //g_hash_table_iter_init(&(priv->iter), priv->file_table);
priv->n_converted = -1;
priv->elapsed_duration = 0;
@@ -870,9 +859,6 @@ libgnac_converter_pause(LibgnacConverter *self,
g_return_if_fail(error == NULL || *error == NULL);
priv = LIBGNAC_CONVERTER_GET_PRIVATE(self);
- // TODO
- //libgnac_item_pause(priv->current, &err);
- // SIGNAL ?
libgnac_gst_pause(priv->current, error);
}
@@ -886,9 +872,6 @@ libgnac_converter_resume(LibgnacConverter *self,
g_return_if_fail(error == NULL || *error == NULL);
priv = LIBGNAC_CONVERTER_GET_PRIVATE(self);
- // TODO
- //libgnac_item_resume(priv->current, &err);
- // SIGNAL ?
libgnac_gst_run(priv->current, error);
}
@@ -946,12 +929,10 @@ libgnac_converter_error_sink(LibgnacMediaItem *item,
g_return_val_if_fail(item->destination, FALSE);
g_return_val_if_fail(error, FALSE);
- /* Create missing directory */
GError *err = NULL;
GFile *folder;
gboolean folder_creation;
- // TODO libgnac_utils
/* Get parent folder name */
folder = g_file_get_parent(item->destination);
folder_creation = g_file_make_directory_with_parents(folder, NULL, &err);
@@ -996,8 +977,6 @@ libgnac_converter_error_sink(LibgnacMediaItem *item,
gboolean overwrite = FALSE;
- /* TODO; do not interrupt user's workflow
- * Provide some notification => GtkInfoBar */
g_signal_emit(item->parent, signals[OVERWRITE], 0,
item->destination, &overwrite);
@@ -1006,7 +985,6 @@ libgnac_converter_error_sink(LibgnacMediaItem *item,
GError *err = NULL;
libgnac_debug("Overwrite file");
- // TODO libgnac_utils
g_file_delete(item->destination, NULL, &err);
if (err) {
libgnac_warning("Unable to overwrite file %s: %s", uri, err->message);
@@ -1020,7 +998,6 @@ libgnac_converter_error_sink(LibgnacMediaItem *item,
/* Just send error signal */
else
{
- // TODO transform to WARNING signal
gchar *msg;
GError *err = NULL;
@@ -1066,7 +1043,6 @@ libgnac_converter_error_other(LibgnacMediaItem *item,
{
GError *err = NULL;
- // TODO libgnac_utils
g_file_delete(item->destination, NULL, &err);
if (err) {
libgnac_warning("Unable to remove partial file %s: %s", uri, err->message);
@@ -1085,7 +1061,6 @@ libgnac_converter_error_cb(GstBus *bus,
gpointer data)
{
GError *error = NULL;
- GstObject *src = NULL;
LibgnacConverter *converter = NULL;
LibgnacMediaItem *item = NULL;
gchar *uri;
@@ -1100,7 +1075,6 @@ libgnac_converter_error_cb(GstBus *bus,
uri = g_file_get_uri(item->source);
out_uri = g_file_get_uri(item->destination);
- src = GST_MESSAGE_SRC(message);
name = GST_MESSAGE_SRC_NAME(message);
gst_message_parse_error(message, &error, NULL);
libgnac_debug("An error occured for file %s", uri);
@@ -1131,12 +1105,6 @@ libgnac_converter_error_cb(GstBus *bus,
g_free(uri);
g_free(out_uri);
- /*
- * We cannot remove partial file here, in some case the error is
- * access error and we do not want and cannot remove the file
- */
-
- // TODO restart current if needed
if (restart) {
if (libgnac_converter_restart_current(item->parent)) {
/* The restart was ok, do not send any signal and do not start next*/
diff --git a/libgnac/libgnac-debug.c b/libgnac/libgnac-debug.c
index 5d4ff14..d6e285d 100644
--- a/libgnac/libgnac-debug.c
+++ b/libgnac/libgnac-debug.c
@@ -26,12 +26,12 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#include <glib.h>
+#endif
#include "libgnac-debug.h"
+#define BUFFER_SIZE 1024
+
gboolean LIBGNAC_DEBUG;
gboolean LIBGNAC_VERBOSE;
@@ -45,10 +45,10 @@ libgnac_debug_real(const gchar *func,
if (LIBGNAC_DEBUG)
{
va_list args;
- char buffer[1025];
+ char buffer[BUFFER_SIZE];
va_start(args, format);
- g_vsnprintf(buffer, 1024, format, args);
+ g_vsnprintf(buffer, BUFFER_SIZE, format, args);
va_end(args);
g_printerr("[DEBUG] %s:%d: %s\n", file, line, buffer);
@@ -64,10 +64,10 @@ libgnac_critical_real(const gchar *func,
...)
{
va_list args;
- char buffer[1025];
+ char buffer[BUFFER_SIZE];
va_start(args, format);
- g_vsnprintf(buffer, 1024, format, args);
+ g_vsnprintf(buffer, BUFFER_SIZE, format, args);
va_end(args);
g_printerr("[CRITICAL] %s:%d: %s\n", file, line, buffer);
@@ -82,10 +82,10 @@ libgnac_warning_real(const gchar *func,
...)
{
va_list args;
- char buffer[1025];
+ char buffer[BUFFER_SIZE];
va_start(args, format);
- g_vsnprintf(buffer, 1024, format, args);
+ g_vsnprintf(buffer, BUFFER_SIZE, format, args);
va_end(args);
g_printerr("[WARNING] %s:%d: %s\n", file, line, buffer);
@@ -98,10 +98,10 @@ libgnac_info(const gchar *format, ...)
if (LIBGNAC_VERBOSE)
{
va_list args;
- char buffer[1025];
+ char buffer[BUFFER_SIZE];
va_start(args, format);
- g_vsnprintf(buffer, 1024, format, args);
+ g_vsnprintf(buffer, BUFFER_SIZE, format, args);
va_end(args);
g_print("[INFO] %s\n", buffer);
diff --git a/libgnac/libgnac-error.c b/libgnac/libgnac-error.c
index 32fd38e..77a359b 100644
--- a/libgnac/libgnac-error.c
+++ b/libgnac/libgnac-error.c
@@ -28,11 +28,11 @@
GQuark
libgnac_error_quark(void)
{
- static GQuark q = 0;
+ static GQuark quark = 0;
- if (q == 0) {
- q = g_quark_from_static_string("libgnac-error-quark");
+ if (quark == 0) {
+ quark = g_quark_from_static_string("libgnac-error-quark");
}
- return q;
+ return quark;
}
diff --git a/libgnac/libgnac-gst-utils.c b/libgnac/libgnac-gst-utils.c
index 4c47dd1..3cf8537 100644
--- a/libgnac/libgnac-gst-utils.c
+++ b/libgnac/libgnac-gst-utils.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <glib/gi18n.h>
diff --git a/libgnac/libgnac-gst.c b/libgnac/libgnac-gst.c
index eb4c23b..860a859 100644
--- a/libgnac/libgnac-gst.c
+++ b/libgnac/libgnac-gst.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <glib/gi18n.h>
@@ -205,7 +205,6 @@ libgnac_gst_build_pipeline(LibgnacMediaItem *item,
gboolean has_video,
GError **error)
{
- gboolean linked;
GError *encoder_error = NULL;
GstElement *source = NULL;
GstElement *decodebin;
@@ -243,7 +242,7 @@ libgnac_gst_build_pipeline(LibgnacMediaItem *item,
return;
}
- linked = libgnac_gstu_element_link(source, decodebin, &encoder_error);
+ libgnac_gstu_element_link(source, decodebin, &encoder_error);
if (encoder_error) {
libgnac_debug("link source->decodebin failed");
g_propagate_error(error, encoder_error);
@@ -291,7 +290,7 @@ libgnac_gst_build_pipeline(LibgnacMediaItem *item,
}
item->muxer = mux;
- linked = libgnac_gstu_element_link(mux, sink, &encoder_error);
+ libgnac_gstu_element_link(mux, sink, &encoder_error);
if (encoder_error) {
libgnac_debug("link encoder->sink failed");
g_propagate_error(error, encoder_error);
@@ -347,7 +346,7 @@ libgnac_gst_build_pipeline(LibgnacMediaItem *item,
}
else /* audio file */
{
- linked = libgnac_gstu_element_link(audio_bin, sink, &encoder_error);
+ libgnac_gstu_element_link(audio_bin, sink, &encoder_error);
if (encoder_error) {
libgnac_debug("link encoder->sink failed");
g_propagate_error(error, encoder_error);
@@ -355,14 +354,8 @@ libgnac_gst_build_pipeline(LibgnacMediaItem *item,
}
}
- /* Connect callbacks */
-
g_signal_connect(decodebin, "new-decoded-pad",
G_CALLBACK(libgnac_gst_newpad_cb), item);
- /*
- g_signal_connect(decodebin, "unknown-type",
- G_CALLBACK(libgnac_gst_unknown_type_cb), item); */
-
}
@@ -432,81 +425,3 @@ libgnac_gst_newpad_cb(GstElement *decodebin,
gst_caps_unref(caps);
}
-
-
-/*void
-libgnac_gst_tags_cb(GstBus *bus,
- GstMessage *message,
- gpointer data)
-{
- GstTagList *tags;
-
- gst_message_parse_tag(message, &tags);
- if (tags) {
- // do something with tags
- gst_tag_list_free (tags);
- } else {
-
- }
-}*/
-
-
-/*
-
-void
-libgnac_gst_element_cb(GstBus *bus,
- GstMessage *message,
- gpointer data)
-{
- gchar *details;
-
- // This code handle missing plugins installer
- if (gst_is_missing_plugin_message(message))
- {
- // TODO free details, but where ?
- details = gst_missing_plugin_message_get_installer_detail(message);
- if (details)
- {
- gst_install_plugins_async(&details, NULL,
- // TODO, what to do ?
- libgnac_converter_missing_plugin_result_cb, data);
- }
- }
-}
-
-*/
-
-
- /*
-void
-libgnac_gst_unknown_type_cb(GstElement *decodebin,
- GstPad *pad,
- GstCaps *caps,
- gpointer data)
-{
- if (!gst_caps_is_empty (caps) && !gst_caps_is_any (caps)) {
- GstStructure *structure;
- const gchar *mimetype;
-
- structure = gst_caps_get_structure (caps, 0);
- mimetype = gst_structure_get_name (structure);
-
- g_free (md->priv->type);
- md->priv->type = g_strdup (mimetype);
-
- rb_debug ("decodebin emitted unknown type signal for %s", mimetype);
- } else {
- rb_debug ("decodebin emitted unknown type signal");
- }
-
- md->priv->has_non_audio = TRUE;
-#ifndef HAVE_GSTREAMER_0_10_MISSING_PLUGINS
- {
- char *msg;
-
- msg = make_undecodable_error (md);
- GST_ELEMENT_ERROR (md->priv->pipeline, STREAM, CODEC_NOT_FOUND, ("%s", msg), (NULL));
- g_free (msg);
- }
-#endif
-} */
diff --git a/libgnac/libgnac-media-item.c b/libgnac/libgnac-media-item.c
index f3923f3..fbea60e 100644
--- a/libgnac/libgnac-media-item.c
+++ b/libgnac/libgnac-media-item.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <glib/gi18n.h>
@@ -92,7 +92,6 @@ libgnac_item_build(LibgnacMediaItem *item,
}
/* is it a video file? */
- // TODO why not passing error ?
tags = libgnac_metadata_extract(metadata, item->source, NULL);
if (tags && libgnac_metadata_tag_exists(tags, GNAC_TAG_HAS_VIDEO)) {
has_video = TRUE;
@@ -137,7 +136,6 @@ libgnac_item_build(LibgnacMediaItem *item,
G_CALLBACK(libgnac_item_error_cb), item);
/* Connect parent callbacks */
- // TODO move
g_signal_connect(G_OBJECT(item->bus), "message::eos",
G_CALLBACK(libgnac_converter_eos_cb), item->parent);
g_signal_connect(G_OBJECT(item->bus), "message::error",
@@ -183,15 +181,12 @@ libgnac_item_stop(LibgnacMediaItem *item,
libgnac_item_clear_event_src(item);
libgnac_gst_stop(item, &err);
- // TODO propagate error here
- //g_propagate_error(error, err);
/* Remove not completed file */
if (G_IS_FILE(item->destination))
{
g_file_delete(item->destination, NULL, &err);
if (err) {
- // Warning, but not critical
libgnac_warning("Unable to remove partial file");
g_clear_error(&err);
}
@@ -199,22 +194,6 @@ libgnac_item_stop(LibgnacMediaItem *item,
}
-/*void
-libgnac_item_pause(LibgnacMediaItem *item,
- GError **error)
-{
- g_return_if_fail(error == NULL || *error == NULL);
-}
-
-
-void
-libgnac_item_resume(LibgnacMediaItem *item,
- GError **error)
-{
- g_return_if_fail(error == NULL || *error == NULL);
-}*/
-
-
void
libgnac_item_free(LibgnacMediaItem *item)
{
@@ -280,5 +259,4 @@ libgnac_item_error_cb(GstBus *bus,
item = (LibgnacMediaItem*)data;
libgnac_item_clear_event_src(item);
-// libgnac_gst_clean_pipeline(item);
}
diff --git a/libgnac/libgnac-media-item.h b/libgnac/libgnac-media-item.h
index 240e435..3ade56c 100644
--- a/libgnac/libgnac-media-item.h
+++ b/libgnac/libgnac-media-item.h
@@ -34,8 +34,6 @@
G_BEGIN_DECLS
-/* Encoder item that handle a file conversion */
-
typedef struct
{
gpointer parent;
diff --git a/libgnac/libgnac-metadata.c b/libgnac/libgnac-metadata.c
index 726b188..5e0a6c7 100644
--- a/libgnac/libgnac-metadata.c
+++ b/libgnac/libgnac-metadata.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib/gi18n.h>
@@ -250,7 +250,6 @@ libgnac_metadata_process_tag_image(const GstTagList *taglist,
g_value_init(newval, G_TYPE_OBJECT);
g_value_set_object(newval, pixbuf);
- /* we don't need the loader anymore */
g_object_unref(G_OBJECT(loader));
loader = NULL;
@@ -709,8 +708,6 @@ libgnac_metadata_extract(LibgnacMetadata *md,
{
libgnac_debug("An error occured while extracting metadata from file %s",
string_uri);
- // XXX something went wrong...
- // what do we do?
}
else if (state_return == GST_STATE_CHANGE_SUCCESS) {
if (g_hash_table_lookup(md->priv->metadata, GST_TAG_DURATION) == NULL) {
@@ -741,10 +738,6 @@ libgnac_metadata_extract(LibgnacMetadata *md,
g_hash_table_insert(md->priv->tags_table, g_strdup(string_uri),
md->priv->metadata);
tags = md->priv->metadata;
-
- // TODO We don't need to save anything in metadata anymore
- // put it to NULL ?
- // The Metadata will be freed when the hash table will be destroyed
}
g_free(string_uri);
diff --git a/libgnac/libgnac-output.c b/libgnac/libgnac-output.c
index 8d7b1ec..8a96d34 100644
--- a/libgnac/libgnac-output.c
+++ b/libgnac/libgnac-output.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <gio/gio.h>
#include <glib.h>
@@ -132,14 +132,6 @@ libgnac_output_sanitize_path(const gchar *str,
s = g_strdup(str);
- /* Replace path seperators with a hyphen */
- /* This operation is done in libgnac_output_rename_pattern_set_replace
- * as folder hierarchy and/or custom rename patterns may contain
- * legitimate dir separators. */
- //g_strdelimit(s, G_DIR_SEPARATOR_S, '-');
-
- // TODO filesystem specific sanitizing
-
if (strip_special)
{
/* Replace separators with a hyphen */
@@ -402,13 +394,6 @@ libgnac_output_build_output(GFile *source,
return NULL;
}
- /*if (!filename) {
- g_set_error(error,
- LIBGNAC_ERROR,
- LIBGNAC_ERROR_INVALID_FILENAME,
- "Invalid output filename");
- }*/
-
switch (config->folder_type)
{
case FOLDER_SUBDIRECTORY:
diff --git a/libgnac/libgnac-output.h b/libgnac/libgnac-output.h
index 9de3676..950d959 100644
--- a/libgnac/libgnac-output.h
+++ b/libgnac/libgnac-output.h
@@ -26,13 +26,8 @@
#ifndef __LIBGNAC_OUTPUT_H__
#define __LIBGNAC_OUTPUT_H__
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
#include <gio/gio.h>
#include <glib.h>
-#include <glib/gi18n.h>
#define RENAME_PATTERN_SEPARATOR '%'
diff --git a/src/gnac-bars.c b/src/gnac-bars.c
index 29b524a..b845291 100644
--- a/src/gnac-bars.c
+++ b/src/gnac-bars.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <glib/gi18n.h>
#include <gtk/gtk.h>
@@ -38,9 +38,6 @@
#include "gnac-ui.h"
-extern gint nb_files_total;
-
-
static void
gnac_bars_update_convert_label(const gchar *label);
diff --git a/src/gnac-file-list.c b/src/gnac-file-list.c
index 3de98ea..69088d6 100644
--- a/src/gnac-file-list.c
+++ b/src/gnac-file-list.c
@@ -36,49 +36,10 @@
#include "libgnac-debug.h"
-extern GnacState state;
-
static GtkWidget *view = NULL;
static GtkTreeModel *model = NULL;
static GtkTreeSelection *selection = NULL;
-
-static GHashTable *reference_table = NULL;
-
-/* Tooltips configuration */
-/*
-static gboolean
-gnac_file_list_tooltip_cb(GtkWidget *widget,
- gint x,
- gint y,
- gboolean keyboard_tip,
- GtkTooltip *tooltip,
- gpointer data)
-{
- GtkTreeIter iter;
- GtkTreePath *path = NULL;
- gchar *tip_msg = NULL;
-
-
- if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW(view), &x, &y,
- keyboard_tip,
- &model, &path, &iter)) {
- return FALSE;
- }
-
- gtk_tree_model_get(model, &iter, COL_TOOLTIP, &tip_msg, -1);
-
- if (!tip_msg) {
- return FALSE;
- }
- gtk_tooltip_set_text(tooltip, tip_msg);
-
- //gtk_tree_view_set_tooltip_cell (view, tooltip, path, column, cell)
-
- gtk_tree_path_free (path);
-
- //gtk_tree_view_set_tooltip_row (tree_view, tooltip, path);
- return TRUE;
-}*/
+static GHashTable *reference_table = NULL;
static void
@@ -87,13 +48,16 @@ gnac_file_list_select_row(GtkTreeRowReference *reference)
GtkTreePath *path;
g_return_if_fail(reference);
+
path = gtk_tree_row_reference_get_path(reference);
gtk_tree_selection_unselect_all(selection);
gtk_tree_selection_select_path(selection, path);
+
gtk_tree_path_free(path);
}
+
static void
gnac_file_list_display_stock(GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
@@ -107,6 +71,7 @@ gnac_file_list_display_stock(GtkTreeViewColumn *tree_column,
g_object_set(G_OBJECT(cell), "stock-id", stock_id, NULL);
}
+
/*
* Returns the number of rows that have been selected in the file list
*/
@@ -116,7 +81,8 @@ gnac_file_list_count_selected_rows(void)
return gtk_tree_selection_count_selected_rows(selection);
}
-gint
+
+guint
gnac_file_list_count_rows(void)
{
return g_hash_table_size(reference_table);
@@ -143,7 +109,6 @@ gnac_file_list_on_row_inserted_cb(GtkTreeModel *tree_model,
}
-
static void
gnac_file_list_selection_changed_cb(GtkTreeSelection *selection,
gpointer user_data)
@@ -170,31 +135,18 @@ gnac_file_list_new(void)
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
- /* Init reference table */
reference_table = g_hash_table_new_full(g_str_hash,
g_str_equal,
g_free,
(GDestroyNotify)gtk_tree_row_reference_free);
- /* initialize the view */
view = gnac_ui_get_widget("file_list");
gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(view), COL_TOOLTIP);
- /* This piece of code can be called if we want more complex tooltips
- * Note that we must adapt gnac_file_list_tooltip_cb
- *
- * g_object_set (view, "has-tooltip", TRUE, NULL);
- * g_signal_connect (view, "query-tooltip",
- * G_CALLBACK (gnac_file_list_tooltip_cb), NULL);
- */
-
- /* initialize the model */
-
model = GTK_TREE_MODEL(gtk_list_store_new(NUM_COLS,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING));
renderer = gtk_cell_renderer_pixbuf_new();
- //g_object_set(G_OBJECT(renderer), "stock-size", 16, NULL);
gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view),
-1,
"Status",
@@ -224,11 +176,9 @@ gnac_file_list_new(void)
column = gtk_tree_view_get_column(GTK_TREE_VIEW(view),COL_STOCK);
gtk_tree_view_column_set_visible(column, FALSE);
- /* Connect signals */
g_signal_connect(G_OBJECT(model), "row-inserted",
G_CALLBACK(gnac_file_list_on_row_inserted_cb), NULL);
- /* configure selection */
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
g_signal_connect(G_OBJECT(selection), "changed",
@@ -260,6 +210,7 @@ gnac_file_list_get_selection(void)
return selection;
}
+
void
gnac_file_list_attach_default_model(gboolean attach)
{
@@ -272,6 +223,7 @@ gnac_file_list_attach_default_model(gboolean attach)
}
}
+
void
gnac_file_list_add_row(const gchar *uri)
{
@@ -421,29 +373,6 @@ gnac_file_list_get_selected_rows(void)
}
-/*
- * XXX this function is never used
- * Sets reference to the currently selected row. If multiples row are selected,
- * sets reference to the first row of the selection.
- */
-/*static gboolean
-gnac_file_list_get_first_row(GtkTreeRowReference **reference)
-{
- GtkTreePath *first_path;
-
- first_path = gtk_tree_path_new_first();
- if (*reference) {
- gtk_tree_row_reference_free(*reference);
- }
-
- *reference = gtk_tree_row_reference_new(model, first_path);
-
- gtk_tree_path_free(first_path);
-
- return gtk_tree_row_reference_valid(*reference);
-}*/
-
-
gboolean
gnac_file_list_get_current_row(GtkTreeRowReference **reference)
{
@@ -585,6 +514,7 @@ gnac_file_list_select_row_and_follow(GtkTreeRowReference *reference)
gtk_tree_path_free(path);
}
+
void
gnac_file_list_select_uri_and_follow(const gchar *uri)
{
@@ -690,37 +620,29 @@ gnac_file_list_on_button_pressed(GtkWidget *treeview,
GdkEventButton *event,
gpointer user_data)
{
- gboolean expanded;
+ gboolean row_exists;
gboolean ret = FALSE;
GtkTreePath *path;
- expanded = gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),
+ row_exists = gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),
(gint) event->x, (gint) event->y, &path, NULL, NULL, NULL);
- /* double click */
- if (event->type == GDK_2BUTTON_PRESS)
+ if (gnac_utils_event_is_double_left_click(event) && !row_exists)
{
- /* left click on an empty line */
- if (event->button == 1 && !expanded) {
- gnac_ui_on_add_cb(NULL, NULL);
- ret = TRUE;
- }
+ gnac_ui_on_add_cb(NULL, NULL);
+ ret = TRUE;
}
- /* single click */
- else if (event->type == GDK_BUTTON_PRESS)
+ else if (gnac_utils_event_is_single_right_click(event))
{
- /* right click */
- if (event->button == 3) {
- if (expanded && gnac_file_list_count_selected_rows() <= 1) {
- GtkTreeRowReference *reference;
- reference = gtk_tree_row_reference_new(model, path);
- gnac_file_list_select_row(reference);
- gtk_tree_row_reference_free(reference);
- }
-
- gnac_ui_show_popup_menu(treeview, event, user_data);
- ret = TRUE;
+ if (row_exists && gnac_file_list_count_selected_rows() <= 1) {
+ GtkTreeRowReference *reference;
+ reference = gtk_tree_row_reference_new(model, path);
+ gnac_file_list_select_row(reference);
+ gtk_tree_row_reference_free(reference);
}
+
+ gnac_ui_show_popup_menu(treeview, event, user_data);
+ ret = TRUE;
}
gtk_tree_path_free(path);
@@ -752,36 +674,9 @@ gnac_file_list_update_cursor(void)
}
-/* XXX this function is never used */
-/*void
-gnac_file_list_display_uri(GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
-{
- GError *err = NULL;
- gchar *uri = NULL;
- gchar *name = NULL;
-
- gtk_tree_model_get(tree_model, iter, COL_URI, &uri, -1);
-
- name = (gchar *)gnac_utils_get_display_name(uri, &err);
- if (err != NULL) {
- g_clear_error(&err);
- return;
- }
- g_object_set(G_OBJECT(cell), "text", name, NULL);
-}*/
-
-
void
gnac_file_list_destroy(void)
{
-
- // if (model)
- // g_object_unref(model);
-
if (reference_table ) {
g_hash_table_unref(reference_table);
reference_table = NULL;
diff --git a/src/gnac-file-list.h b/src/gnac-file-list.h
index 5b13331..1c71496 100644
--- a/src/gnac-file-list.h
+++ b/src/gnac-file-list.h
@@ -67,7 +67,7 @@ gnac_file_list_remove_row(const gchar *uri);
void
gnac_file_list_remove_all(void);
-gint
+guint
gnac_file_list_count_rows(void);
GList *
diff --git a/src/gnac-main.c b/src/gnac-main.c
index 81f8814..da2ea1a 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <gio/gio.h>
#include <glib/gi18n.h>
@@ -54,15 +54,15 @@
static gboolean conversion_errors = FALSE;
-static guint64 prev_time_left = -1;
-//volatile?
static gboolean continue_files_action;
static gboolean quit_app = FALSE;
-static GThread *file_action_thread = NULL;
static gboolean overwrite = FALSE;
static gboolean remember_overwrite = FALSE;
-gint nb_files_total;
-guint nb_files_added;
+static GThread *file_action_thread = NULL;
+static guint64 prev_time_left = -1;
+
+guint nb_files_added;
+guint nb_files_total;
GnacState state = GNAC_AUDIO_EMPTY_STATE;
GnacState prev_state = GNAC_AUDIO_EMPTY_STATE;
@@ -113,10 +113,6 @@ gnac_change_state(GnacState new_state)
gnac_utils_moving_avg_reset();
break;
- case GNAC_AUDIO_CLEAR_STATE:
- // TODO do stg?
- break;
-
case GNAC_AUDIO_CONVERT_STATE:
gnac_ui_on_audio_convert_state();
break;
@@ -129,7 +125,10 @@ gnac_change_state(GnacState new_state)
gnac_bars_on_plugin_install();
break;
- default:
+ case GNAC_AUDIO_CLEAR_STATE:
+ break;
+
+ default:
/* does nothing */
break;
@@ -301,7 +300,6 @@ gnac_add_file(GFile *file)
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
G_FILE_QUERY_INFO_NONE, NULL, &error);
if (error) {
- /* Error adding file */
libgnac_debug("Unable to query file info");
g_clear_error(&error);
g_free(uri);
@@ -311,16 +309,9 @@ gnac_add_file(GFile *file)
mime_type = g_file_info_get_content_type(info);
if (mime_type) {
- /* Check whether we have a playlist */
if (gnac_playlist_is_mime_playlist(mime_type)) {
gnac_playlist_parse(file, mime_type);
- /* Check whether the file format is supported */
- } else if (g_str_has_prefix(mime_type, "audio/") ||
- g_str_has_prefix(mime_type, "video/") ||
- g_str_equal(mime_type, "application/ogg") ||
- g_str_equal(mime_type, "application/vnd.rn-realmedia") ||
- g_str_equal(mime_type, "application/x-shockwave-flash"))
- {
+ } else if (gnac_utils_file_format_is_supported(mime_type)) {
libgnac_info("Add file %s", uri);
libgnac_converter_add(converter, file, &error);
}
@@ -393,7 +384,6 @@ gnac_on_ui_destroy_cb(GtkWidget *widget,
case GNAC_PLUGIN_INSTALL_STATE:
return TRUE;
- /* Ask the user for confirmation */
case GNAC_AUDIO_CONVERT_STATE:
case GNAC_AUDIO_PAUSED_STATE: {
GError *error = NULL;
@@ -408,7 +398,6 @@ gnac_on_ui_destroy_cb(GtkWidget *widget,
case GNAC_AUDIO_FILE_ACTION_STATE: {
GThread *thread = NULL;
- //TODO atomicity?
if (file_action_thread != NULL) {
thread = file_action_thread;
quit_app = TRUE;
@@ -431,7 +420,6 @@ gnac_on_ui_destroy_cb(GtkWidget *widget,
gnac_ui_destroy();
- /* only call 'gtk_main_quit' if the main loop is running */
if (gtk_main_level() != 0) gtk_main_quit();
return FALSE;
@@ -540,29 +528,8 @@ static void
gnac_on_converter_file_added_cb(LibgnacConverter *converter,
const gchar *uri)
{
- //GError *error = NULL;
- //GFile *file;
- //GFileMonitor *monitor;
++nb_files_added;
gnac_file_list_add_row(uri);
-
- // TODO hashtable to cancel monitor when file deletion on file-list
- /*
- file = g_file_new_for_uri(uri);
- monitor = g_file_monitor_file(file,
- G_FILE_MONITOR_NONE,
- NULL, &error);
- if (error) {
- g_printerr(_("An error occured creating a file monitor"));
- g_clear_error(&error);
- return;
- }
-
- g_signal_connect(G_OBJECT(monitor),
- "changed", G_CALLBACK(gnac_on_file_monitor_changed_cb), NULL);
-
- g_object_unref(file);
- */
}
@@ -687,9 +654,9 @@ gnac_on_converter_stopped_cb(LibgnacConverter *converter)
static void
gnac_on_converter_plugin_install_cb(LibgnacConverter *converter,
- gboolean done)
+ gboolean installed)
{
- if (done) {
+ if (installed) {
gnac_bars_on_plugin_installed();
gnac_change_state(GNAC_AUDIO_CONVERT_STATE);
} else {
@@ -744,7 +711,6 @@ gnac_on_ui_pause_cb(GtkWidget *widget,
if (error)
{
- /* do something with the error... */
g_clear_error(&error);
}
}
@@ -806,28 +772,6 @@ gnac_on_ui_convert_cb(GtkWidget *widget,
}
-/*static void
-gnac_on_file_monitor_changed_cb(GFileMonitor *monitor,
- GFile *file,
- GFile *other_file,
- GFileMonitorEvent event_type,
- gpointer user_data)
-{
- GError *error = NULL;
-
- if (event_type == G_FILE_MONITOR_EVENT_DELETED)
- {
- libgnac_converter_remove(converter, file, &error);
- g_object_unref(monitor);
- if (error) {
- g_error(_("An error occured on file monitor suppression"));
- g_clear_error(&error);
- return;
- }
- }
-}*/
-
-
gint
main(gint argc,
gchar **argv)
@@ -837,25 +781,21 @@ main(gint argc,
g_type_init();
#ifdef ENABLE_NLS
- /* Internationalization */
bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
- #endif /* ENABLE_NLS */
+ #endif
- /* Set a name for the application */
g_set_application_name(PACKAGE_NAME);
- /* Initialisation of gsettings */
settings = g_settings_new(GNAC_SCHEMA);
/* Parse command line arguments */
gnac_options_init(argc, argv);
- /* Initialisation of libraries */
gdk_threads_init();
- /* Init gstreamer plugins helper (XXX should be moved to libgnac) */
+ /* Init gstreamer plugins helper */
gst_pb_utils_init();
gnac_ui_init();
diff --git a/src/gnac-main.h b/src/gnac-main.h
index b4ccc47..9063652 100644
--- a/src/gnac-main.h
+++ b/src/gnac-main.h
@@ -44,8 +44,6 @@
G_BEGIN_DECLS
-extern LibgnacConverter *converter;
-
typedef enum {
GNAC_AUDIO_EMPTY_STATE,
GNAC_AUDIO_FILE_ACTION_STATE,
@@ -56,8 +54,12 @@ typedef enum {
GNAC_PLUGIN_INSTALL_STATE
} GnacState;
+extern GnacState state;
extern GSettings *settings;
-extern GSettings *settings_ui;
+extern guint nb_files_added;
+extern guint nb_files_total;
+extern LibgnacConverter *converter;
+extern LibgnacMetadata *metadata;
void
gnac_add_file(GFile *file);
@@ -98,13 +100,6 @@ gboolean
gnac_on_ui_destroy_cb(GtkWidget *widget,
gpointer data);
-//void
-//gnac_on_file_monitor_changed_cb(GFileMonitor *monitor,
-// GFile *file,
-// GFile *other_file,
-// GFileMonitorEvent event_type,
-// gpointer user_data);
-
G_END_DECLS
#endif /* GNAC_MAIN_H */
diff --git a/src/gnac-options.c b/src/gnac-options.c
index 1fa2a88..26a2547 100644
--- a/src/gnac-options.c
+++ b/src/gnac-options.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <glib/gi18n.h>
@@ -155,8 +155,8 @@ gnac_options_process_filenames(gchar **filenames)
GSList *list_files = NULL;
if (filenames) {
- gint i, len;
GFile *uri;
+ guint i, len;
len = g_strv_length(filenames);
diff --git a/src/gnac-options.h b/src/gnac-options.h
index cdcae43..c1a7db4 100644
--- a/src/gnac-options.h
+++ b/src/gnac-options.h
@@ -42,9 +42,6 @@ void
gnac_options_init(gint argc,
gchar **argv);
-//void
-//gnac_options_process_early(void);
-
void
gnac_options_process_late(void);
diff --git a/src/gnac-playlist.c b/src/gnac-playlist.c
index 329c467..b33d1e8 100755
--- a/src/gnac-playlist.c
+++ b/src/gnac-playlist.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <gio/gio.h>
#include <glib.h>
@@ -125,10 +125,10 @@ gnac_playlist_parse_m3u(GFile *file)
if (contents) {
+ guint i;
gchar **lines;
lines = g_strsplit(contents, "\n", -1);
- gint i;
for (i = 0; lines[i]; i++) {
/* skip comments and empty lines */
if (!*lines[i] || *lines[i] == '#') continue;
@@ -153,10 +153,10 @@ gnac_playlist_parse_pls(GFile *file)
if (contents) {
+ guint i;
gchar **lines;
lines = g_strsplit(contents, "\n", -1);
- gint i;
for (i = 0; lines[i]; i++) {
/* skip empty lines */
if (!*lines[i]) continue;
@@ -190,10 +190,10 @@ gnac_playlist_parse_xspf(GFile *file)
if (contents) {
+ guint i;
gchar **lines;
lines = g_strsplit(contents, "\n", -1);
- gint i;
for (i = 0; lines[i]; i++) {
/* skip empty lines */
if (!*lines[i]) continue;
diff --git a/src/gnac-prefs.c b/src/gnac-prefs.c
index d5e2e08..bec96de 100644
--- a/src/gnac-prefs.c
+++ b/src/gnac-prefs.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <glib/gi18n.h>
@@ -234,7 +234,6 @@ gnac_prefs_retrieve_settings(void)
g_free(str);
switch (folder_type)
{
- /* Subfolder */
case FOLDER_SUBDIRECTORY:
check_button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(
gnac_prefs_builder, "subfolder_radiobutton"));
@@ -247,7 +246,6 @@ gnac_prefs_retrieve_settings(void)
gnac_prefs_set_subfolder_mode();
break;
- /* Selected folder */
case FOLDER_SELECTED:
check_button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(
gnac_prefs_builder, "selected_radiobutton"));
@@ -613,12 +611,8 @@ gnac_prefs_query_tooltip_cb(GtkWidget *entry,
GtkTooltip *tooltip,
gpointer user_data)
{
- //if (GTK_WIDGET_IS_SENSITIVE(entry))
- //{
- gtk_tooltip_set_markup(tooltip, gnac_prefs_get_tooltip_patterns());
- return TRUE;
- //}
- //return FALSE;
+ gtk_tooltip_set_markup(tooltip, gnac_prefs_get_tooltip_patterns());
+ return TRUE;
}
@@ -626,7 +620,7 @@ void
gnac_prefs_window_hide(void)
{
if (gnac_prefs_window) {
- gtk_widget_hide_all(gnac_prefs_window);
+ gtk_widget_hide(gnac_prefs_window);
}
}
diff --git a/src/gnac-properties.c b/src/gnac-properties.c
index 42377db..61bf661 100644
--- a/src/gnac-properties.c
+++ b/src/gnac-properties.c
@@ -25,12 +25,12 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <glib/gi18n.h>
-#include <gst/gst.h>
#include "gnac-file-list.h"
+#include "gnac-main.h"
#include "gnac-properties.h"
#include "gnac-ui.h"
#include "gnac-utils.h"
@@ -54,6 +54,12 @@ gnac_properties_set_property(const gchar *name,
const GValue *value);
static void
+gnac_properties_update_forward_arrow(void);
+
+static void
+gnac_properties_update_backward_arrow(void);
+
+static void
gnac_properties_reset_spin_if_empty(const gchar *name);
@@ -105,9 +111,6 @@ static const gchar *displayed_properties[][2] = {
{ NULL, NULL }
};
-
-extern LibgnacMetadata *metadata;
-
static LibgnacTags *tags;
@@ -116,11 +119,8 @@ gnac_properties_visible_func(GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
- /* Visible if PROPERTY_VISIBLE is true */
gboolean visible;
-
- gtk_tree_model_get (model, iter, PROPERTY_VISIBLE, &visible, -1);
-
+ gtk_tree_model_get(model, iter, PROPERTY_VISIBLE, &visible, -1);
return visible;
}
@@ -134,7 +134,7 @@ gnac_properties_build_table(void)
GtkTreeRowReference *ref = NULL;
GtkTreeIter iter;
- gint i;
+ guint i;
model = GTK_TREE_MODEL(gtk_builder_get_object(gnac_properties_builder,
"properties_store"));
@@ -199,7 +199,7 @@ gnac_properties_build_table(void)
static void
gnac_properties_reset_properties(void)
{
- gint i;
+ guint i;
/* reset the basic tab */
for (i = 0; displayed_tags[i]; i++) {
@@ -224,10 +224,9 @@ gnac_properties_set_property(const gchar *name,
GtkTreePath *path;
gboolean visible = TRUE;
- if (value) {
- str_value = gnac_properties_get_property_from_value(name, value);
- if (!str_value) visible = FALSE;
- } else visible = FALSE;
+ if (value) str_value = gnac_properties_get_property_from_value(name, value);
+
+ if (!str_value) visible = FALSE;
model = GTK_TREE_MODEL(gtk_builder_get_object(gnac_properties_builder,
"properties_store"));
@@ -430,7 +429,6 @@ gnac_properties_window_new(void)
gtk_builder_connect_signals(gnac_properties_builder, NULL);
- /* Build properties table */
gnac_properties_build_table();
properties_window = GTK_WIDGET(gtk_builder_get_object(gnac_properties_builder,
@@ -465,20 +463,35 @@ gnac_properties_update_display(GFile *file)
void
gnac_properties_update_arrows(void)
{
- if (backward_arrow && forward_arrow && current_ref)
- {
- /* forward arrow */
- if (gnac_file_list_has_next_row(current_ref)) {
- gtk_widget_set_sensitive(forward_arrow, TRUE);
- } else {
- gtk_widget_set_sensitive(forward_arrow, FALSE);
- }
- /* backward arrow */
- if (gnac_file_list_has_prev_row(current_ref)) {
- gtk_widget_set_sensitive(backward_arrow, TRUE);
- } else {
- gtk_widget_set_sensitive(backward_arrow, FALSE);
- }
+ if (current_ref) {
+ gnac_properties_update_forward_arrow();
+ gnac_properties_update_backward_arrow();
+ }
+}
+
+
+static void
+gnac_properties_update_forward_arrow(void)
+{
+ g_return_if_fail(forward_arrow);
+
+ if (gnac_file_list_has_next_row(current_ref)) {
+ gtk_widget_set_sensitive(forward_arrow, TRUE);
+ } else {
+ gtk_widget_set_sensitive(forward_arrow, FALSE);
+ }
+}
+
+
+static void
+gnac_properties_update_backward_arrow(void)
+{
+ g_return_if_fail(backward_arrow);
+
+ if (gnac_file_list_has_prev_row(current_ref)) {
+ gtk_widget_set_sensitive(backward_arrow, TRUE);
+ } else {
+ gtk_widget_set_sensitive(backward_arrow, FALSE);
}
}
@@ -544,7 +557,7 @@ void
gnac_properties_window_hide(void)
{
if (gnac_properties_window) {
- gtk_widget_hide_all(gnac_properties_window);
+ gtk_widget_hide(gnac_properties_window);
properties_displayed = FALSE;
}
}
diff --git a/src/gnac-stock-items.c b/src/gnac-stock-items.c
index a35ea5e..a158b3e 100644
--- a/src/gnac-stock-items.c
+++ b/src/gnac-stock-items.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <glib.h>
#include <glib/gi18n.h>
@@ -43,7 +43,7 @@ static void
gnac_stock_items_register_icons(void)
{
GtkIconFactory *factory;
- guint i = 0;
+ guint i;
gtk_stock_add(gnac_stock_items, G_N_ELEMENTS(gnac_stock_items));
diff --git a/src/gnac-ui.c b/src/gnac-ui.c
index 720b6bd..81ccec9 100644
--- a/src/gnac-ui.c
+++ b/src/gnac-ui.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
@@ -33,11 +33,11 @@
#ifdef HAVE_LIBNOTIFY
#include <libnotify/notify.h>
-#endif /* HAVE_LIBNOTIFY */
+#endif
#ifdef HAVE_LIBUNIQUE
#include <unique/unique.h>
-#endif /* HAVE_LIBUNIQUE */
+#endif
#include "gnac-bars.h"
#include "gnac-file-list.h"
@@ -51,10 +51,6 @@
#include "libgnac-debug.h"
#include "profiles/gnac-profiles.h"
-extern GnacState state;
-extern guint nb_files_added;
-extern LibgnacMetadata *metadata;
-
GSettings *settings_ui;
static GSList *filters;
@@ -91,33 +87,6 @@ enum {
#endif /* HAVE_LIBUNIQUE */
static void
-gnac_about_url_hook(GtkAboutDialog *dialog,
- const gchar *url,
- gpointer user_data)
-{
- GError *error = NULL;
- if (!gtk_show_uri(gtk_widget_get_screen(GTK_WIDGET(dialog)),
- url, gtk_get_current_event_time(), &error))
- {
- g_warning(_("Could not open link %s: %s"), url, error->message);
- g_error_free(error);
- }
-}
-
-
-static void
-gnac_about_email_hook(GtkAboutDialog *dialog,
- const gchar *email_address,
- gpointer user_data)
-{
- gchar *uri;
- uri = g_strdup_printf("mailto:%s", email_address);
- gnac_about_url_hook(dialog, uri, user_data);
- g_free(uri);
-}
-
-
-static void
gnac_ui_file_chooser_unref_filters(void)
{
GSList *f;
@@ -565,10 +534,8 @@ gnac_ui_file_chooser_response_cb(GtkDialog *dialog,
g_slist_foreach(list_path,(GFunc) gnac_ui_file_chooser_foreach,
(gpointer)&list_files);
- /* free the list */
g_slist_free(list_path);
- /* add files */
gnac_add_files(list_files);
/* Do we have to close de file chooser? */
@@ -630,13 +597,8 @@ gnac_ui_new(void)
}
g_assert (err == NULL && gnac_main_builder != NULL);
- /* make sure every window has an icon */
gtk_window_set_default_icon_name(PACKAGE);
- /* make the links clickable */
- gtk_about_dialog_set_url_hook(gnac_about_url_hook, NULL, NULL);
- gtk_about_dialog_set_email_hook(gnac_about_email_hook, NULL, NULL);
-
file_list = gnac_file_list_new();
/* Add audio profile combo box */
@@ -802,8 +764,7 @@ gnac_ui_notify(const gchar *msg)
NotifyNotification *notification;
- notification = notify_notification_new(PACKAGE_NAME, msg, PACKAGE, NULL);
- notify_notification_attach_to_status_icon(notification, trayicon);
+ notification = notify_notification_new(PACKAGE_NAME, msg, PACKAGE);
notify_notification_set_timeout(notification, NOTIFY_EXPIRES_DEFAULT);
notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL);
@@ -846,6 +807,21 @@ gnac_ui_show_about_dialog(void)
}
+void
+gnac_about_url_hook(GtkAboutDialog *dialog,
+ const gchar *url,
+ gpointer user_data)
+{
+ GError *error = NULL;
+ if (!gtk_show_uri(gtk_widget_get_screen(GTK_WIDGET(dialog)),
+ url, gtk_get_current_event_time(), &error))
+ {
+ g_warning(_("Could not open link %s: %s"), url, error->message);
+ g_error_free(error);
+ }
+}
+
+
GtkWidget *
gnac_ui_get_widget(const gchar *widget_name)
{
@@ -1032,8 +1008,6 @@ gnac_ui_on_drag_data_received_cb(GtkWidget *widget,
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;
@@ -1103,7 +1077,7 @@ gnac_ui_init_notify(void)
{
#ifdef HAVE_LIBNOTIFY
notify_init(PACKAGE_NAME);
-#endif /* HAVE_LIBNOTIFY */
+#endif
}
@@ -1196,7 +1170,7 @@ gnac_ui_show(void)
#ifdef HAVE_LIBUNIQUE
unique_app_watch_window(app, GTK_WINDOW(main_window));
-#endif /* HAVE_LIBUNIQUE */
+#endif
gtk_widget_show_all(main_window);
@@ -1406,7 +1380,7 @@ gnac_ui_on_trayicon(GtkStatusIcon *trayicon,
if (window_displayed) {
gtk_window_get_position(GTK_WINDOW(main_window), &root_x, &root_y);
- gtk_widget_hide_all(main_window);
+ gtk_widget_hide(main_window);
} else {
gtk_widget_show_all(main_window);
gtk_window_move(GTK_WINDOW(main_window), root_x, root_y);
@@ -1430,7 +1404,6 @@ gnac_ui_on_trayicon_popup(GtkStatusIcon *trayicon,
GtkWidget *main_window;
GtkWidget *trayicon_menu;
- /* get the widgets */
main_window = gnac_ui_get_widget("main_window");
show_action = gnac_ui_get_action("tray_show_hide_item");
trayicon_menu = gnac_ui_get_widget("tray_popup");
@@ -1444,7 +1417,6 @@ gnac_ui_on_trayicon_popup(GtkStatusIcon *trayicon,
gtk_menu_popup(GTK_MENU(trayicon_menu), NULL, NULL, NULL, NULL,
button, activate_time);
- /* cleanup */
g_free(label_text);
}
diff --git a/src/gnac-ui.h b/src/gnac-ui.h
index 27e1da2..53029d2 100644
--- a/src/gnac-ui.h
+++ b/src/gnac-ui.h
@@ -74,6 +74,11 @@ void
gnac_ui_show_about_dialog(void);
void
+gnac_about_url_hook(GtkAboutDialog *dialog,
+ const gchar *url,
+ gpointer user_data);
+
+void
gnac_ui_reset_file_filter(void);
GtkWidget *
diff --git a/src/gnac-utils.c b/src/gnac-utils.c
index 9fd5930..38269f5 100644
--- a/src/gnac-utils.c
+++ b/src/gnac-utils.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <gio/gio.h>
#include <glib.h>
@@ -46,7 +46,7 @@ gnac_utils_get_display_name(const gchar *uri,
GError *err = NULL;
GFile *file;
GFileInfo *info;
- gchar *display_name;
+ gchar *display_name;
g_return_val_if_fail(!error || !*error, NULL);
@@ -60,8 +60,10 @@ gnac_utils_get_display_name(const gchar *uri,
}
display_name = g_strdup(g_file_info_get_display_name(info));
+
g_object_unref(info);
g_object_unref(file);
+
return display_name;
}
@@ -109,8 +111,6 @@ gnac_utils_moving_avg_reset(void)
}
-/* FIXME not really efficient (although in our case we only
- * have combos with less than 10 elements) */
gint
gnac_utils_get_combo_size(GtkComboBox *combo)
{
@@ -194,7 +194,7 @@ gnac_utils_get_filenames_from_cmd_line(gchar **argv)
array = g_ptr_array_new();
if (argv) {
- gint i;
+ guint i;
for (i = 0; argv[i]; i++) {
GFile *file;
@@ -213,3 +213,58 @@ gnac_utils_get_filenames_from_cmd_line(gchar **argv)
return (gchar**) g_ptr_array_free(array, FALSE);
}
+
+
+gboolean
+gnac_utils_file_format_is_supported(const gchar *mime_type)
+{
+ return g_str_has_prefix(mime_type, "audio/") ||
+ g_str_has_prefix(mime_type, "video/") ||
+ g_str_equal(mime_type, "application/ogg") ||
+ g_str_equal(mime_type, "application/vnd.rn-realmedia") ||
+ g_str_equal(mime_type, "application/x-shockwave-flash");
+}
+
+
+static gboolean
+gnac_utils_event_is_double_click(GdkEventButton *event)
+{
+ return event->type == GDK_2BUTTON_PRESS;
+}
+
+
+static gboolean
+gnac_utils_event_is_single_click(GdkEventButton *event)
+{
+ return event->type == GDK_BUTTON_PRESS;
+}
+
+
+static gboolean
+gnac_utils_event_is_left_click(GdkEventButton *event)
+{
+ return event->button == 1;
+}
+
+
+static gboolean
+gnac_utils_event_is_right_click(GdkEventButton *event)
+{
+ return event->button == 3;
+}
+
+
+gboolean
+gnac_utils_event_is_double_left_click(GdkEventButton *event)
+{
+ return gnac_utils_event_is_double_click(event) &&
+ gnac_utils_event_is_left_click(event);
+}
+
+
+gboolean
+gnac_utils_event_is_single_right_click(GdkEventButton *event)
+{
+ return gnac_utils_event_is_single_click(event) &&
+ gnac_utils_event_is_right_click(event);
+}
diff --git a/src/gnac-utils.h b/src/gnac-utils.h
index 5a82ddd..74fcffc 100644
--- a/src/gnac-utils.h
+++ b/src/gnac-utils.h
@@ -60,6 +60,15 @@ gnac_utils_add_border_to_pixbuf(GdkPixbuf *pixbuf);
gchar **
gnac_utils_get_filenames_from_cmd_line(gchar **argv);
+gboolean
+gnac_utils_file_format_is_supported(const gchar *mime_type);
+
+gboolean
+gnac_utils_event_is_double_left_click(GdkEventButton *event);
+
+gboolean
+gnac_utils_event_is_single_right_click(GdkEventButton *event);
+
G_END_DECLS
#endif /* GNAC_UTILS_H */
diff --git a/src/profiles/formats/gnac-profiles-unknown.c b/src/profiles/formats/gnac-profiles-unknown.c
index 155fce7..51703e4 100644
--- a/src/profiles/formats/gnac-profiles-unknown.c
+++ b/src/profiles/formats/gnac-profiles-unknown.c
@@ -100,8 +100,6 @@ gnac_profiles_unknown_init(UpdateTextBufferFunc call_back)
widget = GTK_WIDGET(gtk_builder_get_object(unknown_bfi.builder,
"properties-alignment"));
- //g_object_ref (widget);
- //gtk_widget_unparent(widget);
g_signal_connect(G_OBJECT(widget), "hide",
G_CALLBACK(gnac_profiles_unknown_on_hide), NULL);
@@ -261,7 +259,6 @@ gnac_profiles_unknown_clean_up(void) {
widget = GTK_WIDGET(gtk_builder_get_object(unknown_bfi.builder,
"properties-alignment"));
- //gtk_widget_unref(widget);
if (unknown_bfi.pipeline != NULL) g_free(unknown_bfi.pipeline);
g_object_unref(unknown_bfi.builder);
gtk_widget_destroy(widget);
diff --git a/src/profiles/gnac-profiles-default.h b/src/profiles/gnac-profiles-default.h
index ce26b92..8772110 100755
--- a/src/profiles/gnac-profiles-default.h
+++ b/src/profiles/gnac-profiles-default.h
@@ -43,7 +43,6 @@ typedef const gchar *(*FormatModuleGetPluginName) (void);
typedef const gchar *(*FormatModuleGetDescription) (void);
typedef void (*FormatModuleCleanUp) (void);
-//Should be used only by unknown module
typedef void (*FormatModuleSetPipelineTextViewFunc) (GtkTextView*, GtkWidget*);
typedef struct {
diff --git a/src/profiles/gnac-profiles-manager.c b/src/profiles/gnac-profiles-manager.c
index be520e0..4c1a817 100644
--- a/src/profiles/gnac-profiles-manager.c
+++ b/src/profiles/gnac-profiles-manager.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <gdk/gdkkeysyms.h>
#include <gio/gio.h>
@@ -754,7 +754,7 @@ gnac_profiles_mgr_show_description_frame(gboolean show)
if (show) {
gtk_widget_show_all(widget);
} else {
- gtk_widget_hide_all(widget);
+ gtk_widget_hide(widget);
}
}
@@ -770,7 +770,7 @@ gnac_profiles_mgr_show_import_progressbar(gboolean show)
if (show) {
gtk_widget_show_all(widget);
} else {
- gtk_widget_hide_all(widget);
+ gtk_widget_hide(widget);
}
}
@@ -823,7 +823,7 @@ gnac_profiles_mgr_display_status_message(const gchar *ok,
"frame-status"));
if ((ok == NULL) && (error == NULL)) {
- gtk_widget_hide_all(frame_status);
+ gtk_widget_hide(frame_status);
} else {
gtk_widget_show_all(frame_status);
label_status_ok = GTK_WIDGET(gtk_builder_get_object(profiles_mgr_builder,
@@ -1256,7 +1256,6 @@ gnac_profiles_mgr_on_edit_profile(GtkWidget *widget,
gpointer old_profile;
gchar *formatted_name;
GList *selected;
- //gchar *message;
selected = gnac_profiles_mgr_get_selected_rows();
gnac_profiles_mgr_get((GtkTreeRowReference*)selected->data,
@@ -1310,7 +1309,6 @@ gnac_profiles_mgr_on_remove(GtkWidget *widget,
gnac_profiles_mgr_display_status_message(NULL, NULL);
- /* We can do this while selection is unique */
model = gtk_tree_row_reference_get_model(
(GtkTreeRowReference*)selected->data);
path = gtk_tree_row_reference_get_path(
@@ -1386,7 +1384,6 @@ gnac_profiles_mgr_on_treeselection_changed(void)
GtkWidget *widget;
selected = gnac_profiles_mgr_get_selected_rows();
- // When remove
if (selected != NULL) {
gchar *descr;
diff --git a/src/profiles/gnac-profiles-manager.h b/src/profiles/gnac-profiles-manager.h
index aa84653..b006f59 100644
--- a/src/profiles/gnac-profiles-manager.h
+++ b/src/profiles/gnac-profiles-manager.h
@@ -49,9 +49,6 @@ gnac_profiles_mgr_destroy(void);
void
gnac_profiles_mgr_show(void);
-
-// GtkBuilder handler
-
void
gnac_profiles_mgr_on_drag_data_received(GtkWidget *widget,
GdkDragContext *context,
diff --git a/src/profiles/gnac-profiles-properties.c b/src/profiles/gnac-profiles-properties.c
index 074876a..002a8ab 100644
--- a/src/profiles/gnac-profiles-properties.c
+++ b/src/profiles/gnac-profiles-properties.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <gdk/gdkkeysyms.h>
#include <gio/gio.h>
@@ -51,14 +51,14 @@
#ifdef G_OS_WIN32
static const guint nb_forbidden_chars = 11;
-//TODO put correct GDK key event
-static const gchar forbidden_chars[] = {'\\', '/', ':', '*', '?', '"',
- '<', '>', '|', '{', '}'};
+static const gchar forbidden_chars[] = {
+ '\\', '/', ':', '*', '?', '"', '<', '>', '|', '{', '}'
+};
static const gchar *forbidden_chars_string = "\\ / : * ? \" < > | { }";
#else
static const guint nb_forbidden_chars = 3;
-static const guint forbidden_chars_keys[] = {GDK_slash};
-static const gchar forbidden_chars[] = {'/','\n','\t'};
+static const guint forbidden_chars_keys[] = { GDK_KEY_slash };
+static const gchar forbidden_chars[] = { '/', '\n', '\t' };
static const gchar *forbidden_chars_string = " /, <return>, <tab>";
#endif
@@ -73,11 +73,8 @@ static FormatModuleGetFuncs formats_get_funcs[NB_PLUGINS] = {
gnac_profiles_wavpack_get_funcs
};
-//static WindowSize properties_window_size;
-
typedef struct {
FormatModuleFuncs funcs;
- //GModule *module;
GtkTreeRowReference *tree_ref;
} FormatModule;
@@ -91,13 +88,6 @@ static const gchar *current_profile_name;
static void
gnac_profiles_properties_init_format(void);
-/*
-static void
-gnac_profiles_properties_init_modules(void);
-
-static GList *
-gnac_profiles_properties_find_modules(void);*/
-
static void
gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
gpointer user_data);
@@ -152,7 +142,6 @@ gnac_profiles_properties_init(void)
hbox_properties = GTK_WIDGET(gtk_builder_get_object(
profiles_properties_builder, "hbox_properties"));
- // Set up combo format
combo_format = GTK_WIDGET(gtk_builder_get_object(profiles_properties_builder,
"format_combo_box"));
gtk_builder_connect_signals(profiles_properties_builder, NULL);
@@ -272,210 +261,6 @@ gnac_profiles_properties_init_format(void) {
}
-/*static void
-gnac_profiles_properties_init_modules(void)
-{
- GList *list;
- GList *temp;
- GModule *module;
- GtkWidget *widget;
- GtkWidget *format_combo_box;
- GtkWidget *hbox_properties;
- GtkListStore *model;
- GtkTreeIter iter;
- GtkTreePath *tree_path;
-
- hbox_properties = GTK_WIDGET(gtk_builder_get_object(
- profiles_properties_builder, "hbox_properties"));
-
- list = gnac_profiles_properties_find_modules();
- temp = list;
- format_combo_box = GTK_WIDGET(gtk_builder_get_object(
- profiles_properties_builder, "format_combo_box"));
- model = GTK_LIST_STORE(gtk_combo_box_get_model(
- GTK_COMBO_BOX(format_combo_box)));
-
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), 2,
- GTK_SORT_ASCENDING);
-
- while (temp != NULL) {
- module = g_module_open(temp->data, G_MODULE_BIND_LAZY);
- if (module == NULL) {
- libgnac_warning(_("Impossible to load format module %s"),
- (gchar*) temp->data);
- } else {
- FormatModule *format_module;
- FormatModuleFuncs *format_funcs;
- FormatModuleInitFunc module_init;
- FormatModuleGetComboFormatNameFunc get_combo_format_name;
- FormatModuleSetPipelineTextViewFunc set_pipeline_text_view;
- FormatModuleGetPluginName get_plugin_name;
- const gchar *format_id;
- const gchar *plugin_name;
- gchar *format_name;
- GstPlugin *plugin;
- GtkWidget *properties;
-
- g_module_symbol(module, "gnac_profiles_format_init",
- (gpointer*) &module_init);
- if (module_init) {
- format_id = module_init(gnac_profiles_properties_update_textbuffer);
-
- format_module = g_malloc(sizeof(FormatModule));
- format_module->module = module;
- format_funcs = &(format_module->funcs);
-
- g_module_symbol(module, "gnac_profiles_format_get_description",
- (gpointer*) &format_funcs->get_description);
- g_module_symbol(module, "gnac_profiles_format_generate_pipeline",
- (gpointer*) &format_funcs->generate_pipeline);
- g_module_symbol(module, "gnac_profiles_format_generate_audio_profile",
- (gpointer*) &format_funcs->generate_audio_profile);
- g_module_symbol(module, "gnac_profiles_format_free_audio_profile",
- (gpointer*) &format_funcs->free_audio_profile);
- g_module_symbol(module, "gnac_profiles_format_fullfill_fields",
- (gpointer*) &format_funcs->fullfill_fields);
- g_module_symbol(module, "gnac_profiles_format_get_widget",
- (gpointer*) &format_funcs->get_widget);
- g_module_symbol(module, "gnac_profiles_format_save_profile",
- (gpointer*) &format_funcs->save_profile_in_file);
- g_module_symbol(module, "gnac_profiles_format_load_specific_properties",
- (gpointer*) &format_funcs->load_specific_properties);
- g_module_symbol(module, "gnac_profiles_format_clean_up",
- (gpointer*) &format_funcs->clean_up);
-
- g_module_symbol(module, "gnac_profiles_format_get_plugin_name",
- (gpointer*) &get_plugin_name);
- plugin_name = get_plugin_name();
- plugin = gst_plugin_load_by_name(plugin_name);
- if (plugin != NULL) {
- g_hash_table_insert(formats, (gpointer) format_id, format_module);
-
- g_module_symbol(module, "gnac_profiles_format_get_combo_format_name",
- (gpointer*) &get_combo_format_name);
- format_name = get_combo_format_name();
-
- gtk_list_store_append(model, &iter);
- if (g_strcmp0(format_id, "custom-format")) {
- gtk_list_store_set(model, &iter,
- 0, format_name,
- 1, format_module,
- 2, format_name,
- -1);
- } else {
- // This is a big hack to be sure that Custom Format will be
- // at the end :-D
- gtk_list_store_set(model, &iter,
- 0, format_name,
- 1, format_module,
- 2, "ZZZZZZZZZZZZZZZZZZZ",
- -1);
- }
- tree_path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &iter);
- format_module->tree_ref = gtk_tree_row_reference_new(
- GTK_TREE_MODEL(model), tree_path);
- gtk_tree_path_free(tree_path);
- if (g_module_symbol(module,
- "gnac_profiles_format_set_pipeline_text_view",
- (gpointer*) &set_pipeline_text_view))
- {
- GtkWidget *pipeline_box;
-
- widget = GTK_WIDGET(gtk_builder_get_object(
- profiles_properties_builder, "gstreamer_pipeline_text_view"));
- pipeline_box = GTK_WIDGET(gtk_builder_get_object(
- profiles_properties_builder, "gstreamer_pipeline_box"));
- set_pipeline_text_view(GTK_TEXT_VIEW(widget), pipeline_box);
- }
-
- properties = format_funcs->get_widget(NULL);
- gtk_box_pack_start_defaults(GTK_BOX(hbox_properties), properties);
- gtk_widget_hide(properties);
- g_free(format_name);
- g_object_unref(G_OBJECT(plugin));
- } else {
- g_module_close(module);
- g_free(format_module);
- }
-
- } else {
- libgnac_warning(
- "Impossible to find format module init function for module %s",
- (gchar*) temp->data);
- }
- }
-
- temp = temp->next;
- }
-
- g_list_foreach(list, (GFunc) g_free ,NULL);
- g_list_free(list);
-}
-
-
-static GList *
-gnac_profiles_properties_find_modules(void)
-{
- GList *list = NULL;
- GFile *dir;
- GFileEnumerator *files;
- GFileInfo *file_info;
- GError *error = NULL;
-
- dir = g_file_new_for_path(PLUGINDIR);
- if (!g_file_query_exists(dir, NULL)) {
- libgnac_warning(_("The format modules directory does not exist"));
- g_error_free(error);
- }
-
- files = g_file_enumerate_children(dir,
- G_FILE_ATTRIBUTE_STANDARD_NAME ","
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
- G_FILE_ATTRIBUTE_STANDARD_TYPE,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &error);
-
- if (files != NULL) {
- while ((file_info = g_file_enumerator_next_file(files, NULL, NULL)) != NULL)
- {
- guint32 type;
- const gchar *content_type;
-
- type = g_file_info_get_file_type(file_info);
- content_type = g_file_info_get_content_type(file_info);
-
- if ((type == G_FILE_TYPE_REGULAR)
- && !g_strcmp0("application/x-sharedlib",content_type))
- {
- GFile *module;
- gchar *module_path;
- const gchar *module_name;
- gchar *module_full_path;
-
- module = g_file_enumerator_get_container(files);
- module_path = g_file_get_path(module);
- module_name = g_file_info_get_name(file_info);
- module_full_path = g_module_build_path(module_path, module_name);
- g_free(module_path);
- list = g_list_append(list, module_full_path);
- }
-
- g_object_unref(file_info);
- }
- } else {
- libgnac_warning("%s: %s",
- _("Unable to browse to format directory"),
- error->message);
- g_error_free(error);
- }
-
- g_object_unref(dir);
- g_file_enumerator_close(files, NULL, NULL);
- g_object_unref(files);
-
- return list;
-}*/
-
-
void
gnac_profiles_properties_show(gpointer profile,
const gchar *title,
@@ -512,21 +297,25 @@ gnac_profiles_properties_show(gpointer profile,
gtk_widget_show(widget);
gtk_combo_box_set_active(GTK_COMBO_BOX(format_combo_box), 0);
} else {
+ const gchar *format_id;
p = ((AudioProfileGeneric*)profile)->generic;
- format_module = g_hash_table_lookup(formats, p->format_id);
- if (format_module == NULL) {
- libgnac_warning(_("Format not supported"));
- } else {
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(format_combo_box));
- gnac_profiles_properties_name_description_set_text(p->name,
- p->description);
- format_module->funcs.fullfill_fields(profile);
- tree_path = gtk_tree_row_reference_get_path(format_module->tree_ref);
- gtk_tree_model_get_iter(model, &iter, tree_path);
- gtk_combo_box_set_active_iter(GTK_COMBO_BOX(format_combo_box), &iter);
- format_module->funcs.generate_pipeline(NULL);
- gtk_widget_show(widget);
- gtk_tree_path_free(tree_path);
+ format_id = p->format_id;
+ if (format_id) {
+ format_module = g_hash_table_lookup(formats, format_id);
+ if (format_module == NULL) {
+ libgnac_warning(_("Format not supported"));
+ } else {
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(format_combo_box));
+ gnac_profiles_properties_name_description_set_text(p->name,
+ p->description);
+ format_module->funcs.fullfill_fields(profile);
+ tree_path = gtk_tree_row_reference_get_path(format_module->tree_ref);
+ gtk_tree_model_get_iter(model, &iter, tree_path);
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(format_combo_box), &iter);
+ format_module->funcs.generate_pipeline(NULL);
+ gtk_widget_show(widget);
+ gtk_tree_path_free(tree_path);
+ }
}
}
}
@@ -536,14 +325,18 @@ void
gnac_profiles_properties_free_audio_profile(gpointer profile)
{
AudioProfileGeneric *p;
+ const gchar *format_id;
FormatModule *format_module;
p = ((AudioProfileGeneric*)profile)->generic;
- format_module = g_hash_table_lookup(formats, p->format_id);
- if (format_module == NULL) {
- libgnac_warning(_("Format not supported"));
- } else {
- format_module->funcs.free_audio_profile(profile);
+ format_id = p->format_id;
+ if (format_id) {
+ format_module = g_hash_table_lookup(formats, format_id);
+ if (format_module == NULL) {
+ libgnac_warning(_("Format not supported"));
+ } else {
+ format_module->funcs.free_audio_profile(profile);
+ }
}
}
@@ -561,7 +354,6 @@ gnac_profiles_properties_destroy(void)
for (temp = list; temp != NULL; temp = temp->next) {
format_module = ((FormatModule*)temp->data);
format_module->funcs.clean_up();
- //g_module_close(format_module->module);
g_free(format_module);
}
@@ -584,7 +376,6 @@ gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
gpointer user_data)
{
GtkWidget *properties;
- GtkWidget *hbox_properties;
GtkWidget *label;
GtkWidget *text_view;
GtkTreeModel *model;
@@ -596,7 +387,6 @@ gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
gtk_tree_model_get(model, &iter, 1, (gpointer*)&format_module, -1);
gnac_profiles_properties_display_status_message(NULL);
- hbox_properties = GTK_WIDGET(user_data);
if ((current_format_module != NULL)
&& (format_module != current_format_module))
@@ -655,7 +445,7 @@ gnac_profiles_properties_display_status_message(const gchar *error)
gtk_label_set_text(GTK_LABEL(widget), error);
} else {
- gtk_widget_hide_all(widget);
+ gtk_widget_hide(widget);
}
}
@@ -941,9 +731,11 @@ gnac_profiles_properties_save_profile(gpointer profile)
FormatModule *format_module;
format_id = ((AudioProfileGeneric*)profile)->generic->format_id;
- format_module = g_hash_table_lookup(formats, format_id);
- if (format_module != NULL) {
- format_module->funcs.save_profile_in_file(profile);
+ if (format_id) {
+ format_module = g_hash_table_lookup(formats, format_id);
+ if (format_module != NULL) {
+ format_module->funcs.save_profile_in_file(profile);
+ }
}
}
diff --git a/src/profiles/gnac-profiles-properties.h b/src/profiles/gnac-profiles-properties.h
index 499d757..53776c1 100644
--- a/src/profiles/gnac-profiles-properties.h
+++ b/src/profiles/gnac-profiles-properties.h
@@ -62,8 +62,6 @@ gnac_profiles_properties_saved_profiles_contain_name(const gchar *name,
void
gnac_profiles_properties_save_profile(gpointer profile);
-// GtkBuilder handler
-
void
gnac_profiles_properties_on_cancel(GtkWidget *widget,
gpointer data);
diff --git a/src/profiles/gnac-profiles-utils.c b/src/profiles/gnac-profiles-utils.c
index 2478a59..792dbdf 100755
--- a/src/profiles/gnac-profiles-utils.c
+++ b/src/profiles/gnac-profiles-utils.c
@@ -199,12 +199,6 @@ gnac_profiles_utils_register_slider(GtkWidget *widget,
gnac_profiles_utils_add_values_slider(widget, slider);
g_object_set_data(G_OBJECT(widget), "slider-values", slider);
g_signal_connect(G_OBJECT(widget), "value-changed", call_back, user_data);
- //g_signal_connect(G_OBJECT(widget), "button-release-event",
- // call_back, user_data);
- //g_signal_connect(G_OBJECT(widget), "key-release-event",
- // call_back, user_data);
- //g_signal_connect(G_OBJECT(widget), "leave-notify-event",
- // call_back, user_data);
} else {
libgnac_warning("Impossible to register slider with xpath query %s",
xpath_query);
@@ -284,23 +278,16 @@ void
gnac_profiles_utils_add_values_combo(GtkWidget *combo,
ComboValues *values)
{
- GtkTreeModel *model;
- GtkCellRenderer *renderer;
- GList *list_names;
- GList *list_values;
-
- model = GTK_TREE_MODEL(gtk_list_store_new(1, G_TYPE_STRING));
- renderer = gtk_cell_renderer_text_new();
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE);
- gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo),
- renderer, "text", 0, NULL);
- gtk_combo_box_set_model(GTK_COMBO_BOX(combo), model);
+ gint index = 0;
+
+ GList *list_names;
+ GList *list_values;
list_names = values->names;
list_values= values->values;
- gint index = 0;
+
while (list_names != NULL) {
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo),
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo),
(const gchar*) list_names->data);
if (!g_strcmp0(values->default_value, (const gchar*) list_values->data)) {
diff --git a/src/profiles/gnac-profiles-xml-engine.c b/src/profiles/gnac-profiles-xml-engine.c
index bb1eeb1..280d9d0 100755
--- a/src/profiles/gnac-profiles-xml-engine.c
+++ b/src/profiles/gnac-profiles-xml-engine.c
@@ -25,7 +25,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include <glib/gi18n.h>
#include <glib/gstdio.h>
@@ -103,7 +103,6 @@ gnac_profiles_xml_engine_get_text_node(XMLDoc *dx,
if ((nodes != NULL) && (nodes->nodeNr > 0)) {
xmlNodePtr node;
- //const xmlChar *content;
node = nodes->nodeTab[0];
if (node->children != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]