OSDN Git Service

LinGui: first cut at anamorphic picture settings enhancements
[handbrake-jp/handbrake-jp-git.git] / gtk / src / callbacks.c
index 9e8bc23..61b6bf8 100644 (file)
@@ -29,6 +29,7 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 #include <gio/gio.h>
+#include <libnotify/notify.h>
 
 #include "hb.h"
 #include "callbacks.h"
@@ -48,6 +49,7 @@
 static void update_chapter_list(signal_user_data_t *ud);
 static GList* dvd_device_list();
 static void prune_logs(signal_user_data_t *ud);
+void ghb_notify_done(signal_user_data_t *ud);
 
 // This is a dependency map used for greying widgets
 // that are dependent on the state of another widget.
@@ -1029,10 +1031,11 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
        ghb_ui_update(ud, "scale_width", 
                ghb_int64_value(tinfo->width - tinfo->crop[2] - tinfo->crop[3]));
        // If anamorphic or keep_aspect, the hight will be automatically calculated
-       gboolean keep_aspect, anamorphic;
+       gboolean keep_aspect;
+       gint pic_par;
        keep_aspect = ghb_settings_get_boolean(ud->settings, "PictureKeepRatio");
-       anamorphic = ghb_settings_get_boolean(ud->settings, "anamorphic");
-       if (!(keep_aspect || anamorphic))
+       pic_par = ghb_settings_combo_int(ud->settings, "PicturePAR");
+       if (!(keep_aspect || pic_par) || pic_par == 3)
        {
                ghb_ui_update(ud, "scale_height", 
                        ghb_int64_value(tinfo->height - tinfo->crop[0] - tinfo->crop[1]));
@@ -1118,7 +1121,7 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        gint preview_count;
        preview_count = ghb_settings_get_int(ud->settings, "preview_count");
        widget = GHB_WIDGET(ud->builder, "preview_frame");
-       gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, preview_count);
+       gtk_range_set_range (GTK_RANGE(widget), 1, preview_count);
        ghb_ui_update(ud, "preview_frame", ghb_int64_value(2));
 
        ghb_set_preview_image (ud);
@@ -1339,7 +1342,24 @@ scale_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        text = ghb_settings_get_boolean(ud->settings, "autoscale") ? "On" : "Off";
        widget = GHB_WIDGET (ud->builder, "scale_auto");
        gtk_label_set_text (GTK_LABEL(widget), text);
-       text = ghb_settings_get_boolean(ud->settings, "anamorphic") ? "On" : "Off";
+       switch (ghb_settings_combo_int(ud->settings, "PicturePAR"))
+       {
+               case 0:
+                       text = "Off";
+                       break;
+               case 1:
+                       text = "Strict";
+                       break;
+               case 2:
+                       text = "Loose";
+                       break;
+               case 3:
+                       text = "Custom";
+                       break;
+               default:
+                       text = "Unknown";
+                       break;
+       }
        widget = GHB_WIDGET (ud->builder, "scale_anamorphic");
        gtk_label_set_text (GTK_LABEL(widget), text);
 }
@@ -1560,6 +1580,7 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first)
                }
                // Nothing pending
                ghb_uninhibit_gpm();
+               ghb_notify_done(ud);
                return NULL;
        }
        // Find the next pending item after the current running item
@@ -1599,6 +1620,7 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first)
        }
        // Nothing found
        ghb_uninhibit_gpm();
+       ghb_notify_done(ud);
        return NULL;
 }
 
@@ -3147,3 +3169,35 @@ check_stable_update(signal_user_data_t *ud)
        return NULL;
 }
 
+void
+status_activate_cb(GtkStatusIcon *si, signal_user_data_t *ud)
+{
+       GtkWindow *window;
+
+       window = GTK_WINDOW(GHB_WIDGET(ud->builder, "hb_window"));
+       gtk_window_present(window);
+}
+
+static void
+notify_closed_cb(NotifyNotification *notification, signal_user_data_t *ud)
+{
+       g_object_unref(G_OBJECT(notification));
+}
+
+void
+ghb_notify_done(signal_user_data_t *ud)
+{
+       NotifyNotification *notification;
+       GtkStatusIcon *si;
+
+       si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));
+       gtk_status_icon_set_from_icon_name(si, "hb-status-empty");
+       notification = notify_notification_new(
+               "Encode Complete",
+               "Put down that cocktail, Your HandBrake queue is done!",
+               "hb-icon",
+               NULL);
+       notify_notification_attach_to_status_icon(notification, si);
+       g_signal_connect(notification, "closed", (GCallback)notify_closed_cb, ud);
+       notify_notification_show(notification, NULL);
+}