[prev in list] [next in list] [prev in thread] [next in thread]
List: moblin-commits
Subject: [Moblin-Commits] mobile-basic-flash: Changes to 'master'
From: bspencer () moblin ! org (Bob Spencer)
Date: 2008-04-28 22:14:39
Message-ID: 20080429051437.966B692C07F () moblin ! org
[Download RAW message or body]
configure.ac | 2 +-
src/Makefile.am | 2 +-
src/mobile-basic-home-plugin.c | 1188 ------------------------------------
src/mobile-basic-home-plugin.cpp | 1225 ++++++++++++++++++++++++++++++++++++++
4 files changed, 1227 insertions(+), 1190 deletions(-)
New commits:
commit 4b914c7687418d5ba4d2062c32d4f1a4f6f43638
Author: Bob Spencer <bob.spencer@intel.com>
Date: Mon Apr 28 22:14:11 2008 -0700
Applied patches from asac for moving to xulrunner 1.9
Diff in this email is a maximum of 400 lines.
diff --git a/configure.ac b/configure.ac
index 3627b74..3f38d14 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,7 +42,7 @@ PKG_CHECK_MODULES(LIBXML, libxml-2.0)
AC_SUBST(LIBXML_LIBS)
AC_SUBST(LIBXML_CFLAGS)
-PKG_CHECK_MODULES(MOZEMBED, xulrunner-gtkmozembed >= 1.8.1)
+PKG_CHECK_MODULES(MOZEMBED, mozilla-gtkmozembed-embedding >= 1.8.1)
AC_SUBST(MOZEMBED_LIBS)
AC_SUBST(MOZEMBED_CFLAGS)
diff --git a/src/Makefile.am b/src/Makefile.am
index c6a610b..f51af20 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,6 +15,6 @@ hildonhomeentry_DATA = mobile-basic-home.desktop
libmobilebasichome_la_LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(LIBXML_LIBS) \
$(LIBOSSO_LIBS) $(LIBHILDONDESKTOP_LIBS) $(LIBHILDONWM_LIBS) $(MOZEMBED_LIBS) \
$(LIBWNCK_LIBS)
-libmobilebasichome_la_SOURCES = mobile-basic-home-plugin.c windowhelper.c
+libmobilebasichome_la_SOURCES = mobile-basic-home-plugin.cpp windowhelper.c
CLEANFILES = *~ *.la *.desktop *.o *.so
diff --git a/src/mobile-basic-home-plugin.c b/src/mobile-basic-home-plugin.c
deleted file mode 100644
index 0e3ac50..0000000
--- a/src/mobile-basic-home-plugin.c
+++ /dev/null
@@ -1,1188 +0,0 @@
-/*
- * This plugin based on the example dummy plugin from the Maemo
- * maemo-af-desktop repository. Original copyright declaration:
- * Lucas Rocha <lucas.rocha@nokia.com>
- * Copyright 2006 Nokia Corporation.
- *
- * Modifcations transform the example to an embedded mozilla home applet:
- * Bob Spencer <bob.spencer@intel.com>
- * Copyright 2007 Intel Corporation
- *
- * Contributors:
- * Michael Frey <michael.frey@pepper.com>
- * Rusty Lynch <rusty.lynch@intel.com>
- * Horace Li <horace.li@intel.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <sys/resource.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <glib.h>
-#include <glib/gstdio.h>
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-#include <glib-object.h>
-#include <libxml/parser.h>
-
-#include "mobile-basic-home-plugin.h"
-#include "gtkmozembed.h"
-
-#include <libhildondesktop/libhildondesktop.h>
-#include <libhildonwm/hd-wm.h>
-#include <libosso.h>
-#include <hildon/hildon-banner.h>
-#include <hildon/hildon-note.h>
-
-#define FILE_URL_PREFIX "file://"
-#define PROFILE_DIR "/usr/share/mobile-basic-flash"
-#define HOME_HTML "home.html"
-
-#define PROFILE_NAME "mozapplet"
-#define MARQUEE_HEIGHT 52
-#define DESKTOP_FILE_SUFFIX ".desktop"
-#define DESKTOP_GROUP "Desktop Entry"
-
-#define DESKTOP_DIR "/usr/share/applications"
-
-#define APPLICATIONS_MENU "/etc/xdg/menus/applications.menu"
-#define PREFERENCES_MENU "/etc/xdg/menus/preferences.menu"
-
-//TBD: use theme pattern to get fonts
-#define PIXMAP_DIR "/usr/share/pixmaps"
-
-//TBD: use gconf header to replace all gconf defines
-#define BKGD_PATH "/desktop/moblin/background"
-#define BKGD_FILE BKGD_PATH "/picture_filename"
-#define BKGD_PIC_OPTIONS BKGD_PATH "/picture_options"
-#define BKGD_PRIMARY_COLOR BKGD_PATH "/primary_color"
-
-#define INTERFACE_PATH "/desktop/gnome/interface"
-#define GTK_THEME INTERFACE_PATH "/gtk_theme"
-#define ICON_THEME INTERFACE_PATH "/icon_theme"
-#define FONT_NAME INTERFACE_PATH "/font_name"
-
-//gconf location of custom flash movie, and hide/show marquee
-#define HILDON_DESKTOP_GCONF_PATH "/desktop/hildon"
-#define MARQUEE_KEY HILDON_DESKTOP_GCONF_PATH "/marquee/hide"
-#define HOMEPAGE_KEY HILDON_DESKTOP_GCONF_PATH "/htmlhomeplugin/homepage"
-#define FLASHMOVIE_KEY HILDON_DESKTOP_GCONF_PATH "/htmlhomeplugin/flashmoviename"
-#define ONLYSHOWIN_FILTER_KEY HILDON_DESKTOP_GCONF_PATH \
"/htmlhomeplugin/onlyshowin_filter"
-#define ONLYSHOWIN_IGNORE_KEY HILDON_DESKTOP_GCONF_PATH \
"/htmlhomeplugin/onlyshowin_ignore"
-
-#define MARQUEE_GCONF_PATH "/apps/marquee-plugins"
-#define ACTIVE_CAT_KEY MARQUEE_GCONF_PATH "/active"
-#define CATEGORIES_KEY MARQUEE_GCONF_PATH "/categories"
-
-#define UNKNOWN_ICON_NAME "unknown"
-
-#define DialogDestroy 111
-
-#define MB_HOME_PLUGIN_GET_PRIVATE(object) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((object), MOBILE_BASIC_TYPE_HOME_PLUGIN, \
MobileBasicHomePluginPrivate))
-
-HD_DEFINE_PLUGIN (MobileBasicHomePlugin, mobile_basic_home_plugin, \
HILDON_DESKTOP_TYPE_HOME_ITEM);
-
-static GtkWidget* launch_banner = NULL;
-
-typedef struct {
- int index;
- gchar *plugin;
- gchar *name;
- gchar *icon;
- gchar *exec;
- gchar *service;
- gchar *filename;
- gchar *id;
- gchar *cat;
-} application_entry_t;
-
-struct _plugin_context_t {
- GtkWidget *container;
- GList *app_list;
- GHashTable *cat_table;
- osso_context_t *osso_context;
- GConfClient *client;
- const char *active;
-};
-
-extern void init_window_helper (plugin_context_t *context);
-static GdkFilterReturn mobile_basic_home_x_event_handler (GdkXEvent *xevent, \
GdkEvent *event, gpointer data);
-static void home_screen_changed (HildonDesktopHomeItem *item);
-static void start_plugin(plugin_context_t *, gchar*);
-
-void hide_banner(void);
-void net_stop_cb (GtkMozEmbed *embed, gpointer data);
-void js_status_cb (GtkMozEmbed *embed, gpointer data);
-gint compare_items(gconstpointer a, gconstpointer b);
-static gboolean is_app_in_ignore_list (GSList *ignore_list, gchar *app);
-
-// escape " and '
-static gchar *strescape_quotes (gchar *src) {
- int len = strlen(src);
- gchar *tmp = malloc ((len*2)+1);
- int j=0;
- for (int i=0; i<len; i++,j++) {
- if (src[i]=='\'' || src[i]=='"') {
- tmp[j++]='\\';
- }
- tmp[j]=src[i];
- }
- tmp[j]='\0';
- return tmp;
-}
-
-static void update_background(plugin_context_t *context) {
- gchar *pic, *opt, *color;
-
- pic = gconf_client_get_string (context->client,BKGD_FILE,NULL);
- opt = gconf_client_get_string (context->client,BKGD_PIC_OPTIONS,NULL);
- color = gconf_client_get_string (context->client,BKGD_PRIMARY_COLOR,NULL);
-
- //if a picture is selected (not "no Wallpaper"), make sure it is valid
- if ((pic != NULL) &&
- (!g_utf8_validate(pic, -1, NULL) || !g_file_test(pic, G_FILE_TEST_EXISTS))) {
- pic = g_filename_from_utf8 (pic, -1, NULL,NULL, NULL);
- }
-
- //escape quotes
- if (pic) {
- gchar *tmp = pic;
- pic = strescape_quotes (tmp);
- g_free (tmp);
- }
-
- gchar *url = g_strdup_printf("javascript:setBackground(['%s', '%s', '%s'])",
- pic, opt, color);
-
- gtk_moz_embed_load_url(GTK_MOZ_EMBED(context->container), url);
- g_free(url);
-
- if (pic) {
- g_free (pic);
- }
- if (opt) {
- g_free (opt);
- }
- if (color) {
- g_free (color);
- }
-}
-
-
-static void update_theme(plugin_context_t *context) {
-
- gchar *theme, *icon_theme, *font;
- theme = gconf_client_get_string (context->client, GTK_THEME, NULL);
- icon_theme = gconf_client_get_string (context->client, ICON_THEME, NULL);
- font = gconf_client_get_string (context->client, FONT_NAME, NULL);
-
- //a little hack -- Human is default now, but it doesn't exist.
- if (!theme || (!strcmp (theme, "Human"))) {
- theme = g_strdup ("mobilebasic");
- }
- if (!icon_theme) {
- icon_theme = g_strdup ("hicolor");
- }
- gchar *url = g_strdup_printf("javascript:setThemeValues(['%s', '%s', '%s'])",
- theme, icon_theme, font);
- gtk_moz_embed_load_url(GTK_MOZ_EMBED(context->container), url);
- g_free(url);
-
- if (theme) {
- g_free (theme);
- }
- if (icon_theme) {
- g_free (icon_theme);
- }
- if (font) {
- g_free (font);
- }
-}
-
-static void dump_application(gpointer data, gpointer ignore)
-{
- application_entry_t *item = (application_entry_t *)data;
- g_print("app[%i] = %s\n", item->index, item->exec);
-}
-
-static void __add_application(plugin_context_t *c, application_entry_t *i)
-{
- gchar *url = g_strdup_printf("javascript:addApp([%i, '%s', '%s'])",
- i->index,
- i->name,
- i->icon);
- gtk_moz_embed_load_url(GTK_MOZ_EMBED(c->container), url);
- g_free(url);
- return;
-}
-
-static void add_application(gpointer data, gpointer payload)
-{
- application_entry_t *item = (application_entry_t *)data;
- plugin_context_t *c = (plugin_context_t *)payload;
-
- if (!g_ascii_strcasecmp("All", c->active)) {
- if (g_ascii_strcasecmp(item->cat, "Preferences"))
- __add_application(c, item);
- }
- else {
- if (!g_ascii_strcasecmp(item->cat, c->active))
- __add_application(c, item);
- }
- return;
-}
-
-static gboolean init_program(plugin_context_t *c)
-{
- gchar *url;
-
- update_background(c);
- update_theme(c);
- url = g_strdup_printf("javascript:launchDesktop()");
- gtk_moz_embed_load_url(GTK_MOZ_EMBED(c->container), url);
- g_free(url);
-
- return FALSE;
-}
-
-void hide_banner (void)
-{
- if (launch_banner != NULL) {
- gtk_widget_destroy(launch_banner);
- launch_banner = NULL;
- }
-}
-
-static void show_banner (const gchar *msg)
-{
- // make sure we are not already showing a launchBanner
- hide_banner();
-
- // now show a new launch banner
- launch_banner = hildon_banner_show_animation(NULL, NULL, msg);
- gtk_window_set_position(GTK_WINDOW (launch_banner), \
GTK_WIN_POS_CENTER_ALWAYS);
-}
-
-//this function parses a full exec string and returns the first portion
-//before the space
-static gchar *parse_exec(const gchar *exec_name)
-{
- if (exec_name == NULL) {
- return NULL;
- }
-
- gchar *space = strchr(exec_name, ' ');
- if (space) {
- gchar *cmd = g_strdup (exec_name);
- cmd[space - exec_name] = 0;
- return cmd;
- }
-
- return g_strdup (exec_name);
-}
-
-//find a running app with same name/exec path as item passed in
-static HDWMEntryInfo* find_running_app(application_entry_t *item)
-{
- // check if app is already running, if so show it..
- GList *applications_list = NULL;
- HDWMApplication *app = NULL;
- HDWMEntryInfo *app_info = NULL;
- HDWM *hdwm = hd_wm_get_singleton();
-
- // get list of running applications, the app_info for the running
- // app is based on what is defined in /usr/share/applications/*.desktop
- // Specifically, the StartupWMClass attribute needs to be correct
- // in the desktop file or else the app_info won't be correct in this list
- applications_list = hd_wm_get_applications (hdwm);
-
- guint len = g_list_length(applications_list);
- printf ("find_running_app #running apps=%i\n", len);
-
- for (int i = 0; i < len; i++) {
-
- app = HD_WM_APPLICATION(g_list_nth_data(applications_list, i));
- const gchar *app_name = hd_wm_application_get_name(app);
- //get the first part of the exec before the space
- gchar *exec_name = parse_exec(hd_wm_application_get_exec(app));
- const gchar *class_name = hd_wm_application_get_class_name(app);
-
- g_debug("searching appName=%s execName=%s className=%s appInfo=%p\n",
- app_name, exec_name, class_name,
- HD_WM_ENTRY_INFO(hd_wm_application_get_active_window(app)));
-
- gchar *item_exec_name = parse_exec(item->exec);
-
- // look for match based on exec command or name
- if ((exec_name != NULL && (!g_ascii_strcasecmp(item_exec_name, exec_name))) ||
- (app_name != NULL && (!g_ascii_strcasecmp(item->name, app_name))))
- {
-
- app_info = HD_WM_ENTRY_INFO(hd_wm_application_get_active_window(app));
- g_debug("found already running returning app_name=%s app_exec=%s \
app_info=%p\n",
- item->name, item_exec_name, app_info);
-
- g_free(exec_name);
- g_free(item_exec_name);
-
- return app_info;
- }
-
- g_free(exec_name);
- g_free(item_exec_name);
-
- }
-
- g_print("could not find match for app=%s\n", item->name);
-
- return NULL;
-}
-
-
-//Called to launch the application
-//static void start_app(const gchar *app)
-static void launch_app(plugin_context_t *c, application_entry_t *item)
-{
- gchar *program = NULL;
- GError *error = NULL;
- gint argc;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic