marlin r1310 - trunk/src
- From: iain svn gnome org
- To: svn-commits-list gnome org
- Subject: marlin r1310 - trunk/src
- Date: Sat, 11 Oct 2008 23:57:10 +0000 (UTC)
Author: iain
Date: Sat Oct 11 23:57:09 2008
New Revision: 1310
URL: http://svn.gnome.org/viewvc/marlin?rev=1310&view=rev
Log:
Load files into an empty window if one exists.
Fix memory leak by freeing selected filename
Modified:
trunk/src/ChangeLog
trunk/src/main.c
trunk/src/marlin-window.c
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Sat Oct 11 23:57:09 2008
@@ -181,7 +181,7 @@
{
static int sample_count = 1;
char *name;
-
+
if (sample_count != 1) {
name = g_strdup_printf ("Untitled-%d", sample_count);
} else {
@@ -209,9 +209,9 @@
g_object_set (G_OBJECT (window),
"sample", sample,
NULL);
-
+
g_object_unref (sample);
-
+
g_signal_connect (G_OBJECT (window), "delete-event",
G_CALLBACK (window_deleted), NULL);
g_signal_connect (G_OBJECT (window), "destroy",
@@ -237,7 +237,7 @@
MarlinWindow *window;
MarlinSample *sample;
int rate, channels;
-
+
/* Create a sample to be used in the window */
sample = marlin_sample_new ();
@@ -263,7 +263,7 @@
if (filename == NULL) {
char *name = make_window_name ();
-
+
g_object_set (G_OBJECT (sample),
"filename", name,
NULL);
@@ -357,7 +357,7 @@
if (n_toolbars <= 1) {
not_removable &= EGG_TB_MODEL_NOT_REMOVABLE;
}
-
+
for (i = 0; i < n_toolbars - 1; i++) {
egg_toolbars_model_set_flags (EGG_TOOLBARS_MODEL (model), not_removable, i);
}
@@ -368,9 +368,9 @@
{
if (tb_model == NULL) {
tb_model = EPHY_TOOLBARS_MODEL (ephy_toolbars_model_new ());
-
+
ephy_toolbars_model_load (tb_model);
-
+
g_signal_connect (G_OBJECT (tb_model), "toolbar_added",
G_CALLBACK (update_toolbar_remove_flag),
NULL);
@@ -419,7 +419,7 @@
/* Open a new window for each file */
for (i = 0; files[i]; i++) {
char *fullpath;
-
+
fullpath = make_full_path (files[i]);
marlin_open_window (fullpath, NULL, NULL, NULL);
g_free (fullpath);
@@ -518,12 +518,12 @@
add_signal_handlers ();
ensure_dirs_exist ();
-
+
/* Initialise GThread at the very start */
g_thread_init (NULL);
option_ctxt = g_option_context_new ("- Marlin");
- g_option_context_add_main_entries (option_ctxt, marlin_options,
+ g_option_context_add_main_entries (option_ctxt, marlin_options,
GETTEXT_PACKAGE);
g_option_context_add_group (option_ctxt, gst_init_get_option_group ());
g_option_context_set_ignore_unknown_options (option_ctxt, TRUE);
@@ -540,19 +540,19 @@
g_set_application_name (_("Marlin Sample Editor"));
g_log_set_handler ("Glib-GObject",
- G_LOG_LEVEL_CRITICAL |
+ G_LOG_LEVEL_CRITICAL |
G_LOG_LEVEL_ERROR |
G_LOG_FLAG_FATAL |
G_LOG_FLAG_RECURSION,
critical_handler, NULL);
g_log_set_handler ("Glib",
- G_LOG_LEVEL_CRITICAL |
+ G_LOG_LEVEL_CRITICAL |
G_LOG_LEVEL_ERROR |
G_LOG_FLAG_FATAL |
G_LOG_FLAG_RECURSION,
critical_handler, NULL);
g_log_set_handler (NULL,
- G_LOG_LEVEL_CRITICAL |
+ G_LOG_LEVEL_CRITICAL |
G_LOG_LEVEL_ERROR |
G_LOG_FLAG_FATAL |
G_LOG_FLAG_RECURSION,
@@ -581,7 +581,7 @@
unique_app_send_message (unique_app, UNIQUE_NEW, NULL);
} else {
int i;
-
+
for (i = 0; files[i]; i++) {
char *path;
@@ -590,7 +590,7 @@
path = make_full_path (files[i]);
unique_message_data_set_text (message, path, strlen (path));
- unique_app_send_message (unique_app,
+ unique_app_send_message (unique_app,
UNIQUE_OPEN, message);
g_free (path);
Modified: trunk/src/marlin-window.c
==============================================================================
--- trunk/src/marlin-window.c (original)
+++ trunk/src/marlin-window.c Sat Oct 11 23:57:09 2008
@@ -2891,7 +2891,7 @@
void
marlin_window_load_file (MarlinWindow *window,
- const char *filename)
+ const char *uri)
{
struct _load_op_data *lod;
MarlinOperation *operation;
@@ -2917,7 +2917,7 @@
lod->pipeline = (MarlinPipeline *) pipeline;
g_object_set (G_OBJECT (pipeline),
- "filename", filename,
+ "filename", uri,
"sample", window->priv->sample,
NULL);
@@ -3661,10 +3661,10 @@
}
g_free (directory);
g_object_unref (G_OBJECT (client));
-
+
g_signal_connect (G_OBJECT (sd->filesel), "response",
G_CALLBACK (file_sel_save_as_response), sd);
-
+
gtk_widget_show (sd->filesel);
}
@@ -3674,12 +3674,15 @@
};
static void
-file_sel_response (GtkDialog *filesel,
- int response_id,
+file_sel_response (GtkDialog *filesel,
+ int response_id,
struct _FileOpenData *fd)
{
- const char *name;
+ MarlinWindow *window = fd->window;
+ MarlinWindowPrivate *priv = fd->window->priv;
+ char *name;
char *dirname, *d;
+ guint64 n_frames;
switch (response_id) {
case GTK_RESPONSE_OK:
@@ -3687,18 +3690,30 @@
d = g_path_get_dirname (name);
/* Add a trailing / so that the file selector will cd into it */
dirname = g_strdup_printf ("%s/", d);
-
+
marlin_gconf_set_string ("/apps/marlin/system-state/open-file-directory", dirname);
g_free (dirname);
g_free (d);
-
- marlin_open_window (name, NULL, NULL, NULL);
+
+ g_object_get (priv->sample,
+ "total-frames", &n_frames,
+ NULL);
+ if (n_frames == 0) {
+ char *uri;
+
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (filesel));
+ /* Open the file in this window */
+ marlin_window_load_file (window, uri);
+ g_free (uri);
+ } else {
+ marlin_open_window (name, NULL, NULL, NULL);
+ }
+ g_free (name);
break;
case GTK_RESPONSE_CANCEL:
default:
break;
-
}
gtk_widget_destroy (GTK_WIDGET (filesel));
@@ -3716,12 +3731,12 @@
gdk_window_show (fd->filesel->window);
return;
}
-
+
fd = g_new (struct _FileOpenData, 1);
-
+
fd->window = window;
fd->filesel = (GtkWidget *) marlin_file_open_dialog_new (GTK_WINDOW (window));
-
+
directory = marlin_gconf_get_string ("/apps/marlin/system-state/open-file-directory");
if (directory != NULL &&
*directory != 0) {
@@ -3731,12 +3746,12 @@
#endif
g_free (directory);
}
-
+
g_signal_connect (G_OBJECT (fd->filesel), "response",
G_CALLBACK (file_sel_response), fd);
g_signal_connect (G_OBJECT (fd->filesel), "destroy",
G_CALLBACK (gtk_widget_destroyed), &fd);
-
+
gtk_widget_show (fd->filesel);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]