Commit 50c989b5 authored by Stepan Salenikovich's avatar Stepan Salenikovich
Browse files

gnome: select video source

Add ability to select a different video cam by right clicking on the video widget

Refs #66538

Change-Id: I9c49f00f5be99ce2e2700511c43a8d383a8c5ddf
parent cb6aa46b
......@@ -159,6 +159,7 @@ SET( SRC_FILES
src/accountvideotab.cpp
src/models/activeitemproxymodel.h
src/models/activeitemproxymodel.cpp
src/defines.h
)
# compile glib resource files to c code
......
/*
* Copyright (C) 2015 Savoir-Faire Linux Inc.
* Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef __DEFINES_H__
#define BUTTON_RIGHT_CLICK 3
#endif /* __DEFINES_H__ */
\ No newline at end of file
......@@ -35,7 +35,9 @@
#include <clutter-gtk/clutter-gtk.h>
#include <video/renderer.h>
#include <video/sourcesmodel.h>
#include <QtCore/QUrl>
#include <video/devicemodel.h>
#include <QtCore/QUrl>
#include "../defines.h"
#define VIDEO_LOCAL_SIZE 150
#define VIDEO_LOCAL_OPACITY_DEFAULT 150 /* out of 255 */
......@@ -103,6 +105,7 @@ static void renderer_stop(VideoWidgetRenderer *renderer);
static void renderer_start(VideoWidgetRenderer *renderer);
static void video_widget_set_renderer(VideoWidgetRenderer *renderer);
static void on_drag_data_received(GtkWidget *, GdkDragContext *, gint, gint, GtkSelectionData *, guint, guint32, gpointer);
static gboolean on_button_press_in_screen_event(GtkWidget *, GdkEventButton *, gpointer);
/*
* video_widget_dispose()
......@@ -236,12 +239,10 @@ video_widget_init(VideoWidget *self)
priv->local->frame_queue = g_async_queue_new_full((GDestroyNotify)free_framedata);
priv->frame_timeout_source = g_timeout_add(FRAME_RATE_PERIOD, (GSourceFunc)check_frame_queue, self);
/* TODO: handle button event in screen */
// g_signal_connect(screen, "button-press-event",
// G_CALLBACK(on_button_press_in_screen_event_cb),
// self);
/* handle button event */
g_signal_connect(GTK_WIDGET(self), "button-press-event", G_CALLBACK(on_button_press_in_screen_event), NULL);
/* TODO: init drag & drop images */
/* drag & drop files as video sources */
gtk_drag_dest_set(GTK_WIDGET(self), GTK_DEST_DEFAULT_ALL, NULL, 0, (GdkDragAction)(GDK_ACTION_COPY | GDK_ACTION_PRIVATE));
gtk_drag_dest_add_uri_targets(GTK_WIDGET(self));
g_signal_connect(GTK_WIDGET(self), "drag-data-received", G_CALLBACK(on_drag_data_received), NULL);
......@@ -272,6 +273,46 @@ on_drag_data_received(G_GNUC_UNUSED GtkWidget *self,
g_strfreev(uris);
}
static void
switch_video_input(G_GNUC_UNUSED GtkWidget *widget, Video::Device *device)
{
Video::SourcesModel::instance()->switchTo(device);
}
/*
* on_button_press_in_screen_event()
*
* Handle button event in the video screen.
*/
static gboolean
on_button_press_in_screen_event(G_GNUC_UNUSED GtkWidget *widget,
GdkEventButton *event,
G_GNUC_UNUSED gpointer data)
{
/* check for right click */
if (event->button != BUTTON_RIGHT_CLICK || event->type != GDK_BUTTON_PRESS)
return FALSE;
/* create menu with available video sources */
GtkWidget *menu = gtk_menu_new();
/* list available devices and check off the active device */
auto device_list = Video::DeviceModel::instance()->devices();
for( auto device: device_list) {
GtkWidget *item = gtk_check_menu_item_new_with_mnemonic(device->name().toLocal8Bit().constData());
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), device->isActive());
g_signal_connect(item, "activate", G_CALLBACK(switch_video_input), device);
}
/* show menu */
gtk_widget_show_all(menu);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
return TRUE; /* event has been fully handled */
}
static FrameInfo *
prepare_framedata(Video::Renderer *renderer, ClutterActor* image_actor)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment