Skip to content
Snippets Groups Projects
Commit c9a5d094 authored by Jonas Fonseca's avatar Jonas Fonseca Committed by Jonas Fonseca
Browse files
parent 12bc81b9
No related branches found
No related tags found
No related merge requests found
Showing
with 720 additions and 2 deletions
......@@ -98,6 +98,7 @@ sflphone-client-gnome/stamp-h1
/sflphone-client-gnome/src/widget/Makefile
/sflphone-client-gnome/doc/Makefile
/sflphone-client-gnome/po/Makefile
/sflphone-client-gnome/webkit/Makefile
# Ignore sflphone-client-gnome stuff
......
SUBDIRS = src pixmaps tests man po doc
SUBDIRS = src pixmaps webkit tests man po doc
ACLOCAL_AMFLAGS = -I m4
......
......@@ -64,6 +64,7 @@ PKG_CHECK_MODULES(DEPS, \
libnotify >= 0.4 \
gtk+-2.0 >= 2.2 \
glib-2.0 >= 2.2 \
webkit-1.0 \
libebook-1.2 >= 2.22 \
libgnomeui-2.0 \
gnome-doc-utils
......@@ -90,6 +91,7 @@ src/contacts/addressbook/Makefile
src/widget/Makefile
src/icons/Makefile
pixmaps/Makefile
webkit/Makefile
sflphone.desktop
tests/Makefile
man/Makefile
......
......@@ -16,6 +16,7 @@ sflphone_client_gnome_SOURCES = \
uimanager.c \
sflnotify.c \
mainwindow.c \
imwindow.c \
dialpad.c \
callable_obj.c \
conference_obj.c \
......
......@@ -149,6 +149,9 @@ typedef struct {
/* The audio codec used for this call, if applicable */
gchar *_audio_codec;
/* Associated IM widget */
GtkWidget *_im_widget;
} callable_obj_t;
void create_new_call (callable_type_t, call_state_t, gchar*, gchar*, gchar*, gchar*, callable_obj_t **);
......
......@@ -67,6 +67,7 @@ void register_sflphone_stock_icons (GtkIconFactory *factory)
add_icon (factory, GTK_STOCK_TRANSFER, gnome_stock_transfer, GTK_ICON_SIZE_SMALL_TOOLBAR);
add_icon (factory, GTK_STOCK_ONHOLD, gnome_stock_onhold, GTK_ICON_SIZE_SMALL_TOOLBAR);
add_icon (factory, GTK_STOCK_OFFHOLD, gnome_stock_offhold, GTK_ICON_SIZE_SMALL_TOOLBAR);
add_icon (factory, GTK_STOCK_IM, gnome_stock_im, GTK_ICON_SIZE_SMALL_TOOLBAR);
add_icon (factory, GTK_STOCK_CALL_CURRENT, gnome_stock_call_current, GTK_ICON_SIZE_SMALL_TOOLBAR);
add_icon (factory, GTK_STOCK_ADDRESSBOOK, gnome_stock_addressbook, GTK_ICON_SIZE_SMALL_TOOLBAR);
add_icon (factory, GTK_STOCK_CALLS, gnome_stock_calls, GTK_ICON_SIZE_SMALL_TOOLBAR);
......
......@@ -41,6 +41,7 @@ G_BEGIN_DECLS
#define GTK_STOCK_HANGUP "gnome-stock-hangup"
#define GTK_STOCK_ONHOLD "gnome-stock-onhold"
#define GTK_STOCK_OFFHOLD "gnome-stock-offhold"
#define GTK_STOCK_IM "gnome-stock-im"
#define GTK_STOCK_TRANSFER "gnome-stock-transfer"
#define GTK_STOCK_DIAL "gnome-stock-dial"
#define GTK_STOCK_CALL_CURRENT "gnome-stock-call-current"
......
......@@ -660,6 +660,104 @@ static const guint8 gnome_stock_offhold[] =
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0lrU\0mt\267\0lt\254\0js<\0\0\0\0"};
/* GdkPixbuf RGBA C-Source image dump */
#ifdef __SUNPRO_C
#pragma align 4 (gnome_stock_im)
#endif
#ifdef __GNUC__
static const guint8 gnome_stock_im[] __attribute__ ((__aligned__ (4))) =
#else
static const guint8 gnome_stock_im[] =
#endif
{ ""
/* Pixbuf magic (0x47646b50) */
"GdkP"
/* length: header (24) + pixel_data (2304) */
"\0\0\11\30"
/* pixdata_type (0x1010002) */
"\1\1\0\2"
/* rowstride (96) */
"\0\0\0`"
/* width (24) */
"\0\0\0\30"
/* height (24) */
"\0\0\0\30"
/* pixel_data: */
"\0\0\0\0\0ix\21\0mss\0mr\210\0lt@\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"3ff\5\14kqV\14lr\250\0lr}\0mv\34\0\0\0\0\0ht\26\0ls\343\0ls\377\0ls\377"
"\0ls\377\0ms\242\0\200\200\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\34qq\11\33mm/\32kqX\33ms\205\26lq\320\17ou\377\22kp"
"\377\0ls\377\0ls\364\0lq-\0ks\212\0ls\377\0ls\377\0ls\377\0ls\377\0l"
"s\377\0ks\253\0ff\5\0\0\0\0\0\0\0\0\40`p\20\34mm6\35nta\33ms\214\34k"
"p\235\26tz\230\16\202\212\237\5\206\216\324\1\207\217\377\1\205\216\377"
"\21lq\377\0ls\377\0ls\377\0ks\262\0lr\256\0ls\377\0ls\377\0ls\377\0l"
"s\377\0ls\377\3lr\377\11lr\300\32mtn\34ns\222\34lq\234\26y\200\230\15"
"\207\217\240\6\222\233\241\0\233\245\241\0\232\245\241\0\216\226\324"
"\4\201\211\377\10z\200\377\2\203\213\377\21lq\377\0ls\377\0ls\377\0l"
"t\326\0lsv\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\22lq\377\16sy\377"
"\11\202\212\341\5\226\241\243\0\236\251\241\0\236\250\241\2\232\245\241"
"\6\217\230\241\16\202\212\237\20qy\321\21lq\377\17ls\377\22kp\377\2\201"
"\211\377\21kq\377\0ls\377\0ls\377\0ks\235\0\200\200\6\0ls\377\0ls\377"
"\0ls\377\0ls\377\0ls\377\17ls\377\3\210\220\377\1\212\223\377\6\205\215"
"\342\16\201\211\240\27rw\230\35ko\236\33lt\206\15lq\266\6ls\377\1ls\377"
"\0ls\377\21lq\377\2\177\207\377\21kq\377\0ls\377\0lr\341\0ju\30\0\0\0"
"\0\0pp\20\0ms\312\0ls\377\0ls\377\0ls\377\17ls\377\3\207\216\377\22k"
"p\377\15ms\377\13mr\314\26ot.$mm\7\0lr\223\0ls\377\0ls\377\0ls\377\0"
"ls\377\21lq\377\2~\206\377\21kq\377\0ls\340\0lt!\0\0\0\0\0\0\0\0\0\0"
"\0\0\0fw\17\0ls\307\0ls\377\0ls\377\17ls\377\3\205\216\377\22kp\377\0"
"ls\377\0ls\377\0ls\266\0kr\230\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377"
"\21lq\377\2}\204\377\22kq\362\0pp\40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0fw\17\0ks\305\0ls\377\17ls\377\3\204\214\377\22kp\377\0ls\377"
"\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\21l"
"q\377\2|\204\362\32ko\247\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0mm\16\0lr\304\17ls\377\3\202\213\377\22kp\377\0ls\377\0"
"ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\22lp\361"
"\3~\210\254\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0vv\15\21ls\345\3\201\211\377\22kp\377\0ls\377\0ls\377"
"\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\332\32lo\247\3\177"
"\210\241\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\32mr\224\3\201\211\351\22kp\377\0ls\377\0ls\377"
"\0ls\377\0ls\377\0ls\377\0ls\377\0ls\377\0mt\332\0hq\33\34lo\234\3}\205"
"\241\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\33lq\220\3\201\211\335\22kp\377\0ls\377\0ls\377\0ls"
"\377\0ls\377\0ls\377\0ls\377\0ls\377\0ms\305\0f\200\12\34lo\234\3z\203"
"\241\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0UU\3\22lr\326\3}\205\377\22kp\377\0ls\377\0ls\377\0ls\377\0"
"ls\377\0ls\377\0ls\377\4ls\377\12lr\377\17mq\337\34ko\245\3x\200\241"
"\34kp\233\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0U"
"U\3\0ks\244\17lr\377\3|\204\377\22kp\377\0ls\377\0ls\377\0ls\377\0ls"
"\377\3ls\377\16lq\377\17lr\377\11rx\377\5sz\377\7rx\351\3w\177\245\35"
"ko\236\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0UU\3\0ls\246"
"\0ls\377\17kr\377\3{\202\377\22kp\377\0ls\377\0ls\377\0ls\377\2ls\377"
"\20lq\377\10rx\377\0v}\377\0u}\377\0t{\377\0sz\377\3rx\351\34jo\246\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\200\4\3ls\257\10lr\377\13"
"lr\377\22kp\377\3y\201\377\22kp\377\0ls\377\0ls\377\0ls\324\16lr\333"
"\10ry\377\0v}\377\0t|\377\0t{\377\0sz\377\0ry\377\6nv\377\16kr\337\0"
"fw\17\0\0\0\0\0\0\0\0\0\0\0\0\22mm\16\16lr\315\21lr\377\13qx\377\6v}"
"\377\10u{\377\2y\201\377\22kp\377\0ls\377\0ls\317\0ht\26\35kp\240\1u"
"|\344\0t{\377\0sz\377\0ry\377\0qx\377\4ov\377\20kq\377\3ls\377\0ls\307"
"\0fw\17\0\0\0\0\40\200\200\10\22lr\331\13qy\377\1}\204\377\0|\204\377"
"\0{\202\377\0z\202\377\1x\177\377\22kp\377\0ls\316\0ky\23\0\0\0\0\35"
"kp\217\13sy\242\1t|\343\0qx\377\4pv\377\13mt\377\20kp\377\4kr\377\0l"
"s\377\0ls\377\0ls\377\0\200\200\6\17mr\233\12ry\377\0}\204\377\0{\203"
"\377\0{\202\377\0y\201\377\0y\200\377\4u|\377\17lq\347\0qq\22\0\0\0\0"
"\0\0\0\0\34hq\33\32lp\200\34kp\235\23kp\341\17lq\377\11lr\377\1ks\377"
"\0ls\377\0ls\377\0ls\377\0ls\377\0lt\213\23kr\333\3y\201\377\0{\202\377"
"\0z\201\377\0y\200\377\0x\177\377\3v|\377\21jr\353\23mv6\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\200\6\0mr\260\0ls\377\0ls"
"\377\0ls\377\0ls\377\0ls\377\0ls\377\0ls\322\22lr\313\10s{\377\0y\200"
"\377\0x\200\377\2v}\377\11qw\377\21kq\353\27koL\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\200\6\0ls\255\0ls\377"
"\0ls\377\0ls\377\0ls\377\0ls\377\0ls\273\14jnA\17lq\370\21kq\377\20k"
"r\377\20lq\377\15kr\335\24bo'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ff\5\0lt\252\0ls\377\0ls\377"
"\0ls\377\0ls\374\0ksE\0\0\0\0\0lq-\2ms\242\1ls\275\0lrt\0tt\13\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0lrU\0mt\267\0lt\254\0js<\0\0\0\0"};
/* GdkPixbuf RGBA C-Source image dump */
#ifdef __SUNPRO_C
......
/*
* Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
* Author: Pierre-Luc Bacon <pierre-luc.bacon@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., 675 Mass Ave, Cambridge, MA 02139, 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.
*/
#include <config.h>
#include <gtk/gtk.h>
#include <eel-gconf-extensions.h>
#include <sflphone_const.h>
#include <imwindow.h>
/** Local variables */
GtkWidget *im_window = NULL;
GtkWidget *im_vbox = NULL;
static gboolean window_configure_cb (GtkWidget *win, GdkEventConfigure *event) {
int pos_x, pos_y;
eel_gconf_set_integer (CONF_IM_WINDOW_WIDTH, event->width);
eel_gconf_set_integer (CONF_IM_WINDOW_HEIGHT, event->height);
gtk_window_get_position (GTK_WINDOW (im_window_get()), &pos_x, &pos_y);
eel_gconf_set_integer (CONF_IM_WINDOW_POSITION_X, pos_x);
eel_gconf_set_integer (CONF_IM_WINDOW_POSITION_Y, pos_y);
return FALSE;
}
/**
* Minimize the main window.
*/
static gboolean
on_delete(GtkWidget * widget UNUSED, gpointer data UNUSED)
{
gtk_widget_hide(GTK_WIDGET(im_window_get()));
return TRUE;
}
static void
im_window_init()
{
const char *window_title = "SFLphone VoIP Client";
gchar *path;
GError *error = NULL;
gboolean ret;
int width, height, position_x, position_y;
// Get configuration stored in gconf
width = eel_gconf_get_integer(CONF_IM_WINDOW_WIDTH);
if (width <= 0)
width = 400;
height = eel_gconf_get_integer(CONF_IM_WINDOW_HEIGHT);
if (height <= 0)
height = 500;
position_x = eel_gconf_get_integer(CONF_IM_WINDOW_POSITION_X);
position_y = eel_gconf_get_integer(CONF_IM_WINDOW_POSITION_Y);
im_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(im_window), 0);
gtk_window_set_title(GTK_WINDOW(im_window), window_title);
gtk_window_set_default_size(GTK_WINDOW (im_window), width, height);
gtk_window_set_default_icon_from_file(LOGO, NULL);
gtk_window_set_position(GTK_WINDOW(im_window), GTK_WIN_POS_MOUSE);
gtk_widget_set_name(im_window, "imwindow");
g_signal_connect (G_OBJECT (im_window), "delete-event",
G_CALLBACK (on_delete), NULL);
g_signal_connect_object (G_OBJECT (im_window), "configure-event",
G_CALLBACK (window_configure_cb), NULL, 0);
im_vbox = gtk_vbox_new (FALSE /*homogeneous*/, 0 /*spacing*/);
gtk_container_add (GTK_CONTAINER (im_window), im_vbox);
/* make sure that everything is visible */
gtk_widget_show_all (im_window);
// Restore position according to the configuration stored in gconf
gtk_window_move (GTK_WINDOW (im_window), position_x, position_y);
}
GtkWidget *
im_window_get()
{
if (im_window == NULL)
im_window_init();
return im_window;
}
void
im_window_add(GtkWidget *widget)
{
if (im_window_get()) {
gtk_box_pack_start (GTK_BOX (im_vbox), widget, TRUE /*expand*/,
TRUE /*fill*/, 0 /*padding*/);
gtk_widget_show_all (im_window);
}
}
void
im_window_remove(GtkWidget *widget)
{
// TODO(jonas) remove widget from the window
}
/*
* Copyright (C) 2010 Savoir-Faire Linux Inc.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, 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 __IMWINDOW_H__
#define __IMWINDOW_H__
#include <gtk/gtk.h>
#include <gtk/gtk.h>
#define IM_WINDOW_WIDTH 280
#define IM_WINDOW_HEIGHT 320
/** @file imwindow.h
* @brief The IM window of the client.
*/
/**
* Display the IM window
* @return GtkWidget* The IM window
*/
GtkWidget *im_window_get();
/**
* Add IM widget to the IM window
*/
void im_window_add(GtkWidget *widget);
/**
* Remove IM widget from the IM window
*/
void im_window_remove(GtkWidget *widget);
#endif
......@@ -185,6 +185,10 @@ log4c_category_t* log4c_sfl_gtk_category;
#define CONF_MAIN_WINDOW_HEIGHT CONF_PREFIX "/state/window_height"
#define CONF_MAIN_WINDOW_POSITION_X CONF_PREFIX "/state/window_position_x"
#define CONF_MAIN_WINDOW_POSITION_Y CONF_PREFIX "/state/window_position_y"
#define CONF_IM_WINDOW_WIDTH CONF_PREFIX "/state/im_width"
#define CONF_IM_WINDOW_HEIGHT CONF_PREFIX "/state/im_height"
#define CONF_IM_WINDOW_POSITION_X CONF_PREFIX "/state/im_position_x"
#define CONF_IM_WINDOW_POSITION_Y CONF_PREFIX "/state/im_position_y"
/** Show/Hide the dialpad */
#define CONF_SHOW_DIALPAD CONF_PREFIX "/state/dialpad"
#define SHOW_VOLUME_CONTROLS CONF_PREFIX "/state/volume_controls"
......
......@@ -7,6 +7,7 @@
<menuitem action="PickUp"/>
<menuitem action="HangUp"/>
<menuitem name="OnHoldMenu" action="OnHold"/>
<menuitem action="InstantMessaging"/>
<menuitem action="Record"/>
<separator/>
<menuitem action="AccountAssistant"/>
......
......@@ -39,6 +39,7 @@
#include <libgnome/gnome-help.h>
#include <uimanager.h>
#include <statusicon.h>
#include <widget/imwidget.h>
static GtkWidget *toolbar;
static GtkWidget *toolbarWindows;
......@@ -504,6 +505,26 @@ call_hold(void* foo UNUSED)
}
}
static void
call_im(void* foo UNUSED)
{
callable_obj_t * selectedCall = calltab_get_selected_call(current_calls);
static GtkWidget *im = NULL;
if (!im) {
im = im_widget_new();
im_window_add(im);
} else {
im_widget_add_message(im, "hello from call_im");
}
if (selectedCall)
{
printf("Call IM with call\n");
selectedCall->_im_widget = im_widget_new();
}
}
static void
conference_hold(void* foo UNUSED)
{
......@@ -839,6 +860,8 @@ static const GtkActionEntry menu_entries[] =
N_("Place the call on hold"), G_CALLBACK (call_hold) },
{ "OffHold", GTK_STOCK_OFFHOLD, N_("O_ff hold"), "<control>P",
N_("Place the call off hold"), G_CALLBACK (call_hold) },
{ "InstantMessaging", GTK_STOCK_IM, N_("Send _message"), "<control>M",
N_("Send message"), G_CALLBACK (call_im) },
{ "AccountAssistant", NULL, N_("Configuration _Assistant"), NULL,
N_("Run the configuration assistant"),
G_CALLBACK (call_configuration_assistant) },
......@@ -1012,6 +1035,7 @@ show_popup_menu(GtkWidget *my_widget, GdkEventButton *event)
gboolean pickup = FALSE, hangup = FALSE, hold = FALSE, copy = FALSE, record =
FALSE, detach = FALSE;
gboolean accounts = FALSE;
gboolean im = FALSE;
// conference type boolean
gboolean hangup_conf = FALSE, hold_conf = FALSE;
......@@ -1054,6 +1078,7 @@ show_popup_menu(GtkWidget *my_widget, GdkEventButton *event)
hold = TRUE;
record = TRUE;
detach = TRUE;
im = TRUE;
break;
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
......@@ -1182,6 +1207,22 @@ show_popup_menu(GtkWidget *my_widget, GdkEventButton *event)
gtk_widget_show(menu_items);
}
if (im)
{
menu_items = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items);
gtk_widget_show(menu_items);
menu_items = gtk_image_menu_item_new_with_mnemonic(_("Send _message"));
image = gtk_image_new_from_stock(GTK_STOCK_IM, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
gtk_menu_shell_append(GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (call_im),
NULL);
gtk_widget_show(menu_items);
}
}
else
{
......
......@@ -4,7 +4,8 @@ noinst_LTLIBRARIES = libwidget.la
libwidget_la_SOURCES = \
gtkscrollbook.c \
minidialog.c
minidialog.c \
imwidget.c
libwidget_la_LDFLAGS = @DEPS_LDFLAGS@
......
/*
* Copyright (C) 2010 Savoir-Faire Linux Inc.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, 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.
*/
#include "imwidget.h"
#include <JavaScriptCore/JavaScript.h>
#define WEBKIT_DIR "file://" DATA_DIR "/webkit/"
void
im_widget_add_message(GtkWidget *widget, const gchar *message)
{
IMWidget *im = IM_WIDGET(widget);
gchar *script = g_strdup_printf("add_message('%s');", message);
webkit_web_view_execute_script(WEBKIT_WEB_VIEW(im->web_view), script);
g_free(script);
}
static gboolean
web_view_nav_requested_cb(
WebKitWebView *web_view,
WebKitWebFrame *frame,
WebKitNetworkRequest *request,
WebKitWebNavigationAction *navigation_action,
WebKitWebPolicyDecision *policy_decision,
gpointer user_data)
{
const gchar *uri = webkit_network_request_get_uri(request);
/* Always allow files we are serving ourselves. */
if (!strncmp(uri, WEBKIT_DIR, sizeof(WEBKIT_DIR) - 1)) {
webkit_web_policy_decision_use(policy_decision);
} else {
printf("FIXME(jonas) open URL in browser: %s\n", uri);
webkit_web_policy_decision_ignore(policy_decision);
}
return TRUE;
}
static void
im_widget_class_init(IMWidgetClass *klass)
{
}
static void
im_widget_init(IMWidget *im)
{
im->textarea = gtk_text_view_new();
gtk_text_view_set_editable(GTK_TEXT_VIEW(im->textarea), TRUE);
GtkWidget *textscrollwin = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(textscrollwin),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(textscrollwin), im->textarea);
im->web_view = webkit_web_view_new();
GtkWidget *webscrollwin = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(webscrollwin),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(webscrollwin), im->web_view);
g_signal_connect(im->web_view, "navigation-policy-decision-requested",
G_CALLBACK (web_view_nav_requested_cb), NULL);
gtk_box_pack_start(GTK_BOX(im), webscrollwin, TRUE, TRUE, 5);
gtk_box_pack_end(GTK_BOX(im), textscrollwin, TRUE, TRUE, 5);
im->web_frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(im->web_view));
im->js_context = webkit_web_frame_get_global_context(im->web_frame);
im->js_global = JSContextGetGlobalObject(im->js_context);
webkit_web_view_open(WEBKIT_WEB_VIEW(im->web_view), "file://" DATA_DIR "/webkit/im/im.html");
}
GtkWidget *
im_widget_new()
{
return GTK_WIDGET(g_object_new(IM_WIDGET_TYPE, NULL));
}
GType
im_widget_get_type(void)
{
static GType im_widget_type = 0;
if (!im_widget_type) {
static const GTypeInfo im_widget_info = {
sizeof (IMWidgetClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) im_widget_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (IMWidget),
0,
(GInstanceInitFunc) im_widget_init,
NULL /* value_table */
};
im_widget_type = g_type_register_static(
GTK_TYPE_VBOX,
"IMWidget",
&im_widget_info,
0);
}
return im_widget_type;
}
/*
* Copyright (C) 2010 Savoir-Faire Linux Inc.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, 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 __IM_WIDGET_H__
#define __IM_WIDGET_H__
#include <gtk/gtk.h>
#include <webkit/webkit.h>
G_BEGIN_DECLS
#define IM_WIDGET_TYPE (im_widget_get_type())
#define IM_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), IM_WIDGET_TYPE, IMWidget))
#define IM_WIDGET_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST((vtable), IM_WIDGET_TYPE, IMWidgetClass))
#define IS_IM_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), IM_WIDGET_TYPE))
#define IS_IM_WIDGET_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE((vtable), IM_WIDGET_TYPE))
#define IM_WIDGET_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS((inst), IM_WIDGET_TYPE, IMWidgetClass))
typedef struct _IMWidget IMWidget;
typedef struct _IMWidgetClass IMWidgetClass;
struct _IMWidget {
GtkVBox parent_instance;
/* Private */
GtkWidget *textarea;
GtkWidget *web_view;
WebKitWebFrame *web_frame; // Our web frame
JSGlobalContextRef js_context; // The frame's global JS context
JSObjectRef js_global; // The frame's global context JS object
};
struct _IMWidgetClass {
GtkContainerClass parent_class;
};
GType im_widget_get_type(void) G_GNUC_CONST;
GtkWidget *im_widget_new(void);
void im_widget_add_message(GtkWidget *im, const gchar *message);
G_END_DECLS
#endif /* __IM_WIDGET_H__ */
/*
* Copyright (C) 2010 Savoir-Faire Linux Inc.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, 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.
*/
#include "imwidget.h"
#include <JavaScriptCore/JavaScript.h>
static void im_widget_init(IMWidget *im);
static void im_widget_class_init(IMWidgetClass *klass);
GType
im_widget_get_type (void)
{
static GType im_widget_type = 0;
if (!im_widget_type) {
static const GTypeInfo im_widget_info = {
sizeof (IMWidgetClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) im_widget_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (IMWidget),
0,
(GInstanceInitFunc) im_widget_init,
NULL /* value_table */
};
im_widget_type = g_type_register_static(
WEBKIT_TYPE_WEB_VIEW,
"IMWidget",
&im_widget_info,
0);
}
return im_widget_type;
}
static void
im_widget_class_init (IMWidgetClass *klass)
{
}
static void
im_widget_init (IMWidget *im)
{
/* Load our initial webpage on startup */
webkit_web_view_open(WEBKIT_WEB_VIEW(im), "file://" DATA_DIR "/webkit/im.html");
/* Instantiate our local webkit related variables */
im->web_frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(im));
im->js_context = webkit_web_frame_get_global_context(im->web_frame);
im->js_global = JSContextGetGlobalObject(im->js_context);
}
GtkWidget *
im_widget_new()
{
return GTK_WIDGET(g_object_new(IM_WIDGET_TYPE, NULL));
}
/*
* Copyright (C) 2010 Savoir-Faire Linux Inc.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, 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 __WEB_WIDGET_H__
#define __WEB_WIDGET_H__
#include <gtk/gtk.h>
#include <webkit/webkit.h>
G_BEGIN_DECLS
#define WEB_WIDGET_TYPE (im_widget_get_type())
#define WEB_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEB_WIDGET_TYPE, WebWidget))
#define IM_WIDGET_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST((vtable), IM_WIDGET_TYPE, WebWidgetClass))
#define IS_IM_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), IM_WIDGET_TYPE))
#define IS_IM_WIDGET_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE((vtable), IM_WIDGET_TYPE))
#define IM_WIDGET_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS((inst), IM_WIDGET_TYPE, WebWidgetClass))
typedef struct _WebWidget WebWidget;
typedef struct _WebWidgetClass WebWidgetClass;
struct _WebWidget {
WebKitWebView parent_instance;
/* Private */
WebKitWebFrame *web_frame; // Our web frame
JSGlobalContextRef js_context; // The frame's global JS context
JSObjectRef js_global; // The frame's global context JS object
};
struct _WebWidgetClass {
WebKitWebViewClass parent_class;
};
GType im_widget_get_type (void) G_GNUC_CONST;
GtkWidget *im_widget_new (void);
G_END_DECLS
#endif /* __IM_WIDGET_H__ */
include ../globals.mak
EXTRA_DIST = $(im_DATA)
webkitdir = $(datadir)/sflphone/webkit
imdir = $(webkitdir)/im
im_DATA = im/im.js im/im.html im/im.css
.message {
-webkit-border-radius: 5px;
background: green;
color: white;
padding: 1em;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment