[gthumb: 13/13] media viewer: added command to copy the current time to clipboard



commit cf84f79714c60adefdfc995cd6cabffc60c7f315
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Jul 19 11:29:53 2020 +0200

    media viewer: added command to copy the current time to clipboard

 extensions/gstreamer_tools/data/ui/mediabar.ui     | 34 ++++++++++++++++++++++
 extensions/gstreamer_tools/gth-media-viewer-page.c | 34 ++++++++++++++++++++++
 2 files changed, 68 insertions(+)
---
diff --git a/extensions/gstreamer_tools/data/ui/mediabar.ui b/extensions/gstreamer_tools/data/ui/mediabar.ui
index 036f5a39..2135133b 100644
--- a/extensions/gstreamer_tools/data/ui/mediabar.ui
+++ b/extensions/gstreamer_tools/data/ui/mediabar.ui
@@ -403,6 +403,40 @@ audio-volume-medium-symbolic</property>
             <property name="top_attach">2</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_start">10</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkButton" id="copy_position_to_clipboard_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="tooltip_text" translatable="yes">Copy</property>
+                <property name="relief">none</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">edit-copy-symbolic</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">4</property>
+            <property name="top_attach">0</property>
+            <property name="height">3</property>
+          </packing>
+        </child>
       </object>
     </child>
   </object>
diff --git a/extensions/gstreamer_tools/gth-media-viewer-page.c 
b/extensions/gstreamer_tools/gth-media-viewer-page.c
index 53b27cdd..90a1c14f 100644
--- a/extensions/gstreamer_tools/gth-media-viewer-page.c
+++ b/extensions/gstreamer_tools/gth-media-viewer-page.c
@@ -976,6 +976,36 @@ skip_forward_bigger_button_clicked_cb (GtkButton *button,
 }
 
 
+static void
+copy_position_to_clipboard_button_clicked_cb (GtkButton *button,
+                                             gpointer   user_data)
+{
+       GthMediaViewerPage *self = user_data;
+       gint64              current_time = 0;
+       char               *text;
+
+       if (! gst_element_query_position (self->priv->playbin, GST_FORMAT_TIME, &current_time))
+               return;
+
+       {
+               int sec, min, hour, _time;
+
+               _time = (int) GST_TIME_AS_SECONDS (current_time);
+               sec = _time % 60;
+               _time = _time - sec;
+               min = (_time % (60*60)) / 60;
+               _time = _time - (min * 60);
+               hour = _time / (60*60);
+
+               text = g_strdup_printf ("%d:%02d:%02d", hour, min, sec);
+       }
+
+       gtk_clipboard_set_text (gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (button)), 
GDK_SELECTION_CLIPBOARD), text, -1);
+
+       g_free (text);
+}
+
+
 static void
 gth_media_viewer_page_real_activate (GthViewerPage *base,
                                     GthBrowser    *browser)
@@ -1107,6 +1137,10 @@ gth_media_viewer_page_real_activate (GthViewerPage *base,
                          "clicked",
                          G_CALLBACK (skip_forward_bigger_button_clicked_cb),
                          self);
+       g_signal_connect (GET_WIDGET ("copy_position_to_clipboard_button"),
+                         "clicked",
+                         G_CALLBACK (copy_position_to_clipboard_button_clicked_cb),
+                         self);
 
        self->priv->mediabar_revealer = gtk_revealer_new ();
        gtk_revealer_set_transition_type (GTK_REVEALER (self->priv->mediabar_revealer), 
GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]