OSDN Git Service

LinGui: Activity Logs for individual encodes
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 31 Oct 2008 18:03:24 +0000 (18:03 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 31 Oct 2008 18:03:24 +0000 (18:03 +0000)
- Individual activity logs are saved in the file format
  "YYYY-MM-DD HH-MM-SS mymoviename.log".
- Default directory is <user config idr>/ghb/EncodeLogs
  (usually ~/.config/ghb/EncodeLogs)
- Preference available to alternatively put them in the users output
  movie directory with the output movie (by default set to "off").

git-svn-id: svn://localhost/HandBrake/trunk@1887 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/callbacks.c
gtk/src/ghb.ui
gtk/src/internal_defaults.xml
gtk/src/main.c
gtk/src/presets.c
gtk/src/presets.h
gtk/src/resource_data.h
gtk/src/resources.plist
gtk/src/settings.h

index 7e22de3..f79fbe2 100644 (file)
@@ -1423,10 +1423,52 @@ submit_job(GValue *settings)
 }
 
 static void
-queue_scan(GValue *js)
+queue_scan(signal_user_data_t *ud, GValue *js)
 {
        gchar *path;
        gint titlenum;
+       time_t  _now;
+       struct tm *now;
+       gchar *log_path, *pos, *destname, *basename, *dest_dir;
+
+       _now = time(NULL);
+       now = localtime(&_now);
+       destname = ghb_settings_get_string(js, "destination");
+       basename = g_path_get_basename(destname);
+       if (ghb_settings_get_boolean(ud->settings, "EncodeLogLocation"))
+       {
+               dest_dir = g_path_get_dirname (destname);
+       }
+       else
+       {
+               dest_dir = ghb_get_user_config_dir("EncodeLogs");
+       }
+       g_free(destname);
+       pos = g_strrstr( basename, "." );
+       if (pos != NULL)
+       {
+               *pos = 0;
+       }
+       log_path = g_strdup_printf("%s/%d-%02d-%02d %02d-%02d-%02d %s.log",
+               dest_dir,
+               now->tm_year + 1900, now->tm_mon + 1, now->tm_mday,
+               now->tm_hour, now->tm_min, now->tm_sec, basename);
+       g_free(basename);
+       g_free(dest_dir);
+       if (ud->job_activity_log)
+               g_io_channel_unref(ud->job_activity_log);
+       ud->job_activity_log = g_io_channel_new_file (log_path, "w", NULL);
+       if (ud->job_activity_log)
+       {
+               gchar *ver_str;
+
+               ver_str = g_strdup_printf("Handbrake Version: %s (%d)\n", 
+                                                                       HB_VERSION, HB_BUILD);
+               g_io_channel_write_chars (ud->job_activity_log, ver_str, 
+                                                                       -1, NULL, NULL);
+               g_free(ver_str);
+       }
+       g_free(log_path);
 
        path = ghb_settings_get_string( js, "source");
        titlenum = ghb_settings_get_int(js, "titlenum");
@@ -1455,7 +1497,7 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first)
                        if (status == GHB_QUEUE_PENDING)
                        {
                                current = ii;
-                               queue_scan(js);
+                               queue_scan(ud, js);
                                return js;
                        }
                }
@@ -1476,7 +1518,7 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first)
                                if (status == GHB_QUEUE_PENDING)
                                {
                                        current = jj;
-                                       queue_scan(js);
+                                       queue_scan(ud, js);
                                        return js;
                                }
                        }
@@ -1491,7 +1533,7 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first)
                if (status == GHB_QUEUE_PENDING)
                {
                        current = ii;
-                       queue_scan(js);
+                       queue_scan(ud, js);
                        return js;
                }
        }
@@ -1737,6 +1779,8 @@ ghb_backend_events(signal_user_data_t *ud)
                        ghb_settings_set_int(js, "job_status", qstatus);
                ghb_save_queue(ud->queue);
                ud->cancel_encode = FALSE;
+               g_io_channel_unref(ud->job_activity_log);
+               ud->job_activity_log = NULL;
        }
        else if (status.queue_state & GHB_STATE_MUXING)
        {
@@ -1870,7 +1914,11 @@ ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data)
                        mark = gtk_text_buffer_get_insert (buffer);
                        gtk_text_view_scroll_mark_onscreen(textview, mark);
                }
-               g_io_channel_write_chars (ud->activity_log, text, length, &length, NULL);
+               g_io_channel_write_chars (ud->activity_log, text, 
+                                                               length, &length, NULL);
+               if (ud->job_activity_log)
+                       g_io_channel_write_chars (ud->job_activity_log, text, 
+                                                                       length, &length, NULL);
                g_free(text);
        }
        if (status != G_IO_STATUS_NORMAL)
index 0f8baf8..67ed63d 100644 (file)
@@ -3472,6 +3472,22 @@ this setting.</property>
                           </packing>
                         </child>
                         <child>
+                          <object class="GtkCheckButton" id="EncodeLogLocation">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="tooltip_text"> HandBrake produces 2 activity logs.  
+One for the session and one for each encoding.
+Store the individual encode logs in the same
+location as the movie.</property>
+                            <property name="label" translatable="yes">Store logs in destination video directory</property>
+                            <property name="draw_indicator">True</property>
+                            <signal name="toggled" handler="pref_changed_cb"/>
+                          </object>
+                          <packing>
+                            <property name="position">5</property>
+                          </packing>
+                        </child>
+                        <child>
                           <object class="GtkCheckButton" id="allow_tweaks">
                             <property name="can_focus">True</property>
                             <property name="label" translatable="yes">Allow Tweaks</property>
@@ -3479,7 +3495,7 @@ this setting.</property>
                             <signal name="toggled" handler="tweaks_changed_cb"/>
                           </object>
                           <packing>
-                            <property name="position">5</property>
+                            <property name="position">6</property>
                           </packing>
                         </child>
                         <child>
@@ -3490,7 +3506,7 @@ this setting.</property>
                             <signal name="toggled" handler="hbfd_feature_changed_cb"/>
                           </object>
                           <packing>
-                            <property name="position">6</property>
+                            <property name="position">7</property>
                           </packing>
                         </child>
                       </object>
index 2820000..373f78a 100644 (file)
@@ -84,6 +84,8 @@
        </dict>
        <key>Preferences</key>
        <dict>
+               <key>EncodeLogLocation</key>
+               <false />
                <key>allow_tweaks</key>
                <false />
                <key>chapters_in_destination</key>
index d1a002a..d735384 100644 (file)
@@ -420,9 +420,10 @@ IoRedirect(signal_user_data_t *ud)
        }
        // Open activity log.
        // TODO: Put this in the same directory as the encode destination
-       config = ghb_get_user_config_dir();
+       config = ghb_get_user_config_dir(NULL);
        path = g_strdup_printf("%s/%s", config, "Activity.log");
        ud->activity_log = g_io_channel_new_file (path, "w", NULL);
+       ud->job_activity_log = NULL;
        ghb_ui_update(ud, "activity_location", ghb_string_value(path));
        g_free(path);
        g_free(config);
index cad74d7..0e40e6d 100644 (file)
@@ -1015,7 +1015,7 @@ ghb_select_default_preset(GtkBuilder *builder)
 }
 
 gchar*
-ghb_get_user_config_dir()
+ghb_get_user_config_dir(gchar *subdir)
 {
        const gchar *dir;
        gchar *config;
@@ -1034,6 +1034,23 @@ ghb_get_user_config_dir()
                if (!g_file_test(config, G_FILE_TEST_IS_DIR))
                        g_mkdir (config, 0755);
        }
+       if (subdir)
+       {
+               gchar **split;
+               gint ii;
+
+               split = g_strsplit(subdir, "/", -1);
+               for (ii = 0; split[ii] != NULL; ii++)
+               {
+                       gchar *tmp;
+
+                       tmp = g_strdup_printf ("%s/%s", config, split[ii]);
+                       g_free(config);
+                       config = tmp;
+                       if (!g_file_test(config, G_FILE_TEST_IS_DIR))
+                               g_mkdir (config, 0755);
+               }
+       }
        return config;
 }
 
@@ -1043,7 +1060,7 @@ store_plist(GValue *plist, const gchar *name)
        gchar *config, *path;
        FILE *file;
 
-       config = ghb_get_user_config_dir();
+       config = ghb_get_user_config_dir(NULL);
        path = g_strdup_printf ("%s/%s", config, name);
        file = g_fopen(path, "w");
        g_free(config);
@@ -1058,7 +1075,7 @@ load_plist(const gchar *name)
        gchar *config, *path;
        GValue *plist = NULL;
 
-       config = ghb_get_user_config_dir();
+       config = ghb_get_user_config_dir(NULL);
        path = g_strdup_printf ("%s/%s", config, name);
        if (g_file_test(path, G_FILE_TEST_IS_REGULAR))
        {
@@ -1074,7 +1091,7 @@ remove_plist(const gchar *name)
 {
        gchar *config, *path;
 
-       config = ghb_get_user_config_dir();
+       config = ghb_get_user_config_dir(NULL);
        path = g_strdup_printf ("%s/%s", config, name);
        if (g_file_test(path, G_FILE_TEST_IS_REGULAR))
        {
index 1565238..c5a870d 100644 (file)
@@ -28,7 +28,7 @@ void ghb_pref_save(GValue *settings, const gchar *key);
 void ghb_save_queue(GValue *queue);
 GValue* ghb_load_queue();
 void ghb_remove_queue_file(void);;
-gchar* ghb_get_user_config_dir();
+gchar* ghb_get_user_config_dir(gchar *subdir);
 void ghb_settings_to_ui(signal_user_data_t *ud, GValue *dict);
 void ghb_clear_presets_selection(signal_user_data_t *ud);
 void ghb_select_preset(GtkBuilder *builder, 
index f962b78..b942f67 100644 (file)
 "                        &lt;/child&gt;\n"
 "                        &lt;child&gt;\n"
 "                          &lt;object class=&quot;GtkCheckButton&quot; i"
+"d=&quot;EncodeLogLocation&quot;&gt;\n"
+"                            &lt;property name=&quot;visible&quot;&gt;Tr"
+"ue&lt;/property&gt;\n"
+"                            &lt;property name=&quot;can_focus&quot;&gt;"
+"True&lt;/property&gt;\n"
+"                            &lt;property name=&quot;tooltip_text&quot;&"
+"gt; HandBrake produces 2 activity logs.  \n"
+"One for the session and one for each encoding.\n"
+"Store the individual encode logs in the same\n"
+"location as the movie.&lt;/property&gt;\n"
+"                            &lt;property name=&quot;label&quot; transla"
+"table=&quot;yes&quot;&gt;Store logs in destination video directory&lt;/"
+"property&gt;\n"
+"                            &lt;property name=&quot;draw_indicator&quot"
+";&gt;True&lt;/property&gt;\n"
+"                            &lt;signal name=&quot;toggled&quot; handler"
+"=&quot;pref_changed_cb&quot;/&gt;\n"
+"                          &lt;/object&gt;\n"
+"                          &lt;packing&gt;\n"
+"                            &lt;property name=&quot;position&quot;&gt;5"
+"&lt;/property&gt;\n"
+"                          &lt;/packing&gt;\n"
+"                        &lt;/child&gt;\n"
+"                        &lt;child&gt;\n"
+"                          &lt;object class=&quot;GtkCheckButton&quot; i"
 "d=&quot;allow_tweaks&quot;&gt;\n"
 "                            &lt;property name=&quot;can_focus&quot;&gt;"
 "True&lt;/property&gt;\n"
 "=&quot;tweaks_changed_cb&quot;/&gt;\n"
 "                          &lt;/object&gt;\n"
 "                          &lt;packing&gt;\n"
-"                            &lt;property name=&quot;position&quot;&gt;5"
+"                            &lt;property name=&quot;position&quot;&gt;6"
 "&lt;/property&gt;\n"
 "                          &lt;/packing&gt;\n"
 "                        &lt;/child&gt;\n"
 "=&quot;hbfd_feature_changed_cb&quot;/&gt;\n"
 "                          &lt;/object&gt;\n"
 "                          &lt;packing&gt;\n"
-"                            &lt;property name=&quot;position&quot;&gt;6"
+"                            &lt;property name=&quot;position&quot;&gt;7"
 "&lt;/property&gt;\n"
 "                          &lt;/packing&gt;\n"
 "                        &lt;/child&gt;\n"
 "              </dict>\n"
 "              <key>Preferences</key>\n"
 "              <dict>\n"
+"                      <key>EncodeLogLocation</key>\n"
+"                      <false />\n"
 "                      <key>allow_tweaks</key>\n"
 "                      <false />\n"
 "                      <key>chapters_in_destination</key>\n"
index 2fa3c29..d286994 100644 (file)
@@ -3477,6 +3477,22 @@ this setting.&lt;/property&gt;
                           &lt;/packing&gt;
                         &lt;/child&gt;
                         &lt;child&gt;
+                          &lt;object class=&quot;GtkCheckButton&quot; id=&quot;EncodeLogLocation&quot;&gt;
+                            &lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
+                            &lt;property name=&quot;can_focus&quot;&gt;True&lt;/property&gt;
+                            &lt;property name=&quot;tooltip_text&quot;&gt; HandBrake produces 2 activity logs.  
+One for the session and one for each encoding.
+Store the individual encode logs in the same
+location as the movie.&lt;/property&gt;
+                            &lt;property name=&quot;label&quot; translatable=&quot;yes&quot;&gt;Store logs in destination video directory&lt;/property&gt;
+                            &lt;property name=&quot;draw_indicator&quot;&gt;True&lt;/property&gt;
+                            &lt;signal name=&quot;toggled&quot; handler=&quot;pref_changed_cb&quot;/&gt;
+                          &lt;/object&gt;
+                          &lt;packing&gt;
+                            &lt;property name=&quot;position&quot;&gt;5&lt;/property&gt;
+                          &lt;/packing&gt;
+                        &lt;/child&gt;
+                        &lt;child&gt;
                           &lt;object class=&quot;GtkCheckButton&quot; id=&quot;allow_tweaks&quot;&gt;
                             &lt;property name=&quot;can_focus&quot;&gt;True&lt;/property&gt;
                             &lt;property name=&quot;label&quot; translatable=&quot;yes&quot;&gt;Allow Tweaks&lt;/property&gt;
@@ -3484,7 +3500,7 @@ this setting.&lt;/property&gt;
                             &lt;signal name=&quot;toggled&quot; handler=&quot;tweaks_changed_cb&quot;/&gt;
                           &lt;/object&gt;
                           &lt;packing&gt;
-                            &lt;property name=&quot;position&quot;&gt;5&lt;/property&gt;
+                            &lt;property name=&quot;position&quot;&gt;6&lt;/property&gt;
                           &lt;/packing&gt;
                         &lt;/child&gt;
                         &lt;child&gt;
@@ -3495,7 +3511,7 @@ this setting.&lt;/property&gt;
                             &lt;signal name=&quot;toggled&quot; handler=&quot;hbfd_feature_changed_cb&quot;/&gt;
                           &lt;/object&gt;
                           &lt;packing&gt;
-                            &lt;property name=&quot;position&quot;&gt;6&lt;/property&gt;
+                            &lt;property name=&quot;position&quot;&gt;7&lt;/property&gt;
                           &lt;/packing&gt;
                         &lt;/child&gt;
                       &lt;/object&gt;
@@ -4930,6 +4946,8 @@ R2RrUAAABBgBAQACAAAAQAAAABAAAAAQ////AP///wD///8A////AP///wD///8A////AP///wD///8A
                </dict>
                <key>Preferences</key>
                <dict>
+                       <key>EncodeLogLocation</key>
+                       <false />
                        <key>allow_tweaks</key>
                        <false />
                        <key>chapters_in_destination</key>
index b788799..a089e0a 100644 (file)
@@ -47,6 +47,7 @@ typedef struct
        GValue *queue;
        GValue *current_job;
        GIOChannel *activity_log;
+       GIOChannel *job_activity_log;
 } signal_user_data_t;
 
 enum