diff options
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/callbacks.c | 2 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 468 | ||||
-rw-r--r-- | gtk/src/internal_defaults.xml | 10 | ||||
-rw-r--r-- | gtk/src/main.c | 13 | ||||
-rw-r--r-- | gtk/src/presets.c | 43 | ||||
-rw-r--r-- | gtk/src/presets.h | 2 | ||||
-rw-r--r-- | gtk/src/preview.c | 293 | ||||
-rw-r--r-- | gtk/src/values.c | 4 |
8 files changed, 605 insertions, 230 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index ad36f6fa7..36f78f76c 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -1120,7 +1120,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); diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 39964c750..7496d641d 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -325,7 +325,7 @@ <property name="icon-name">hb-picture</property> <property name="name">show_preview_menu</property> <property name="label" translatable="yes">_Picture Settings</property> - <signal handler="preview_menu_clicked_cb" name="activate"/> + <signal handler="picture_settings_alt_clicked_cb" name="activate"/> </object> </child> <child> @@ -503,7 +503,7 @@ <property name="tooltip-text" translatable="yes">Open Picture Settings</property> <property name="label" translatable="yes">Picture Settings</property> <property name="icon_name">hb-picture</property> - <signal name="toggled" handler="preview_button_clicked_cb"/> + <signal name="toggled" handler="picture_settings_clicked_cb"/> </object> <packing> <property name="expand">False</property> @@ -3091,7 +3091,6 @@ no-dct-decimate=0:cabac=1</property> <object class="GtkFrame" id="presets_frame"> <property name="visible">False</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="border_width">3</property> <property name="label_xalign">0</property> <property name="shadow_type">out</property> <signal handler="presets_frame_size_allocate_cb" name="size_allocate"/> @@ -4086,233 +4085,39 @@ location as the movie.</property> </object> </child> </object> - <object class="GtkWindow" id="preview_window"> - <property name="title" translatable="yes">Preview</property> - <property name="window_position">GTK_WIN_POS_CENTER</property> + <object class="GtkWindow" id="settings_window"> + <property name="title" translatable="yes">Picture Settings</property> + <property name="window_position">GTK_WIN_POS_NONE</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="skip_taskbar_hint">True</property> <property name="skip_pager_hint">True</property> - <signal handler="preview_window_delete_cb" name="delete_event"/> + <property name="allow-grow">False</property> + <property name="transient-for">preview_window</property> + <property name="events">GDK_STRUCTURE_MASK</property> + <signal handler="settings_configure_cb" name="configure-event"/> + <signal handler="settings_window_delete_cb" name="delete_event"/> <child> - <object class="GtkHBox" id="hbox2"> + <object class="GtkVBox" id="vbox40"> <property name="visible">True</property> - <property name="spacing">4</property> - <child> - <object class="GtkVBox" id="vbox40"> - <property name="visible">True</property> - <property name="spacing">5</property> - <child> - <object class="GtkAlignment" id="alignment52"> - <property name="visible">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">2</property> - <property name="bottom_padding">2</property> - <property name="left_padding">2</property> - <property name="right_padding">2</property> - <child> - <object class="GtkDrawingArea" id="preview_image"> - <property name="visible">True</property> - <property name="app_paintable">True</property> - </object> - </child> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment53"> - <property name="visible">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="left_padding">10</property> - <property name="right_padding">10</property> - <child> - <object class="GtkHBox" id="hbox70"> - <property name="visible">True</property> - <property name="spacing">5</property> - <child> - <object class="GtkButton" id="live_preview_play"> - <property name="height_request">30</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="relief">none</property> - <signal name="clicked" handler="live_preview_start_cb"/> - <child> - <object class="GtkImage" id="live_preview_play_image"> - <property name="visible">True</property> - <property name="stock">gtk-media-play</property> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkHScale" id="live_preview_progress"> - <property name="can_focus">True</property> - <property name="adjustment">preview_progress_adj</property> - <property name="draw_value">False</property> - <property name="value_pos">right</property> - <signal name="value_changed" handler="live_preview_seek_cb"/> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkVBox" id="live_progress_box"> - <property name="visible">True</property> - <child> - <object class="GtkLabel" id="label71"> - <property name="height_request">1</property> - <property name="visible">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkProgressBar" id="live_encode_progress"> - <property name="height_request">16</property> - <property name="visible">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - </object> - <packing> - <property name="expand">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label72"> - <property name="height_request">1</property> - <property name="visible">True</property> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment7"> - <property name="visible">True</property> - <property name="bottom_padding">4</property> - <property name="left_padding">10</property> - <property name="right_padding">10</property> - <child> - <object class="GtkHBox" id="hbox26"> - <property name="visible">True</property> - <property name="spacing">10</property> - <child> - <object class="GtkHBox" id="hbox27"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <object class="GtkLabel" id="label36"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Preview Frame:</b></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="preview_frame"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="max_length">2</property> - <property name="shadow_type">none</property> - <property name="adjustment">adjustment19</property> - <property name="numeric">True</property> - <signal name="value_changed" handler="preview_frame_value_changed_cb"/> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkHBox" id="hbox60"> - <property name="visible">True</property> - <property name="spacing">2</property> - <child> - <object class="GtkLabel" id="label37"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Duration:</b></property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="live_duration"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">adjustment21</property> - <property name="numeric">True</property> - <signal name="value_changed" handler="preview_duration_changed_cb"/> - </object> - <packing> - <property name="expand">False</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="position">2</property> - </packing> - </child> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> + <property name="spacing">5</property> <child> - <object class="GtkVSeparator" id="vseparator2"> + <object class="GtkCheckButton" id="show_preview"> <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip-text" translatable="yes">Open Preview Window</property> + <property name="label" translatable="yes">Show Preview</property> + <signal name="toggled" handler="preview_button_clicked_cb"/> </object> <packing> <property name="expand">False</property> - <property name="position">1</property> + <property name="position">0</property> </packing> </child> - <child> <object class="GtkNotebook" id="notebook1"> <property name="visible">True</property> <property name="can_focus">True</property> + <child> <object class="GtkAlignment" id="alignment54"> <property name="visible">True</property> @@ -5037,10 +4842,245 @@ location as the movie.</property> </child> </object> <packing> + <property name="expand">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + + <object class="GtkWindow" id="preview_window"> + <property name="title" translatable="yes">Preview</property> + <property name="window_position">GTK_WIN_POS_CENTER</property> + <property name="skip_taskbar_hint">True</property> + <property name="skip_pager_hint">True</property> + <property name="allow-grow">False</property> + <property name="events">GDK_STRUCTURE_MASK</property> + <signal handler="preview_configure_cb" name="configure-event"/> + <signal handler="preview_window_delete_cb" name="delete_event"/> + <child> + <object class="GtkHBox" id="hbox2"> + <property name="visible">True</property> + <property name="spacing">4</property> + <child> + <object class="GtkVBox" id="vbox40"> + <property name="visible">True</property> + <property name="spacing">5</property> + <child> + <object class="GtkAlignment" id="alignment52"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">2</property> + <property name="bottom_padding">2</property> + <property name="left_padding">2</property> + <property name="right_padding">2</property> + <child> + <object class="GtkDrawingArea" id="preview_image"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK</property> + <property name="app_paintable">True</property> + <signal name="motion-notify-event" handler="preview_motion_cb"/> + <signal name="leave-notify-event" handler="preview_leave_cb"/> + </object> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVSeparator" id="vseparator2"> + <property name="visible">True</property> + </object> + <packing> <property name="expand">False</property> <property name="position">1</property> </packing> </child> + + </object> + </child> + </object> + <object class="GtkWindow" id="preview_hud"> + <property name="default_width">500</property> + <property name="decorated">False</property> + <property name="opacity">.50</property> + <property name="skip_taskbar_hint">True</property> + <property name="skip_pager_hint">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property> + <signal name="enter-notify-event" handler="hud_enter_cb"/> + <child> + <object class="GtkAlignment" id="alignment53"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="left_padding">10</property> + <property name="right_padding">10</property> + <property name="top_padding">5</property> + <property name="bottom_padding">5</property> + + <child> + <object class="GtkVBox" id="vbox35"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <object class="GtkHScale" id="preview_frame"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment19</property> + <property name="digits">0</property> + <property name="value_pos">bottom</property> + <signal name="value_changed" handler="preview_frame_value_changed_cb"/> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox70"> + <property name="visible">True</property> + <property name="spacing">5</property> + <child> + <object class="GtkButton" id="live_preview_play"> + <property name="height_request">30</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="relief">none</property> + <signal name="clicked" handler="live_preview_start_cb"/> + <child> + <object class="GtkImage" id="live_preview_play_image"> + <property name="visible">True</property> + <property name="stock">gtk-media-play</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHScale" id="live_preview_progress"> + <property name="can_focus">True</property> + <property name="adjustment">preview_progress_adj</property> + <property name="draw_value">False</property> + <property name="value_pos">right</property> + <signal name="value_changed" handler="live_preview_seek_cb"/> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="live_progress_box"> + <property name="visible">True</property> + <child> + <object class="GtkLabel" id="label71"> + <property name="height_request">1</property> + <property name="visible">True</property> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkProgressBar" id="live_encode_progress"> + <property name="height_request">16</property> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label72"> + <property name="height_request">1</property> + <property name="visible">True</property> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox26"> + <property name="visible">True</property> + <property name="spacing">10</property> + <child> + <object class="GtkHBox" id="hbox60"> + <property name="visible">True</property> + <property name="spacing">2</property> + <child> + <object class="GtkLabel" id="label37"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Duration:</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="live_duration"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment21</property> + <property name="numeric">True</property> + <signal name="value_changed" handler="preview_duration_changed_cb"/> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="settings_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip-text" translatable="yes">Open Picture Settings</property> + <property name="label" translatable="yes">Settings</property> + <signal handler="picture_settings_alt2_clicked_cb" name="clicked"/> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + </object> </child> </object> diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml index 5b8106590..65201e89c 100644 --- a/gtk/src/internal_defaults.xml +++ b/gtk/src/internal_defaults.xml @@ -120,8 +120,18 @@ <false /> <key>preview_count</key> <integer>10</integer> + <key>preview_x</key> + <integer>-1</integer> + <key>preview_y</key> + <integer>-1</integer> + <key>settings_x</key> + <integer>-1</integer> + <key>settings_y</key> + <integer>-1</integer> <key>show_presets</key> <true /> + <key>show_preview</key> + <false /> <key>use_source_name</key> <true /> <key>update_skip_version</key> diff --git a/gtk/src/main.c b/gtk/src/main.c index 559d9799e..370086fdd 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -631,6 +631,19 @@ main (int argc, char *argv[]) // Start timer for monitoring libhb status, 500ms g_timeout_add (500, ghb_timer_cb, (gpointer)ud); // Everything should be go-to-go. Lets rock! + + // Create floating window over preview image + GtkWidget *widget; + GdkWindow *parent, *win; + + widget = GHB_WIDGET(ud->builder, "preview_image"); + gtk_widget_realize(widget); + parent = gtk_widget_get_window(widget); + widget = GHB_WIDGET(ud->builder, "preview_hud"); + gtk_widget_realize(widget); + win = gtk_widget_get_window(widget); + gdk_window_reparent(win, parent, 0, 0); + gtk_main (); ghb_backend_close(); if (ud->queue) diff --git a/gtk/src/presets.c b/gtk/src/presets.c index cbe539345..aafff05d1 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -38,6 +38,7 @@ enum static GValue *presetsPlist = NULL; static GValue *internalPlist = NULL; static GValue *prefsPlist = NULL; +static gboolean prefs_modified = FALSE; static const GValue* preset_dict_get_value(GValue *dict, const gchar *key); static void store_plist(GValue *plist, const gchar *name); @@ -1196,12 +1197,35 @@ ghb_prefs_save(GValue *settings) } } store_plist(prefsPlist, "preferences"); + prefs_modified = FALSE; +} + +void +ghb_pref_set(GValue *settings, const gchar *key) +{ + const GValue *value, *value2; + + if (prefs_initializing) return; + value = ghb_settings_get_value(settings, key); + if (value != NULL) + { + GValue *dict; + dict = plist_get_dict(prefsPlist, "Preferences"); + if (dict == NULL) return; + value2 = ghb_dict_lookup(dict, key); + if (ghb_value_cmp(value, value2) != 0) + { + ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value)); + store_plist(prefsPlist, "preferences"); + prefs_modified = TRUE; + } + } } void ghb_pref_save(GValue *settings, const gchar *key) { - const GValue *value; + const GValue *value, *value2; if (prefs_initializing) return; value = ghb_settings_get_value(settings, key); @@ -1210,8 +1234,23 @@ ghb_pref_save(GValue *settings, const gchar *key) GValue *dict; dict = plist_get_dict(prefsPlist, "Preferences"); if (dict == NULL) return; - ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value)); + value2 = ghb_dict_lookup(dict, key); + if (ghb_value_cmp(value, value2) != 0) + { + ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value)); + store_plist(prefsPlist, "preferences"); + prefs_modified = FALSE; + } + } +} + +void +ghb_prefs_store(void) +{ + if (prefs_modified) + { store_plist(prefsPlist, "preferences"); + prefs_modified = FALSE; } } diff --git a/gtk/src/presets.h b/gtk/src/presets.h index c5a870d3d..6bcd14a54 100644 --- a/gtk/src/presets.h +++ b/gtk/src/presets.h @@ -38,5 +38,7 @@ void ghb_presets_list_init(signal_user_data_t *ud, gint *indices, gint len); GValue* ghb_parse_preset_path(const gchar *path); gchar* ghb_preset_path_string(const GValue *path); gboolean ghb_preset_is_custom(void); +void ghb_prefs_store(void); +void ghb_pref_set(GValue *settings, const gchar *key); #endif // _GHB_PRESETS_H_ diff --git a/gtk/src/preview.c b/gtk/src/preview.c index d9abf248f..d3bd475da 100644 --- a/gtk/src/preview.c +++ b/gtk/src/preview.c @@ -713,9 +713,12 @@ preview_expose_cb( return TRUE; } - gdk_draw_pixbuf( - widget->window, NULL, ud->preview->pix, 0, 0, 0, 0, - -1, -1, GDK_RGB_DITHER_NONE, 0, 0); + if (ud->preview->pix != NULL) + { + gdk_draw_pixbuf( + widget->window, NULL, ud->preview->pix, 0, 0, 0, 0, + -1, -1, GDK_RGB_DITHER_NONE, 0, 0); + } return TRUE; } @@ -750,21 +753,113 @@ set_visible(GtkWidget *widget, gboolean visible) } } -void +G_MODULE_EXPORT void preview_button_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { - GtkWidget *widget = GHB_WIDGET (ud->builder, "preview_window"); - set_visible(widget, gtk_toggle_tool_button_get_active( - GTK_TOGGLE_TOOL_BUTTON(xwidget))); + gint titleindex; + + g_debug("preview_button_clicked_cb()"); + titleindex = ghb_settings_combo_int(ud->settings, "title"); + if (titleindex >= 0) + { + gint x, y; + GtkWidget *widget = GHB_WIDGET (ud->builder, "preview_window"); + x = ghb_settings_get_int(ud->settings, "preview_x"); + y = ghb_settings_get_int(ud->settings, "preview_y"); + if (x >= 0 && y >= 0) + gtk_window_move(GTK_WINDOW(widget), x, y); + set_visible(widget, gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(xwidget))); + } + ghb_widget_to_setting (ud->settings, xwidget); + ghb_check_dependency(ud, xwidget); + const gchar *name = gtk_widget_get_name(xwidget); + ghb_pref_save(ud->settings, name); } -void -preview_menu_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) +G_MODULE_EXPORT void +picture_settings_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { - GtkWidget *widget = GHB_WIDGET (ud->builder, "preview_window"); - set_visible(widget, TRUE); - widget = GHB_WIDGET (ud->builder, "show_picture"); - gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), TRUE); + GtkWidget *widget; + gboolean active; + gint x, y; + + g_debug("picture_settings_clicked_cb()"); + widget = GHB_WIDGET (ud->builder, "settings_window"); + active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(xwidget)); + x = ghb_settings_get_int(ud->settings, "settings_x"); + y = ghb_settings_get_int(ud->settings, "settings_y"); + if (x >= 0 && y >= 0) + gtk_window_move(GTK_WINDOW(widget), x, y); + set_visible(widget, active); + if (ghb_settings_get_boolean(ud->settings, "show_preview")) + { + widget = GHB_WIDGET (ud->builder, "preview_window"); + x = ghb_settings_get_int(ud->settings, "preview_x"); + y = ghb_settings_get_int(ud->settings, "preview_y"); + if (x >= 0 && y >= 0) + gtk_window_move(GTK_WINDOW(widget), x, y); + set_visible(widget, active); + } +} + +G_MODULE_EXPORT void +picture_settings_alt_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) +{ + GtkWidget *toggle; + gboolean active; + + g_debug("picture_settings_alt_clicked_cb()"); + toggle = GHB_WIDGET (ud->builder, "show_picture"); + active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(toggle)); + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(toggle), !active); +} + +G_MODULE_EXPORT void +picture_settings_alt2_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) +{ + GtkWidget *toggle; + gboolean active; + gint signal_id; + gint handler_id = 0; + + g_debug("picture_settings_alt2_clicked_cb()"); + toggle = GHB_WIDGET (ud->builder, "show_picture"); + active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(toggle)); + if (active) + { + // I don't want deleting the settings window to also remove the + // preview window, but changing the toggle will do this, so temporarily + // ignore the toggled signal + signal_id = g_signal_lookup("toggled", GTK_TYPE_TOGGLE_TOOL_BUTTON); + if (signal_id > 0) + { + // Valid signal id found. This should always succeed. + handler_id = g_signal_handler_find((gpointer)toggle, + G_SIGNAL_MATCH_ID, + signal_id, 0, 0, 0, 0); + if (handler_id > 0) + { + // This should also always succeed + g_signal_handler_block ((gpointer)toggle, handler_id); + } + } + } + + GtkWidget *widget = GHB_WIDGET (ud->builder, "settings_window"); + gint x, y; + + x = ghb_settings_get_int(ud->settings, "settings_x"); + y = ghb_settings_get_int(ud->settings, "settings_y"); + if (x >= 0 && y >= 0) + gtk_window_move(GTK_WINDOW(widget), x, y); + set_visible(widget, !active); + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(toggle), !active); + + if (handler_id > 0) + { + g_signal_handler_unblock ((gpointer)toggle, handler_id); + } } void @@ -787,8 +882,43 @@ preview_window_delete_cb( { live_preview_stop(ud); gtk_widget_hide(widget); + return TRUE; +} + +gboolean +settings_window_delete_cb( + GtkWidget *widget, + GdkEvent *event, + signal_user_data_t *ud) +{ + gint signal_id; + gint handler_id = 0; + + gtk_widget_hide(widget); widget = GHB_WIDGET (ud->builder, "show_picture"); + + // I don't want deleting the settings window to also remove the + // preview window, but changing the toggle will do this, so temporarily + // ignore the toggled signal + signal_id = g_signal_lookup("toggled", GTK_TYPE_TOGGLE_TOOL_BUTTON); + if (signal_id > 0) + { + // Valid signal id found. This should always succeed. + handler_id = g_signal_handler_find((gpointer)widget, G_SIGNAL_MATCH_ID, + signal_id, 0, 0, 0, 0); + if (handler_id > 0) + { + // This should also always succeed + g_signal_handler_block ((gpointer)widget, handler_id); + } + } + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), FALSE); + + if (handler_id > 0) + { + g_signal_handler_unblock ((gpointer)widget, handler_id); + } return TRUE; } @@ -803,3 +933,140 @@ preview_duration_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_pref_save(ud->settings, name); } +static guint hud_timeout_id = 0; + +static gboolean +hud_timeout(signal_user_data_t *ud) +{ + GtkWidget *widget; + + widget = GHB_WIDGET(ud->builder, "preview_hud"); + gtk_widget_hide(widget); + hud_timeout_id = 0; + return FALSE; +} + +G_MODULE_EXPORT gboolean +hud_enter_cb( + GtkWidget *widget, + GdkEventCrossing *event, + signal_user_data_t *ud) +{ + if (hud_timeout_id != 0) + { + GMainContext *mc; + GSource *source; + + mc = g_main_context_default(); + source = g_main_context_find_source_by_id(mc, hud_timeout_id); + if (source != NULL) + g_source_destroy(source); + } + widget = GHB_WIDGET(ud->builder, "preview_hud"); + gtk_widget_show(widget); + hud_timeout_id = 0; + return FALSE; +} + +G_MODULE_EXPORT gboolean +preview_leave_cb( + GtkWidget *widget, + GdkEventCrossing *event, + signal_user_data_t *ud) +{ + if (hud_timeout_id != 0) + { + GMainContext *mc; + GSource *source; + + mc = g_main_context_default(); + source = g_main_context_find_source_by_id(mc, hud_timeout_id); + if (source != NULL) + g_source_destroy(source); + } + hud_timeout_id = g_timeout_add(300, (GSourceFunc)hud_timeout, ud); + return FALSE; +} + +G_MODULE_EXPORT gboolean +preview_motion_cb( + GtkWidget *widget, + GdkEventMotion *event, + signal_user_data_t *ud) +{ + if (hud_timeout_id != 0) + { + GMainContext *mc; + GSource *source; + + mc = g_main_context_default(); + source = g_main_context_find_source_by_id(mc, hud_timeout_id); + if (source != NULL) + g_source_destroy(source); + } + else + { + GtkWidget *widget; + GdkWindow *parent, *win; + gint pw, ph, w, h, x, y; + + widget = GHB_WIDGET(ud->builder, "preview_image"); + parent = gtk_widget_get_window(widget); + widget = GHB_WIDGET(ud->builder, "preview_hud"); + win = gtk_widget_get_window(widget); + gtk_widget_show(widget); + gdk_drawable_get_size(GDK_DRAWABLE(parent), &pw, &ph); + gdk_drawable_get_size(GDK_DRAWABLE(win), &w, &h); + x = pw/2 - w/2; + if (ph/4 > h/2) + y = ph - ph/4 - h/2; + else + y = ph - h; + gdk_window_move(win, x, y); + } + hud_timeout_id = g_timeout_add_seconds(10, (GSourceFunc)hud_timeout, ud); + return FALSE; +} + +G_MODULE_EXPORT gboolean +preview_configure_cb( + GtkWidget *widget, + GdkEventConfigure *event, + signal_user_data_t *ud) +{ + gint x, y; + + g_debug("preview_configure_cb()"); + if (GTK_WIDGET_VISIBLE(widget)) + { + gtk_window_get_position(GTK_WINDOW(widget), &x, &y); + ghb_settings_set_int(ud->settings, "preview_x", x); + ghb_settings_set_int(ud->settings, "preview_y", y); + ghb_pref_set(ud->settings, "preview_x"); + ghb_pref_set(ud->settings, "preview_y"); + ghb_prefs_store(); + } + return FALSE; +} + +G_MODULE_EXPORT gboolean +settings_configure_cb( + GtkWidget *widget, + GdkEventConfigure *event, + signal_user_data_t *ud) +{ + gint x, y; + + g_debug("settings_configure_cb()"); + if (GTK_WIDGET_VISIBLE(widget)) + { + gtk_window_get_position(GTK_WINDOW(widget), &x, &y); + ghb_settings_set_int(ud->settings, "settings_x", x); + ghb_settings_set_int(ud->settings, "settings_y", y); + ghb_pref_set(ud->settings, "settings_x"); + ghb_pref_set(ud->settings, "settings_y"); + ghb_prefs_store(); + } + return FALSE; +} + diff --git a/gtk/src/values.c b/gtk/src/values.c index a888d0a50..a2096e008 100644 --- a/gtk/src/values.c +++ b/gtk/src/values.c @@ -252,6 +252,10 @@ ghb_value_cmp(const GValue *vala, const GValue *valb) GType typa; GType typb; + if ((vala == NULL && valb != NULL) || (vala != NULL && valb == NULL)) + { + return 1; + } typa = G_VALUE_TYPE(vala); typb = G_VALUE_TYPE(valb); if (typa != typb) |