--- Begin Message ---
Author: zhiyong_sun
Date: 2007-03-08 07:14:44 +0100 (Thu, 08 Mar 2007)
New Revision: 1268
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/app-history.c
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/app-history.h
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/callbacks.c
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/callbacks.h
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.c
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.h
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.c
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.h
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mainmenu.c
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokodesktop.c
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokodesktop.h
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokoiconview.c
Log:
add launch history applications function & some small modfiy
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/app-history.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/app-history.c
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/app-history.c
2007-03-08 06:14:44 UTC (rev 1268)
@@ -20,8 +20,9 @@
*/
#include "app-history.h"
+#include "callbacks.h"
-static int current = 0;
+static gint current = 0;
static void
pointer_check()
@@ -32,15 +33,55 @@
current = 0;
}
-void
-moko_hisory_app_fill(MokoPixmapButton **btn, const char *path)
+MokoAppHistory *
+moko_app_history_init (MokoFingerToolBox *toolbox)
{
- GtkWidget *image;
- image = gtk_image_new_from_file (path);
+ gint i = 0;
+ MokoAppHistory *self;
- if (!path)
- return;
- pointer_check();
- moko_pixmap_button_set_finger_toolbox_btn_center_image(btn[current], image);
- current++;
+ if (!toolbox)
+ return NULL;
+
+ self = g_malloc0 (sizeof (MokoAppHistory));
+
+ if (!self)
+ return NULL;
+
+ for (i; i<MAX_RECORD_APP; i++)
+ {
+ self->btn[i] = moko_finger_tool_box_add_button_without_label (toolbox);
+ g_signal_connect( G_OBJECT(self->btn[i]), "clicked",
G_CALLBACK(moko_tool_box_btn_clicked_cb), self);
+ gtk_widget_show (self->btn[i]);
+ self->item[i] = NULL;
+ }
+
+ return self;
}
+
+gboolean
+moko_app_history_set (MokoAppHistory *self, GdkPixbuf *pixbuf, MokoDesktopItem
*item)
+{
+ if (!self || !pixbuf)
+ return FALSE;
+
+ pointer_check ();
+
+ moko_pixmap_button_set_finger_toolbox_btn_center_image_pixbuf
(self->btn[current], pixbuf);
+
+ if (item)
+ self->item[current] = item;
+ else
+ self->item[current] = NULL;
+
+ current ++;
+
+ return TRUE;
+}
+
+void
+moko_app_history_free (MokoAppHistory *self)
+{
+ if (self)
+ g_free (self);
+ return;
+}
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/app-history.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/app-history.h
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/app-history.h
2007-03-08 06:14:44 UTC (rev 1268)
@@ -21,15 +21,38 @@
#ifndef _MOKO_APP_HISTORY_H
#define _MOKO_APP_HISTORY_H
+#include "mokodesktop.h"
#include <libmokoui/moko-pixmap-button.h>
+#include <libmokoui/moko-finger-tool-box.h>
-#define MAX_RECORD_APP 4
+#define MAX_RECORD_APP 4
+typedef struct {
+ MokoDesktopItem *item[MAX_RECORD_APP];
+ MokoPixmapButton *btn[MAX_RECORD_APP];
+} MokoAppHistory;
+
/**
- * @brief moko_history_app_fill
- * @param btn MokoPixmapButton **
- * @param path const char *
- * @return NONE
+ * @brief moko_history_app_init
+ * @param toolboox MokoFingerToolBox *
+ * @return MokoAppHistory instance
*/
-void moko_hisory_app_fill(MokoPixmapButton **btn, const char *path);
+MokoAppHistory * moko_app_history_init (MokoFingerToolBox *toolbox);
+
+/**
+ * @brief moko_history_app_set
+ * @param self MokoAppHistory *,
+ * @param path const char *,
+ * @param item MokoDesktopItem *,
+ * @return gboolean
+ */
+gboolean moko_app_history_set (MokoAppHistory *self, GdkPixbuf *pixbuf,
MokoDesktopItem *item);
+
+/**
+ * @brief moko_app_history_free
+ * @brief self MokoAppHistory *,
+ * @return none
+ */
+void moko_app_history_free (MokoAppHistory *self);
+
#endif /*_MOKO_APP_HISTORY_H*/
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/callbacks.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/callbacks.c
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/callbacks.c
2007-03-08 06:14:44 UTC (rev 1268)
@@ -31,6 +31,7 @@
#include "mokodesktop_item.h"
#include "app-history.h"
+static void moko_cb_run_app (const char * data);
void
moko_wheel_bottom_press_cb (GtkWidget *self, MokoMainmenuApp *mma)
@@ -39,14 +40,11 @@
{
mma->mm->current = mokodesktop_item_get_parent(mma->mm->current);
moko_main_menu_update_content (mma->mm, mma->mm->current);
- gtk_window_present (mma->window);
}
else
{
- gtk_widget_hide (GTK_WIDGET (mma->wheel));
- gtk_widget_hide (GTK_WIDGET (mma->toolbox));
- gtk_widget_hide (GTK_WIDGET (mma->window));
- moko_dbus_send_message ("");
+ gtk_window_iconify (GTK_WINDOW (mma->window));
+ moko_dbus_send_message ("");
}
}
@@ -54,15 +52,11 @@
moko_wheel_left_up_press_cb (GtkWidget *self, MokoMainmenuApp *mma)
{
g_signal_emit_by_name (G_OBJECT(mma->mm->icon_view), "move-cursor",
GTK_MOVEMENT_DISPLAY_LINES, -1);
- //gtk_window_present (mma->window);
- //gtk_widget_grab_focus (mma->mm->icon_view);
-
}
void
moko_wheel_right_down_press_cb (GtkWidget *self, MokoMainmenuApp *mma)
{
- //gtk_widget_grab_focus (mma->mm->icon_view);
g_signal_emit_by_name (G_OBJECT(mma->mm->icon_view), "move-cursor",
GTK_MOVEMENT_DISPLAY_LINES, 1);
}
@@ -70,45 +64,29 @@
moko_icon_view_item_acitvated_cb(MokoIconView *icon_view,
GtkTreePath *path, MokoMainmenuApp *mma)
{
- g_debug ("call moko_item_acitvated_cb");
- MokoDesktopItem *select_item = mokodesktop_item_get_child
(mma->mm->current);
- gint index, i;
+ MokoDesktopItem *selected_item = NULL;
+ GtkTreeModel *tree_model;
+ GtkTreeIter iter;
+
+ tree_model = moko_icon_view_get_model (icon_view);
+ gtk_tree_model_get_iter (tree_model, &iter, path);
+ gtk_tree_model_get (tree_model, &iter, OBJECT_COLUMN, &selected_item,
-1);
- index = moko_icon_view_get_cursor_positon (icon_view);
-
- for (i = 1; i < index; i++)
+ if (selected_item->type == ITEM_TYPE_FOLDER)
{
- select_item = mokodesktop_item_get_next_sibling (select_item);
+ mma->mm->current = selected_item;
+ moko_main_menu_update_content (mma->mm, selected_item);
}
+ else if (selected_item->type == ITEM_TYPE_DOTDESKTOP_ITEM
||selected_item->type == ITEM_TYPE_APP)
+ {
+ GdkPixbuf *pixbuf;
+ moko_cb_run_app (selected_item->data);
- g_debug ("select_item name %s TYPE is %d", select_item->name,
select_item->type);
+ gtk_tree_model_get (tree_model, &iter, PIXBUF_COLUMN, &pixbuf,
-1);
- if (select_item->type == ITEM_TYPE_FOLDER)
- {
- mma->mm->current = select_item;
- g_debug ("current name %s------------------", mma->mm->current->name);
- moko_main_menu_update_content (mma->mm, select_item);
+ if (pixbuf)
+ moko_app_history_set (mma->history, pixbuf, selected_item);
}
- else if (select_item->type == ITEM_TYPE_DOTDESKTOP_ITEM
||select_item->type == ITEM_TYPE_APP)
- {
- switch (fork())
- {
- case 0:
- mb_exec((char *)select_item->data);
- fprintf(stderr, "exec failed, cleaning up child\n");
- exit(1);
- case -1:
- fprintf(stderr, "can't fork\n");
- break;
- }
-
- char path[512];
- snprintf (path, 512, "%s/%s", PIXMAP_PATH, select_item->icon_name);
- g_debug ("-------select_item path: %s", path);
- moko_hisory_app_fill (mma->history, path);
- }
-
- moko_icon_view_selection_changed_cb (mma->mm->icon_view, mma);
}
void
@@ -117,33 +95,60 @@
{
GList *selected_item;
GtkTreeIter iter;
- GtkTreePath *path;
GtkTreeModel *icon_view_model;
gchar *text;
selected_item = moko_icon_view_get_selected_items (iconview);
if (!selected_item)
- g_debug ("Can't get mokoiconview selected item");
- else
- {
- icon_view_model = moko_icon_view_get_model (iconview);
- gtk_tree_model_get_iter (icon_view_model, &iter, selected_item->data);
+ return;
- gtk_tree_model_get (icon_view_model, &iter,
- TEXT_COLUMN , &text,
- -1);
+ icon_view_model = moko_icon_view_get_model (iconview);
+ gtk_tree_model_get_iter (icon_view_model, &iter, selected_item->data);
+ gtk_tree_model_get (icon_view_model, &iter, TEXT_COLUMN , &text, -1);
- if (text)
- {
- moko_dbus_send_message (text);
- free (text);
- }
+ if (text)
+ {
+ moko_dbus_send_message (text);
+ }
- g_list_foreach (selected_item, gtk_tree_path_free, NULL);
- g_list_free (selected_item);
- }
+ g_list_foreach (selected_item, gtk_tree_path_free, NULL);
+ g_list_free (selected_item);
moko_main_menu_update_item_total_label (mma->mm);
}
+void
+moko_tool_box_btn_clicked_cb (GtkButton *btn, MokoAppHistory *history)
+{
+ MokoDesktopItem *selected_item;
+ gint i = 0;
+
+ if (!btn || !history)
+ return;
+
+ for (i; i<MAX_RECORD_APP; i++)
+ {
+ if (history->btn[i] == btn)
+ selected_item = history->item[i];
+ else continue;
+ }
+
+ if (selected_item)
+ {
+ moko_cb_run_app (selected_item->data);
+ }
+}
+
+static void
+moko_cb_run_app (const char * data)
+{
+ switch (fork())
+ {
+ case 0 :
+ system (data);
+ exit (1);
+ case -1 :
+ break;
+ }
+}
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/callbacks.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/callbacks.h
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/callbacks.h
2007-03-08 06:14:44 UTC (rev 1268)
@@ -21,6 +21,10 @@
#ifndef _MAIN_MENU_CALLBACKS_H
#define _MAIN_MENU_CALLBACKS_H
+
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE
+
#include <gtk/gtk.h>
#include "main.h"
@@ -34,13 +38,13 @@
void moko_down_btn_cb (GtkButton *button, MokoMainMenu *mm);
-void moko_item_select_cb(MokoIconView *icon_view,
- GtkTreePath *path, MokoMainmenuApp *mma);
+void moko_item_select_cb(MokoIconView *icon_view, GtkTreePath *path,
MokoMainmenuApp *mma);
-void moko_icon_view_item_acitvated_cb(MokoIconView *iconview,
- GtkTreePath *path, MokoMainmenuApp *mma);
+void moko_icon_view_item_acitvated_cb(MokoIconView *iconview, GtkTreePath
*path, MokoMainmenuApp *mma);
-void moko_icon_view_selection_changed_cb(MokoIconView *iconview,
- MokoMainmenuApp *mma);
+void moko_icon_view_selection_changed_cb(MokoIconView *iconview,
MokoMainmenuApp *mma);
+void moko_tool_box_btn_clicked_cb (GtkButton *btn, MokoAppHistory *history);
+
+#endif /*_XOPEN_SOURCE*/
#endif /*_MAIN_MENU_CALLBACKS_H*/
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.c
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.c
2007-03-08 06:14:44 UTC (rev 1268)
@@ -26,7 +26,7 @@
gboolean
moko_dbus_connect_init (void)
{
- /* Get a connection to the session bus */
+ /* Get a connection to the system bus */
dbus_error_init (&error);
bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
@@ -38,7 +38,7 @@
if (dbus_error_is_set (&error))
{
- fprintf(stdout, "Connection Error (%s)\n", error.message);
+ g_warning ("Connection Error (%s)\n", error.message);
dbus_error_free (&error);
}
@@ -49,25 +49,19 @@
moko_dbus_send_message (const char *str)
{
DBusMessage *message;
- //char *str = "openmoko taskmanager";
/* Create a new signal on the "org.openmoko.dbus.TaskManager" interface,
* from the object "/org/openmoko/footer". */
message = dbus_message_new_signal ("/org/openmoko/footer",
"org.openmoko.dbus.TaskManager",
"push_statusbar_message");
- /* Append the string "openmoko taskmanager" to the signal */
+ /* Append the string to the signal */
dbus_message_append_args (message,
DBUS_TYPE_STRING, &str,
DBUS_TYPE_INVALID);
- /* Send the signal */
+
dbus_connection_send (bus, message, NULL);
- /* Free the signal now we have finished with it */
dbus_message_unref (message);
- /* Tell the user we send a signal */
- g_print("send signal\n");
-
- /* Return TRUE to tell the event loop we want to be called again */
return TRUE;
}
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.h
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.h
2007-03-08 06:14:44 UTC (rev 1268)
@@ -30,6 +30,6 @@
gboolean moko_dbus_connect_init (void);
-gboolean moko_send_message (const char *str);
+gboolean moko_dbus_send_message (const char *str);
#endif /*MOKO_DBUS_MESSAGE_SEND_H*/
Modified: trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.c
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.c
2007-03-08 06:14:44 UTC (rev 1268)
@@ -37,10 +37,8 @@
{
if (!mma)
return;
- gtk_widget_show_all (GTK_WIDGET(mma->window));
gtk_window_present (GTK_WINDOW(mma->window));
- gtk_widget_show (GTK_WIDGET(mma->wheel));
- gtk_widget_show (GTK_WIDGET(mma->toolbox));
+ moko_dbus_send_message ("Openmoko main menu");
signal (SIGUSR1, handle_sigusr1);
}
@@ -112,22 +110,21 @@
main( int argc, char** argv )
{
pid_t lockapp;
- int i;
lockapp = testlock (LOCK_FILE);
- g_debug ("lock app = %x", lockapp);
+
if (lockapp > 0)
{
kill (lockapp, SIGUSR1);
return 0;
}
+
setlock (LOCK_FILE);
- g_debug ("test");
mma = g_malloc0 (sizeof (MokoMainmenuApp));
if (!mma)
{
- fprintf (stderr, "openmoko-mainmenu application initialize FAILED");
+ g_error ("openmoko-mainmenu application initialize FAILED.");
exit (0);
}
memset (mma, 0, sizeof (MokoMainmenuApp));
@@ -135,18 +132,16 @@
if (!moko_dbus_connect_init ())
{
g_error ("Failed to initial dbus connection.");
- exit (0);
+ exit (0);
}
gtk_init( &argc, &argv );
-
/* application object */
mma->app = MOKO_APPLICATION(moko_application_get_instance());
g_set_application_name( "OpenMoko Main Menu" );
/* finger based window */
mma->window = MOKO_FINGER_WINDOW(moko_finger_window_new());
-// gtk_window_set_decorated (mma->window, FALSE);
gtk_widget_show (GTK_WIDGET (mma->window));
/* finger wheel object*/
@@ -156,11 +151,12 @@
/* finger toolbox object*/
mma->toolbox = moko_finger_window_get_toolbox(mma->window);
//initialize toolbox's buttons, which are MokoPixmapButton objects.
- for (i=0; i<4; i++)
- {
- mma->history[i] = moko_finger_tool_box_add_button_without_label
(mma->toolbox);
- gtk_widget_show (mma->history[i]);
- }
+ mma->history = moko_app_history_init (mma->toolbox);
+ if (!mma->history)
+ {
+ g_error ("Failed to get application history instance");
+ exit (0);
+ }
/* MokoMainMenu object */
mma->mm = moko_main_menu_new();
@@ -181,13 +177,9 @@
signal (SIGUSR1, handle_sigusr1);
- /* put MokoMainMenu object and MokoClosePange object into the finger based
window */
moko_finger_window_set_contents (mma->window, GTK_WIDGET(mma->mm));
-
- /* show everything and run main loop */
gtk_widget_show_all (GTK_WIDGET(mma->window) );
- /*show wheel toolbox MokoMainMenu objects first, and hide the
MokoClosePage object*/
gtk_widget_show (GTK_WIDGET (mma->wheel));
gtk_widget_show (GTK_WIDGET (mma->toolbox));
gtk_widget_show (GTK_WIDGET (mma->mm));
@@ -195,6 +187,10 @@
gtk_main();
if (mma)
- g_free (mma);
+ {
+ if (mma->history)
+ moko_app_history_free (mma->history);
+ g_free (mma);
+ }
return 0;
}
Modified: trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.h
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.h
2007-03-08 06:14:44 UTC (rev 1268)
@@ -22,6 +22,7 @@
#ifndef _MAIN_MENU_MAIN_H
#define _MAIN_MENU_MAIN_H
+
#include <libmokoui/moko-application.h>
#include <libmokoui/moko-finger-window.h>
#include <libmokoui/moko-finger-wheel.h>
@@ -41,7 +42,7 @@
MokoFingerWheel *wheel;
MokoFingerToolBox *toolbox;
MokoMainMenu *mm;
- MokoPixmapButton *history[MAX_RECORD_APP];
+ MokoAppHistory *history;
};
-#endif /*main.h*/
+#endif /*_MAIN_MENU_MAIN_H*/
Modified: trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mainmenu.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mainmenu.c
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mainmenu.c
2007-03-08 06:14:44 UTC (rev 1268)
@@ -202,6 +202,8 @@
gtk_list_store_append (store, &iter);
pixbuf = gdk_pixbuf_new_from_file_at_size (icon_path, PIXBUF_WIDTH,
PIXBUF_HEIGHT, NULL);// ADD Gerro handle later
+ if (!pixbuf)
+ return FALSE;
gtk_list_store_set (store, &iter, PIXBUF_COLUMN, pixbuf, TEXT_COLUMN,
icon_name, OBJECT_COLUMN, item, -1);
g_object_unref (pixbuf);
return TRUE;
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokodesktop.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokodesktop.c
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokodesktop.c
2007-03-08 06:14:44 UTC (rev 1268)
@@ -253,7 +253,6 @@
snprintf(app_paths[2], 256, "/usr/local/share/applications");
snprintf(app_paths[3], 256, "%s/.applications", mb_util_get_homedir());
-
if (getcwd(orig_wd, 255) == (char *)NULL)
{
fprintf(stderr, "Cant get current directory\n");
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokodesktop.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokodesktop.h
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokodesktop.h
2007-03-08 06:14:44 UTC (rev 1268)
@@ -18,12 +18,8 @@
#define VFOLDERDIR "/usr/share/matchbox"
#define DD_DIR "/usr/share/applications/"
-/* #define DD_DIR "/tmp/" */
-//#define PIXMAP_PATH PIXMAPSDIR
#define PIXMAP_PATH "/usr/share/pixmaps"
-
-
#ifdef DEBUG
#define DBG(txt, args... ) fprintf(stderr, "DT-DEBUG: " txt , ##args )
#else
@@ -58,16 +54,16 @@
typedef struct _mokodesktop_item {
- int type;
- int subtype; /* user defined type */
+ int type;
+ int subtype; /* user defined type */
- char *name;
- char *name_extended;
- char *comment;
- char *icon_name;
- void *data;
+ char *name;
+ char *name_extended;
+ char *comment;
+ char *icon_name;
+ void *data;
- MokoDesktopCB activate_cb;
+ MokoDesktopCB activate_cb;
struct _mokodesktop_item *item_next_sibling;
struct _mokodesktop_item *item_prev_sibling;
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokoiconview.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokoiconview.c
2007-03-07 21:19:10 UTC (rev 1267)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokoiconview.c
2007-03-08 06:14:44 UTC (rev 1268)
@@ -985,7 +985,6 @@
icon_view->priv->max_text_len = 30;
icon_view->priv->decr_width = 10;
icon_view->priv->decorated = FALSE;
- icon_view->priv->activate = FALSE;
pango_layout_set_wrap (icon_view->priv->layout, PANGO_WRAP_WORD_CHAR);
@@ -1585,24 +1584,9 @@
}
- if (dirty)
- g_signal_emit (icon_view, moko_icon_view_signals[SELECTION_CHANGED], 0);
-
- return event->button == 1;
-}
-
-static gboolean
-moko_icon_view_button_release (GtkWidget *widget,
- GdkEventButton *event)
-{
- MokoIconView *icon_view;
-
- icon_view = MOKO_ICON_VIEW (widget);
-
- if (event->button == 1 && event->type == GDK_BUTTON_RELEASE &&
icon_view->priv->activate ) //SUNZY : tabbing will launch "item-activated"
event
- {
- icon_view->priv->activate = FALSE;
- MokoIconViewItem *item = moko_icon_view_get_item_at_pos (icon_view,
+ if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
+ {
+ item = moko_icon_view_get_item_at_pos (icon_view,
event->x, event->y);
if (item && item == icon_view->priv->last_single_clicked)
@@ -1617,6 +1601,20 @@
icon_view->priv->last_single_clicked = NULL;
}
+ if (dirty)
+ g_signal_emit (icon_view, moko_icon_view_signals[SELECTION_CHANGED], 0);
+
+ return event->button == 1;
+}
+
+static gboolean
+moko_icon_view_button_release (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ MokoIconView *icon_view;
+
+ icon_view = MOKO_ICON_VIEW (widget);
+
#ifdef DND_WORKS
if (icon_view->priv->pressed_button == event->button)
{
--- End Message ---
--- Begin Message ---
Author: zhiyong_sun
Date: 2007-03-08 07:45:50 +0100 (Thu, 08 Mar 2007)
New Revision: 1269
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.c
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.c
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.h
Log:
remove ^M
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.c
2007-03-08 06:14:44 UTC (rev 1268)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/dbus-conn.c
2007-03-08 06:45:50 UTC (rev 1269)
@@ -1,67 +1,67 @@
-/**
- * @file dbus-conn.c
- * @brief dbus connection and message send for openmoko mainmenu
- *
- * Authored by Sun Zhiyong <[EMAIL PROTECTED]>
- *
- * Copyright (C) 2006-2007 OpenMoko Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Public License as published by
- * the Free Software Foundation; version 2 of the license.
- *
- * 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 Public License for more details.
- *
- * Current Version: $Rev$ ($Date$) [$Author$]
- *
- */
-#include "dbus-conn.h"
-
-static DBusConnection *bus;
-static DBusError error;
-
-gboolean
-moko_dbus_connect_init (void)
-{
- /* Get a connection to the system bus */
- dbus_error_init (&error);
- bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
-
- if (!bus)
- {
- g_warning ("Failed to connect to the D-BUS daemon: %s", error.message);
- return FALSE;
- }
-
- if (dbus_error_is_set (&error))
- {
- g_warning ("Connection Error (%s)\n", error.message);
- dbus_error_free (&error);
- }
-
- return TRUE;
-}
-
-gboolean
-moko_dbus_send_message (const char *str)
-{
- DBusMessage *message;
-
- /* Create a new signal on the "org.openmoko.dbus.TaskManager" interface,
- * from the object "/org/openmoko/footer". */
- message = dbus_message_new_signal ("/org/openmoko/footer",
- "org.openmoko.dbus.TaskManager",
"push_statusbar_message");
- /* Append the string to the signal */
- dbus_message_append_args (message,
- DBUS_TYPE_STRING, &str,
- DBUS_TYPE_INVALID);
-
- dbus_connection_send (bus, message, NULL);
-
- dbus_message_unref (message);
-
- return TRUE;
-}
+/**
+ * @file dbus-conn.c
+ * @brief dbus connection and message send for openmoko mainmenu
+ *
+ * Authored by Sun Zhiyong <[EMAIL PROTECTED]>
+ *
+ * Copyright (C) 2006-2007 OpenMoko Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Public License as published by
+ * the Free Software Foundation; version 2 of the license.
+ *
+ * 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 Public License for more details.
+ *
+ * Current Version: $Rev$ ($Date$) [$Author$]
+ *
+ */
+#include "dbus-conn.h"
+
+static DBusConnection *bus;
+static DBusError error;
+
+gboolean
+moko_dbus_connect_init (void)
+{
+ /* Get a connection to the system bus */
+ dbus_error_init (&error);
+ bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+
+ if (!bus)
+ {
+ g_warning ("Failed to connect to the D-BUS daemon: %s", error.message);
+ return FALSE;
+ }
+
+ if (dbus_error_is_set (&error))
+ {
+ g_warning ("Connection Error (%s)\n", error.message);
+ dbus_error_free (&error);
+ }
+
+ return TRUE;
+}
+
+gboolean
+moko_dbus_send_message (const char *str)
+{
+ DBusMessage *message;
+
+ /* Create a new signal on the "org.openmoko.dbus.TaskManager" interface,
+ * from the object "/org/openmoko/footer". */
+ message = dbus_message_new_signal ("/org/openmoko/footer",
+ "org.openmoko.dbus.TaskManager",
"push_statusbar_message");
+ /* Append the string to the signal */
+ dbus_message_append_args (message,
+ DBUS_TYPE_STRING, &str,
+ DBUS_TYPE_INVALID);
+
+ dbus_connection_send (bus, message, NULL);
+
+ dbus_message_unref (message);
+
+ return TRUE;
+}
Modified: trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.c
2007-03-08 06:14:44 UTC (rev 1268)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.c
2007-03-08 06:45:50 UTC (rev 1269)
@@ -1,196 +1,197 @@
-/**
- * @file main.c
- * @brief The Main Menu in the Openmoko
- *
- * Authored by Sun Zhiyong <[EMAIL PROTECTED]>
- *
- * Copyright (C) 2006-2007 OpenMoko Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Public License as published by
- * the Free Software Foundation; version 2 of the license.
- *
- * 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 Public License for more details.
- *
- * Current Version: $Rev$ ($Date$) [$Author$]
- *
- */
-
-#include "callbacks.h"
-
-#include "main.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <signal.h>
-
-#define LOCK_FILE "/tmp/moko-mainmenu.lock"
-
-static MokoMainmenuApp *mma;
-
-static void
-handle_sigusr1 (int value)
-{
- if (!mma)
- return;
- gtk_window_present (GTK_WINDOW(mma->window));
- moko_dbus_send_message ("Openmoko main menu");
-
- signal (SIGUSR1, handle_sigusr1);
-}
-
-static pid_t
-testlock (char *fname)
-{
- int fd;
- struct flock fl;
-
- fd = open (fname, O_WRONLY, S_IWUSR);
- if (fd < 0)
- {
- if (errno == ENOENT)
- {
- return 0;
- }
- else
- {
- perror ("Test lock open file");
- return -1;
- }
- }
-
- fl.l_type = F_WRLCK;
- fl.l_whence = SEEK_SET;
- fl.l_start = 0;
- fl.l_len = 0;
-
- if (fcntl (fd, F_GETLK, &fl) < 0)
- {
- close (fd);
- return -1;
- }
- close (fd);
-
- if (fl.l_type == F_UNLCK)
- return 0;
-
- return fl.l_pid;
-}
-
-static void
-setlock (char *fname)
-{
- int fd;
- struct flock fl;
-
- fd = open (fname, O_WRONLY|O_CREAT, S_IWUSR);
- if (fd < 0)
- {
- perror ("Set lock open file");
- return ;
- }
-
- fl.l_type = F_WRLCK;
- fl.l_whence = SEEK_SET;
- fl.l_start = 0;
- fl.l_len = 0;
-
- if (fcntl (fd, F_SETLK, &fl) < 0)
- {
- perror ("Lock file");
- close (fd);
- }
-}
-
-int
-main( int argc, char** argv )
-{
- pid_t lockapp;
-
- lockapp = testlock (LOCK_FILE);
-
- if (lockapp > 0)
- {
- kill (lockapp, SIGUSR1);
- return 0;
- }
-
- setlock (LOCK_FILE);
-
- mma = g_malloc0 (sizeof (MokoMainmenuApp));
- if (!mma)
- {
- g_error ("openmoko-mainmenu application initialize FAILED.");
- exit (0);
- }
- memset (mma, 0, sizeof (MokoMainmenuApp));
-
- if (!moko_dbus_connect_init ())
- {
- g_error ("Failed to initial dbus connection.");
- exit (0);
- }
- gtk_init( &argc, &argv );
-
- /* application object */
- mma->app = MOKO_APPLICATION(moko_application_get_instance());
- g_set_application_name( "OpenMoko Main Menu" );
-
- /* finger based window */
- mma->window = MOKO_FINGER_WINDOW(moko_finger_window_new());
- gtk_widget_show (GTK_WIDGET (mma->window));
-
- /* finger wheel object*/
- mma->wheel = moko_finger_window_get_wheel (mma->window);
- gtk_window_set_title (GTK_WIDGET (mma->wheel), "wheel");
-
- /* finger toolbox object*/
- mma->toolbox = moko_finger_window_get_toolbox(mma->window);
- //initialize toolbox's buttons, which are MokoPixmapButton objects.
- mma->history = moko_app_history_init (mma->toolbox);
- if (!mma->history)
- {
- g_error ("Failed to get application history instance");
- exit (0);
- }
-
- /* MokoMainMenu object */
- mma->mm = moko_main_menu_new();
-
- /* signal connected*/
- //finger wheel object signals
- g_signal_connect (mma->wheel, "press_bottom",
- G_CALLBACK ( moko_wheel_bottom_press_cb), mma);
- g_signal_connect (mma->wheel, "press_left_up",
- G_CALLBACK ( moko_wheel_left_up_press_cb), mma);
- g_signal_connect (mma->wheel, "press_right_down",
- G_CALLBACK ( moko_wheel_right_down_press_cb), mma);
- //MokoMainMenu:MokoIconView object signals
- g_signal_connect (mma->mm->icon_view, "selection-changed",
- G_CALLBACK (moko_icon_view_selection_changed_cb), mma);
- g_signal_connect (mma->mm->icon_view, "item_activated",
- G_CALLBACK (moko_icon_view_item_acitvated_cb), mma);
-
- signal (SIGUSR1, handle_sigusr1);
-
- moko_finger_window_set_contents (mma->window, GTK_WIDGET(mma->mm));
- gtk_widget_show_all (GTK_WIDGET(mma->window) );
-
- gtk_widget_show (GTK_WIDGET (mma->wheel));
- gtk_widget_show (GTK_WIDGET (mma->toolbox));
- gtk_widget_show (GTK_WIDGET (mma->mm));
-
- gtk_main();
-
- if (mma)
- {
- if (mma->history)
- moko_app_history_free (mma->history);
- g_free (mma);
- }
- return 0;
-}
+/**
+ * @file main.c
+ * @brief The Main Menu in the Openmoko
+ *
+ * Authored by Sun Zhiyong <[EMAIL PROTECTED]>
+ *
+ * Copyright (C) 2006-2007 OpenMoko Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Public License as published by
+ * the Free Software Foundation; version 2 of the license.
+ *
+ * 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 Public License for more details.
+ *
+ * Current Version: $Rev$ ($Date$) [$Author$]
+ *
+ */
+
+#include "callbacks.h"
+
+
+#include "main.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+
+#define LOCK_FILE "/tmp/moko-mainmenu.lock"
+
+static MokoMainmenuApp *mma;
+
+static void
+handle_sigusr1 (int value)
+{
+ if (!mma)
+ return;
+ gtk_window_present (GTK_WINDOW(mma->window));
+ moko_dbus_send_message ("Openmoko main menu");
+
+ signal (SIGUSR1, handle_sigusr1);
+}
+
+static pid_t
+testlock (char *fname)
+{
+ int fd;
+ struct flock fl;
+
+ fd = open (fname, O_WRONLY, S_IWUSR);
+ if (fd < 0)
+ {
+ if (errno == ENOENT)
+ {
+ return 0;
+ }
+ else
+ {
+ perror ("Test lock open file");
+ return -1;
+ }
+ }
+
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+
+ if (fcntl (fd, F_GETLK, &fl) < 0)
+ {
+ close (fd);
+ return -1;
+ }
+ close (fd);
+
+ if (fl.l_type == F_UNLCK)
+ return 0;
+
+ return fl.l_pid;
+}
+
+static void
+setlock (char *fname)
+{
+ int fd;
+ struct flock fl;
+
+ fd = open (fname, O_WRONLY|O_CREAT, S_IWUSR);
+ if (fd < 0)
+ {
+ perror ("Set lock open file");
+ return ;
+ }
+
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+
+ if (fcntl (fd, F_SETLK, &fl) < 0)
+ {
+ perror ("Lock file");
+ close (fd);
+ }
+}
+
+int
+main( int argc, char** argv )
+{
+ pid_t lockapp;
+
+ lockapp = testlock (LOCK_FILE);
+
+ if (lockapp > 0)
+ {
+ kill (lockapp, SIGUSR1);
+ return 0;
+ }
+
+ setlock (LOCK_FILE);
+
+ mma = g_malloc0 (sizeof (MokoMainmenuApp));
+ if (!mma)
+ {
+ g_error ("openmoko-mainmenu application initialize FAILED.");
+ exit (0);
+ }
+ memset (mma, 0, sizeof (MokoMainmenuApp));
+
+ if (!moko_dbus_connect_init ())
+ {
+ g_error ("Failed to initial dbus connection.");
+ exit (0);
+ }
+ gtk_init( &argc, &argv );
+
+ /* application object */
+ mma->app = MOKO_APPLICATION(moko_application_get_instance());
+ g_set_application_name( "OpenMoko Main Menu" );
+
+ /* finger based window */
+ mma->window = MOKO_FINGER_WINDOW(moko_finger_window_new());
+ gtk_widget_show (GTK_WIDGET (mma->window));
+
+ /* finger wheel object*/
+ mma->wheel = moko_finger_window_get_wheel (mma->window);
+ gtk_window_set_title (GTK_WIDGET (mma->wheel), "wheel");
+
+ /* finger toolbox object*/
+ mma->toolbox = moko_finger_window_get_toolbox(mma->window);
+ //initialize toolbox's buttons, which are MokoPixmapButton objects.
+ mma->history = moko_app_history_init (mma->toolbox);
+ if (!mma->history)
+ {
+ g_error ("Failed to get application history instance");
+ exit (0);
+ }
+
+ /* MokoMainMenu object */
+ mma->mm = moko_main_menu_new();
+
+ /* signal connected*/
+ //finger wheel object signals
+ g_signal_connect (mma->wheel, "press_bottom",
+ G_CALLBACK ( moko_wheel_bottom_press_cb), mma);
+ g_signal_connect (mma->wheel, "press_left_up",
+ G_CALLBACK ( moko_wheel_left_up_press_cb), mma);
+ g_signal_connect (mma->wheel, "press_right_down",
+ G_CALLBACK ( moko_wheel_right_down_press_cb), mma);
+ //MokoMainMenu:MokoIconView object signals
+ g_signal_connect (mma->mm->icon_view, "selection-changed",
+ G_CALLBACK (moko_icon_view_selection_changed_cb), mma);
+ g_signal_connect (mma->mm->icon_view, "item_activated",
+ G_CALLBACK (moko_icon_view_item_acitvated_cb), mma);
+
+ signal (SIGUSR1, handle_sigusr1);
+
+ moko_finger_window_set_contents (mma->window, GTK_WIDGET(mma->mm));
+ gtk_widget_show_all (GTK_WIDGET(mma->window) );
+
+ gtk_widget_show (GTK_WIDGET (mma->wheel));
+ gtk_widget_show (GTK_WIDGET (mma->toolbox));
+ gtk_widget_show (GTK_WIDGET (mma->mm));
+
+ gtk_main();
+
+ if (mma)
+ {
+ if (mma->history)
+ moko_app_history_free (mma->history);
+ g_free (mma);
+ }
+ return 0;
+}
Modified: trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.h
2007-03-08 06:14:44 UTC (rev 1268)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.h
2007-03-08 06:45:50 UTC (rev 1269)
@@ -1,48 +1,48 @@
-/**
- * @file main.h
- * @brief The Main Menu in the Openmoko
- *
- * Authored by Sun Zhiyong <[EMAIL PROTECTED]>
- *
- * Copyright (C) 2006-2007 OpenMoko Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Public License as published by
- * the Free Software Foundation; version 2 of the license.
- *
- * 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 Public License for more details.
- *
- * Current Version: $Rev$ ($Date$) [$Author$]
- *
- */
-
-#ifndef _MAIN_MENU_MAIN_H
-#define _MAIN_MENU_MAIN_H
-
-
-#include <libmokoui/moko-application.h>
-#include <libmokoui/moko-finger-window.h>
-#include <libmokoui/moko-finger-wheel.h>
-#include <libmokoui/moko-finger-tool-box.h>
-#include <libmokoui/moko-pixmap-button.h>
-
-#include "mainmenu.h"
-#include "app-history.h"
-#include "dbus-conn.h"
-
-typedef struct _MokoMainmenuApp MokoMainmenuApp;
-
-struct _MokoMainmenuApp {
- MokoApplication *app;
-
- MokoFingerWindow *window;
- MokoFingerWheel *wheel;
- MokoFingerToolBox *toolbox;
- MokoMainMenu *mm;
- MokoAppHistory *history;
-};
-
-#endif /*_MAIN_MENU_MAIN_H*/
+/**
+ * @file main.h
+ * @brief The Main Menu in the Openmoko
+ *
+ * Authored by Sun Zhiyong <[EMAIL PROTECTED]>
+ *
+ * Copyright (C) 2006-2007 OpenMoko Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Public License as published by
+ * the Free Software Foundation; version 2 of the license.
+ *
+ * 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 Public License for more details.
+ *
+ * Current Version: $Rev$ ($Date$) [$Author$]
+ *
+ */
+
+#ifndef _MAIN_MENU_MAIN_H
+#define _MAIN_MENU_MAIN_H
+
+
+#include <libmokoui/moko-application.h>
+#include <libmokoui/moko-finger-window.h>
+#include <libmokoui/moko-finger-wheel.h>
+#include <libmokoui/moko-finger-tool-box.h>
+#include <libmokoui/moko-pixmap-button.h>
+
+#include "mainmenu.h"
+#include "app-history.h"
+#include "dbus-conn.h"
+
+typedef struct _MokoMainmenuApp MokoMainmenuApp;
+
+struct _MokoMainmenuApp {
+ MokoApplication *app;
+
+ MokoFingerWindow *window;
+ MokoFingerWheel *wheel;
+ MokoFingerToolBox *toolbox;
+ MokoMainMenu *mm;
+ MokoAppHistory *history;
+};
+
+#endif /*_MAIN_MENU_MAIN_H*/
--- End Message ---