r1434 - trunk/src/target/OM-2007/applications/openmoko-mainmenu/src
zhiyong_sun at sita.openmoko.org
zhiyong_sun at sita.openmoko.org
Tue Mar 20 10:30:36 CET 2007
Author: zhiyong_sun
Date: 2007-03-20 10:30:22 +0100 (Tue, 20 Mar 2007)
New Revision: 1434
Added:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/fingermenu.c
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/fingermenu.h
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/stylusmenu.c
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/stylusmenu.h
Modified:
trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/Makefile.am
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/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/mokoiconview.c
Log:
add stylus menu object , abstract finger menu object
Modified: trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/Makefile.am 2007-03-20 09:11:00 UTC (rev 1433)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/Makefile.am 2007-03-20 09:30:22 UTC (rev 1434)
@@ -4,10 +4,10 @@
bin_PROGRAMS = openmoko-mainmenu
-openmoko_mainmenu_SOURCES = main.c \
- mainmenu.c mokoiconview.c\
- mokodesktop.c mokodesktop_item.c\
- callbacks.c app-history.c dbus-conn.c
+openmoko_mainmenu_SOURCES = main.c fingermenu.c stylusmenu.c\
+ mainmenu.c mokoiconview.c\
+ mokodesktop.c mokodesktop_item.c\
+ callbacks.c app-history.c dbus-conn.c
openmoko_mainmenu_LDADD = @OPENMOKO_LIBS@ @LIBMB_LIBS@
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-20 09:11:00 UTC (rev 1433)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/callbacks.c 2007-03-20 09:30:22 UTC (rev 1434)
@@ -29,40 +29,48 @@
#include "callbacks.h"
#include "mokoiconview.h"
#include "mokodesktop_item.h"
-#include "app-history.h"
+#include "fingermenu.h"
static void moko_cb_run_app (const char * data);
void
-moko_wheel_bottom_press_cb (GtkWidget *self, MokoMainmenuApp *mma)
+moko_wheel_bottom_press_cb (GtkWidget *self, MokoFingerMenu *fm)
{
- if (mma->mm->current->type != ITEM_TYPE_ROOT)
+ MokoDesktopItem *current = NULL;
+
+ current = moko_finger_menu_get_current_item (fm);
+
+ if (current->type != ITEM_TYPE_ROOT)
{
- mma->mm->current = mokodesktop_item_get_parent(mma->mm->current);
- moko_main_menu_update_content (mma->mm, mma->mm->current);
+ current = mokodesktop_item_get_parent(current);
+ moko_finger_menu_update_content (fm, current);
}
else
{
- gtk_window_iconify (GTK_WINDOW (mma->window));
+ //gtk_window_iconify (GTK_WINDOW (mma->window));
+ g_debug ("Call moko finger menu hide");
moko_dbus_send_message ("");
- }
+ }
+
}
void
-moko_wheel_left_up_press_cb (GtkWidget *self, MokoMainmenuApp *mma)
+moko_wheel_left_up_press_cb (GtkWidget *self, MokoFingerMenu *fm)
{
- moko_icon_view_move_cursor_line_up (mma->mm->icon_view);
+ //moko_icon_view_move_cursor_line_up (mma->fm->mm->icon_view);
+ moko_finger_menu_move_cursor_up(fm);
}
void
-moko_wheel_right_down_press_cb (GtkWidget *self, MokoMainmenuApp *mma)
+moko_wheel_right_down_press_cb (GtkWidget *self, MokoFingerMenu *fm)
{
- moko_icon_view_move_cursor_line_down (mma->mm->icon_view);
+ // moko_icon_view_move_cursor_line_down (mma->mm->icon_view);
+ moko_finger_menu_move_cursor_down(fm);
}
void
moko_icon_view_item_acitvated_cb(MokoIconView *icon_view,
- GtkTreePath *path, MokoMainmenuApp *mma)
+ GtkTreePath *path, MokoFingerMenu *fm)
{
MokoDesktopItem *selected_item = NULL;
GtkTreeModel *tree_model;
@@ -74,8 +82,9 @@
if (selected_item->type == ITEM_TYPE_FOLDER)
{
- mma->mm->current = selected_item;
- moko_main_menu_update_content (mma->mm, selected_item);
+ // moko_finger_menu_set_current_item(mma->fm, selected_item);
+ moko_finger_menu_update_content (fm, 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)
{
@@ -85,13 +94,13 @@
gtk_tree_model_get (tree_model, &iter, PIXBUF_COLUMN, &pixbuf, -1);
if (pixbuf)
- moko_app_history_set (mma->history, pixbuf, selected_item);
+ moko_finger_menu_set_app_history(fm, pixbuf, selected_item);
}
}
void
moko_icon_view_selection_changed_cb(MokoIconView *iconview,
- MokoMainmenuApp *mma)
+ MokoFingerMenu *fm)
{
GList *selected_item;
GtkTreeIter iter;
@@ -115,7 +124,7 @@
g_list_foreach (selected_item, (GFunc) gtk_tree_path_free, NULL);
g_list_free (selected_item);
- moko_main_menu_update_item_total_label (mma->mm);
+ moko_main_menu_update_item_total_label (fm->mm);
}
void
@@ -144,7 +153,13 @@
}
}
-static void
+void
+moko_stylus_menu_activate_item (GtkMenuItem *menuitem, gpointer data)
+{
+ moko_cb_run_app (data);
+}
+
+void
moko_cb_run_app (const char * data)
{
switch (fork())
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-20 09:11:00 UTC (rev 1433)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/callbacks.h 2007-03-20 09:30:22 UTC (rev 1434)
@@ -27,24 +27,28 @@
#include <gtk/gtk.h>
#include "main.h"
+#include "fingermenu.h"
-void moko_wheel_bottom_press_cb (GtkWidget *self, MokoMainmenuApp *mma);
+void moko_wheel_bottom_press_cb (GtkWidget *self, MokoFingerMenu *fm);
-void moko_wheel_left_up_press_cb (GtkWidget *self, MokoMainmenuApp *mma);
+void moko_wheel_left_up_press_cb (GtkWidget *self, MokoFingerMenu *fm);
-void moko_wheel_right_down_press_cb (GtkWidget *self, MokoMainmenuApp *mma);
+void moko_wheel_right_down_press_cb (GtkWidget *self, MokoFingerMenu *fm);
void moko_up_btn_cb (GtkButton *button, MokoMainMenu *mm);
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, MokoFingerMenu *fm);
-void moko_icon_view_item_acitvated_cb(MokoIconView *iconview, GtkTreePath *path, MokoMainmenuApp *mma);
+void moko_icon_view_item_acitvated_cb(MokoIconView *iconview, GtkTreePath *path, MokoFingerMenu *fm);
-void moko_icon_view_selection_changed_cb(MokoIconView *iconview, MokoMainmenuApp *mma);
+void moko_icon_view_selection_changed_cb(MokoIconView *iconview,MokoFingerMenu *fm);
void moko_tool_box_btn_clicked_cb (GtkButton *btn, MokoAppHistory *history);
+void
+moko_stylus_menu_activate_item (GtkMenuItem *menuitem, gpointer data);
+
#endif /*_XOPEN_SOURCE*/
#endif /*_MAIN_MENU_CALLBACKS_H*/
Added: trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/fingermenu.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/fingermenu.c 2007-03-20 09:11:00 UTC (rev 1433)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/fingermenu.c 2007-03-20 09:30:22 UTC (rev 1434)
@@ -0,0 +1,178 @@
+/**
+ * @file fingermenu.c
+ * @brief The Main Menu in the Openmoko
+ *
+ * Authored by Sun Zhiyong <sunzhiyong at fic-sh.com.cn>
+ *
+ * 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 <gtk/gtk.h>
+#include "fingermenu.h"
+#include "callbacks.h"
+
+static void moko_finger_menu_init(MokoFingerMenu *self);
+
+static void moko_finger_menu_class_init(MokoFingerMenuClass *self);
+
+GType
+moko_finger_menu_get_type (void) /* Typechecking */
+{
+ static GType menu_type = 0;
+
+ if (!menu_type)
+ {
+ static const GTypeInfo menu_info =
+ {
+ sizeof (MokoFingerMenuClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) moko_finger_menu_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (MokoFingerMenu),
+ 0,
+ (GInstanceInitFunc) moko_finger_menu_init,
+ NULL
+ };
+ menu_type = g_type_register_static (MOKO_TYPE_APPLICATION, "MokoFingerMenu", &menu_info, 0);
+ }
+
+ return menu_type;
+}
+
+void
+moko_finger_menu_class_init(MokoFingerMenuClass *self)
+{
+
+}
+
+void
+moko_finger_menu_init(MokoFingerMenu *self)
+{
+ self->app = MOKO_APPLICATION(moko_application_get_instance());
+ g_set_application_name( "OpenMoko Main Menu" );
+
+ self->window = MOKO_FINGER_WINDOW(moko_finger_window_new());
+ gtk_widget_show (GTK_WIDGET (self->window));
+
+ self->wheel = moko_finger_window_get_wheel (self->window);
+
+ self->toolbox = moko_finger_window_get_toolbox (self->window);
+ self->history = moko_app_history_init (self->toolbox);
+ self->mm = MAINMENU (moko_main_menu_new());
+ gtk_widget_show (self->mm);
+
+ g_signal_connect (self->wheel, "press_bottom", G_CALLBACK ( moko_wheel_bottom_press_cb), self);
+ g_signal_connect (self->wheel, "press_left_up", G_CALLBACK ( moko_wheel_left_up_press_cb), self);
+ g_signal_connect (self->wheel, "press_right_down", G_CALLBACK ( moko_wheel_right_down_press_cb), self);
+ g_signal_connect (self->mm->icon_view, "selection-changed", G_CALLBACK (moko_icon_view_selection_changed_cb), self);
+ g_signal_connect (self->mm->icon_view, "item_activated", G_CALLBACK (moko_icon_view_item_acitvated_cb), self);
+
+ moko_finger_window_set_contents (self->window, GTK_WIDGET(self->mm));
+}
+
+MokoFingerMenu*
+moko_finger_menu_new ()
+{
+ return FINGERMENU(g_object_new(moko_finger_menu_get_type(), NULL));
+}
+
+void
+moko_finger_menu_show (MokoFingerMenu *self)
+{
+ if (!self)
+ return;
+
+ gtk_widget_show_all (GTK_WIDGET(self->window));
+ gtk_widget_show_all (self->mm);
+
+ //gtk_widget_show (GTK_WIDGET(self->window));
+ // gtk_widget_show (GTK_WIDGET(self->toolbox));
+ // gtk_widget_show (GTK_WIDGET(self->wheel));
+
+ gtk_window_present (GTK_WINDOW (self->window));
+}
+
+void
+moko_finger_menu_hide (MokoFingerMenu *self)
+{
+ if (!self)
+ return;
+ if (GTK_WIDGET_VISIBLE (GTK_WIDGET(self->window)))
+ //gtk_widget_hide (GTK_WIDGET(self->window));
+ //gtk_widget_hide (GTK_WIDGET(self->toolbox));
+ //gtk_widget_hide (GTK_WIDGET(self->wheel));
+ gtk_window_iconify (GTK_WINDOW (self->window));
+}
+
+void
+moko_finger_menu_build (MokoFingerMenu *self, MokoDesktopItem *item)
+{
+ if (!self)
+ return;
+
+ self->mm->top_item = item;
+ moko_main_menu_update_content (self->mm, item);
+}
+
+void
+moko_finger_menu_update_content (MokoFingerMenu *self, MokoDesktopItem *item)
+{
+ if (!self || !item)
+ return;
+ moko_main_menu_update_content (self->mm, item);
+}
+
+MokoDesktopItem *
+moko_finger_menu_get_current_item (MokoFingerMenu *self)
+{
+ if (!self->mm->current)
+ return NULL;
+ else
+ return self->mm->current;
+}
+
+void
+moko_finger_menu_set_current_item (MokoFingerMenu *self, MokoDesktopItem *item)
+{
+ if(!self || !item)
+ return;
+ self->mm->current = item;
+}
+
+void
+moko_finger_menu_move_cursor_up(MokoFingerMenu *self)
+{
+ if (!self)
+ return;
+ moko_icon_view_move_cursor_line_up (self->mm->icon_view);
+}
+
+void
+moko_finger_menu_move_cursor_down(MokoFingerMenu *self)
+{
+ if (!self)
+ return;
+ moko_icon_view_move_cursor_line_down (self->mm->icon_view);
+}
+
+void
+moko_finger_menu_set_app_history(MokoFingerMenu *self, GdkPixbuf *pixbuf, MokoDesktopItem *item)
+{
+ if (!self || !pixbuf || !item)
+ return;
+ moko_app_history_set (self->history, pixbuf, item);
+
+}
Added: trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/fingermenu.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/fingermenu.h 2007-03-20 09:11:00 UTC (rev 1433)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/fingermenu.h 2007-03-20 09:30:22 UTC (rev 1434)
@@ -0,0 +1,84 @@
+/**
+ * @file fingermenu.h
+ * @brief The Main Menu in the Openmoko
+ *
+ * Authored by Sun Zhiyong <sunzhiyong at fic-sh.com.cn>
+ *
+ * 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 _MOKO_FINGER_MENU_H_
+#define _MOKO_FINGER_MENU_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 <libmokoui/moko-application.h>
+
+
+#include "mainmenu.h"
+#include "app-history.h"
+
+G_BEGIN_DECLS
+#define FINGERMENU_TYPE (moko_finger_menu_get_type())
+#define FINGERMENU(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), FINGERMENU_TYPE, MokoFingerMenu))
+#define FINEGERMENU_CLASS(kalss) (G_TYPE_CHECK_CLASS_CAST((klass), FINGERMENU_TYPE, MokoFingerMenuClass))
+
+typedef struct _MokoFingerMenu MokoFingerMenu;
+typedef struct _MokoFingerMenuClass MokoFingerMenuClass;
+
+struct _MokoFingerMenu{
+ MokoApplication parent;
+
+ MokoApplication *app;
+ MokoMainMenu *mm;
+ MokoFingerWindow *window;
+ MokoFingerWheel *wheel;
+ MokoFingerToolBox *toolbox;
+ MokoAppHistory *history;
+};
+
+struct _MokoFingerMenuClass{
+ MokoApplicationClass parent_class;
+};
+
+GType moko_finger_menu_get_type(void);
+
+/*************/
+/*Public API*/
+/*************/
+MokoFingerMenu* moko_finger_menu_new ();
+
+void moko_finger_menu_show (MokoFingerMenu *self);
+
+void moko_finger_menu_hide (MokoFingerMenu *self);
+
+void moko_finger_menu_build (MokoFingerMenu *self, MokoDesktopItem *item);
+
+void moko_finger_menu_update_content (MokoFingerMenu *self, MokoDesktopItem *item);
+
+MokoDesktopItem * moko_finger_menu_get_current_item (MokoFingerMenu *self);
+
+void moko_finger_menu_set_current_item (MokoFingerMenu *self, MokoDesktopItem *item);
+
+void moko_finger_menu_move_cursor_up(MokoFingerMenu *self);
+
+void moko_finger_menu_move_cursor_down(MokoFingerMenu *self);
+
+void moko_finger_menu_set_app_history(MokoFingerMenu *self, GdkPixbuf *pixbuf, MokoDesktopItem *item);
+
+G_END_DECLS
+
+#endif /*_MOKO_FINGER_MENU_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-20 09:11:00 UTC (rev 1433)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.c 2007-03-20 09:30:22 UTC (rev 1434)
@@ -38,7 +38,8 @@
{
if (!mma)
return;
- gtk_window_present (GTK_WINDOW(mma->window));
+ //gtk_window_present (GTK_WINDOW(mma->window));
+ g_debug ("Show finger menu");
moko_dbus_send_message ("Openmoko main menu");
signal (SIGUSR1, handle_sigusr1);
@@ -107,12 +108,62 @@
}
}
+static void
+moko_mainmenu_usage (const char *bin_name)
+{
+ fprintf (stderr, "%s usage: %s [Options...]\n"
+ "Where options are:\n"
+ "--help, -h print help\n"
+ "--finger-menum, -fm Show finger menu when application started\n",
+ bin_name, bin_name);
+ exit (1);
+}
+
+static void
+moko_mainmenu_init(MokoMainmenuApp *mma, int argc, char** argv)
+{
+ gint i;
+ gint ret = 0 ;
+ gboolean show_fm = FALSE;
+
+ for (i=1; i< argc; i++)
+ {
+ if (!strcmp("--finger-menu", argv[i]) || !strcmp("-fm", argv[i]))
+ {
+ show_fm = TRUE;
+ continue;
+ }
+ if (++i>=argc)
+ moko_mainmenu_usage (argv[0]);
+ }
+
+ /* Buid Root item, don't display */
+ mma->top_item = mokodesktop_item_new_with_params ("Home",
+ NULL,
+ NULL,
+ ITEM_TYPE_ROOT );
+
+ /* Build Lists (parse .directory and .desktop files) */
+ ret = mokodesktop_init(mma->top_item, ITEM_TYPE_CNT);
+
+ gtk_init( &argc, &argv );
+
+ /*MokoFingerMenu object*/
+ mma->fm = moko_finger_menu_new ();
+ moko_finger_menu_build (mma->fm, mma->top_item);
+ if(show_fm)
+ moko_finger_menu_show (mma->fm);
+
+ /*MokoStylusMenu object*/
+ mma->sm = moko_stylus_menu_new ();
+ moko_stylus_menu_build (mma->sm, mma->top_item);
+}
int
main( int argc, char** argv )
{
pid_t lockapp;
-
lockapp = testlock (LOCK_FILE);
+ int ret;
if (lockapp > 0)
{
@@ -135,63 +186,36 @@
g_error ("Failed to initial dbus connection.");
exit (0);
}
- gtk_init( &argc, &argv );
+
+ // moko_mainmenu_init (mma, argc, argv);
- /* application object */
- mma->app = MOKO_APPLICATION(moko_application_get_instance());
- g_set_application_name( "OpenMoko Main Menu" );
+ /* Buid Root item, don't display */
+ mma->top_item = mokodesktop_item_new_with_params ("Home",
+ NULL,
+ NULL,
+ ITEM_TYPE_ROOT );
+
+ /* Build Lists (parse .directory and .desktop files) */
+ ret = mokodesktop_init(mma->top_item, ITEM_TYPE_CNT);
- /* finger based window */
- mma->window = MOKO_FINGER_WINDOW(moko_finger_window_new());
- gtk_widget_show (GTK_WIDGET (mma->window));
+ gtk_init( &argc, &argv );
- /* finger wheel object*/
- mma->wheel = MOKO_FINGER_WHEEL (moko_finger_window_get_wheel (mma->window));
- gtk_window_set_title (GTK_WINDOW (mma->wheel), "wheel");
+ /*MokoFingerMenu object*/
+ mma->fm = moko_finger_menu_new ();
+ moko_finger_menu_build (mma->fm, mma->top_item);
+ moko_finger_menu_show (mma->fm);
- /* finger toolbox object*/
- mma->toolbox = MOKO_FINGER_TOOL_BOX (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);
- }
+ /*MokoStylusMenu object*/
+ // mma->sm = moko_stylus_menu_new ();
+ // moko_stylus_menu_build (mma->sm, mma->top_item);
+ signal (SIGUSR1, handle_sigusr1);
- /* MokoMainMenu object */
- mma->mm = MAINMENU (moko_main_menu_new ());
+ gtk_main();
- /* 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;
+ if (mma)
+ {
+ 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-20 09:11:00 UTC (rev 1433)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/main.h 2007-03-20 09:30:22 UTC (rev 1434)
@@ -22,27 +22,17 @@
#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 "fingermenu.h"
+#include "stylusmenu.h"
#include "dbus-conn.h"
+#include "mokodesktop.h"
typedef struct _MokoMainmenuApp MokoMainmenuApp;
struct _MokoMainmenuApp {
- MokoApplication *app;
-
- MokoFingerWindow *window;
- MokoFingerWheel *wheel;
- MokoFingerToolBox *toolbox;
- MokoMainMenu *mm;
- MokoAppHistory *history;
+ MokoFingerMenu *fm;
+ MokoStylusMenu *sm;
+ MokoDesktopItem *top_item;
};
#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-20 09:11:00 UTC (rev 1433)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mainmenu.c 2007-03-20 09:30:22 UTC (rev 1434)
@@ -86,18 +86,10 @@
{
PangoFontDescription* PangoFont = pango_font_description_new(); //get system default PangoFontDesc
GtkEventBox *eventbox;
- int ret = 0 ;
- /* Buid Root item, don't display */
- mm->top_item = mokodesktop_item_new_with_params ("Home",
- NULL,
- NULL,
- ITEM_TYPE_ROOT );
+
+ mm->top_item = NULL;
+ mm->current = NULL;
- /* Build Lists (parse .directory and .desktop files) */
- ret = mokodesktop_init(mm->top_item, ITEM_TYPE_CNT);
- //make current item point to the top_item.
- mm->current = mm->top_item;
-
/*center label of MokoMainMenu head*/
mm->section_name = gtk_label_new ("Main Menu");
gtk_widget_show (mm->section_name);
@@ -170,7 +162,6 @@
gtk_box_pack_end (mm->hbox, mm->item_total, FALSE, FALSE, 0);
gtk_box_pack_end (mm, mm->scrolled, TRUE, TRUE, 0);
- moko_main_menu_update_content (mm, mm->current);
if (PangoFont)
pango_font_description_free (PangoFont);
@@ -264,23 +255,27 @@
char total_item[6];
//g_debug("mokodesktop: item [%d][%s][%s]\n", item->type, item->name, item->icon_name);
+ if (!mm)
+ return;
+ mm->current = item;
+
item_new = item->item_child;
//g_debug("mokodesktop: item [%d][%s][%s]\n", item_new->type, item_new->name, item_new->icon_name);
// g_debug ("test");
if (item->type == ITEM_TYPE_ROOT)
{
- moko_set_label_content (mm->section_name, "Main Menu");
+ moko_set_label_content (mm->section_name, "Main Menu");
}
else if (item->type == ITEM_TYPE_FOLDER)
{
- moko_set_label_content (mm->section_name, item->name);
+ moko_set_label_content (mm->section_name, item->name);
}
else
return FALSE; // neither ROOT nor FOLDER
if (mm->list_store)
- gtk_list_store_clear (mm->list_store);
+ gtk_list_store_clear (mm->list_store);
mokodesktop_items_enumerate_siblings(item->item_child, item_new)
{
@@ -294,8 +289,8 @@
{
char path[512];
snprintf (path, 512, "%s/%s", PIXMAP_PATH, item_new->icon_name);
-
- if (access (path, 0) == 0)
+
+ if (access (path, 0) == 0)
moko_fill_model(mm->list_store, path, item_new->name, item_new);
else
{
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-20 09:11:00 UTC (rev 1433)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/mokoiconview.c 2007-03-20 09:30:22 UTC (rev 1434)
@@ -1057,11 +1057,10 @@
gdk_window_set_user_data (icon_view->priv->bin_window, widget);
widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, widget->state);//SUNZY:draw window backgound with window BG_PIXBUF
- //gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
- //gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
-
+ //SUNZY:draw window backgound with window BG_PIXBUF
+ gtk_style_set_background (widget->style, icon_view->priv->bin_window, widget->state);
+ gtk_style_set_background (widget->style, widget->window, widget->state);
}
static void
@@ -2321,9 +2320,6 @@
MOKO_MAX (icon_view->priv->height, allocation->height));
}
- //SUNZY: ReDraw window back ground wirh widget->bg_pixmap
- gdk_window_set_back_pixmap (icon_view->priv->bin_window, widget->style->bg_pixmap[widget->state], FALSE);
-
icon_view->priv->hadjustment->page_size = allocation->width;
icon_view->priv->hadjustment->page_increment = allocation->width * 0.9;
icon_view->priv->hadjustment->step_increment = allocation->width * 0.1;
Added: trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/stylusmenu.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/stylusmenu.c 2007-03-20 09:11:00 UTC (rev 1433)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/stylusmenu.c 2007-03-20 09:30:22 UTC (rev 1434)
@@ -0,0 +1,186 @@
+/*
+ * openmoko-mainmenu
+ *
+ * Authored by Sun Zhiyong <sunzhiyong at fic-sh.com.cn>
+ *
+ * Copyright (C) 2006 First International Computer 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.1 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 "mokodesktop.h"
+#include "mokodesktop_item.h"
+
+#include "stylusmenu.h"
+#include "callbacks.h"
+
+struct _MokoStylusMenuPrivate{
+
+};
+enum {
+ MENU_SIGNAL = 0,
+ LAST_SIGNAL
+};
+
+static void moko_stylus_menu_class_init(MokoStylusMenuClass *klass);
+
+static void moko_stylus_menu_init(MokoStylusMenu *self);
+
+static guint stylus_menu_signals[LAST_SIGNAL] = { 0 };
+
+GType
+moko_stylus_menu_get_type (void) /* Typechecking */
+{
+ static GType menu_type = 0;
+
+ if (!menu_type)
+ {
+ static const GTypeInfo menu_info =
+ {
+ sizeof (MokoStylusMenuClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) moko_stylus_menu_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (MokoStylusMenu),
+ 0,
+ (GInstanceInitFunc) moko_stylus_menu_init,
+ NULL
+ };
+ menu_type = g_type_register_static (GTK_TYPE_MENU_SHELL, "MokoStylusMenu", &menu_info, 0);
+ }
+
+ return menu_type;
+}
+
+void
+moko_stylus_menu_class_init (MokoStylusMenuClass * klass)
+{
+
+}
+
+void
+moko_stylus_menu_init (MokoStylusMenu * self)
+{
+}
+
+MokoStylusMenu *
+moko_stylus_menu_new ()
+{
+ return STYLUSMENU(g_object_new(moko_stylus_menu_get_type, NULL));
+}
+
+static GtkImageMenuItem *moko_build_new_menu_item (const char *icon_name, const char *icon_path);
+
+void
+moko_stylus_menu_build (GtkMenu *menu, MokoDesktopItem *item)
+{
+ //GtkMenu *sub_menu;
+ GtkImageMenuItem *menu_item;
+
+ MokoDesktopItem *item_new;
+
+ mokodesktop_items_enumerate_siblings(item->item_child, item_new)
+ {
+
+ if (access (item_new->icon_name, 0) == 0)
+ {
+ g_debug ("item patch %s", item_new->icon_name);
+ menu_item = moko_build_new_menu_item (item_new->name, item_new->icon_name);
+ }
+ else
+ {
+ char path[512];
+ snprintf (path, 512, "%s/%s", PIXMAP_PATH, item_new->icon_name);
+ if (access (path, 0) == 0)
+ menu_item = moko_build_new_menu_item (item_new->name, path);
+ else
+ {
+ snprintf (path, 512, "%s/%s", PKGDATADIR, "default-app-icon.xpm");
+ menu_item = moko_build_new_menu_item (item_new->name, path);
+ //moko_fill_model(self->list_store, path, item_new->name, item_new);
+ }
+ }
+ gtk_menu_shell_append( GTK_MENU_SHELL(menu), GTK_WIDGET(menu_item));
+ gtk_widget_show (GTK_WIDGET(menu_item));
+
+ if (item_new->type == ITEM_TYPE_FOLDER)
+ {
+ MokoDesktopItem *tmp_item;
+ GtkWidget *sub_menu;
+ sub_menu = gtk_menu_new();
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_item), GTK_WIDGET(sub_menu));
+ mokodesktop_items_enumerate_siblings(item_new->item_child, tmp_item)
+ {
+ if (access (tmp_item->icon_name, 0) == 0)
+ {
+ menu_item = moko_build_new_menu_item (tmp_item->name, tmp_item->icon_name);
+ }
+ else
+ {
+ char path[512];
+ snprintf (path, 512, "%s/%s", PIXMAP_PATH, tmp_item->icon_name);
+ if (access (path, 0) == 0)
+ menu_item = moko_build_new_menu_item (tmp_item->name, path);
+ else
+ {
+ snprintf (path, 512, "%s/%s", PKGDATADIR, "default-app-icon.xpm");
+ menu_item = moko_build_new_menu_item (tmp_item->name, path);
+ //moko_fill_model(self->list_store, path, item_new->name, item_new);
+ }
+ }
+
+ if (tmp_item->type == ITEM_TYPE_DOTDESKTOP_ITEM ||tmp_item->type == ITEM_TYPE_APP )
+ g_signal_connect (menu_item, "activate" ,G_CALLBACK(moko_stylus_menu_activate_item), tmp_item->data);
+ gtk_menu_shell_append( GTK_MENU_SHELL(sub_menu), GTK_WIDGET(menu_item) );
+ gtk_widget_show (GTK_WIDGET(menu_item));
+ }
+ }
+ }
+
+ return ;
+}
+
+static GtkImageMenuItem *
+moko_build_new_menu_item(const char *name, const char *path)
+{
+ GdkPixbuf *pixbuf;
+ GtkWidget *image;
+ GtkWidget *item;
+
+ pixbuf = gdk_pixbuf_new_from_file_at_size (path, 32, 32, NULL);
+ if(!pixbuf) g_debug ("Can't get pixbuf");
+ image = gtk_image_new_from_pixbuf (pixbuf);
+
+ item = gtk_image_menu_item_new_with_label (name);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(item), image);
+ gtk_widget_show (GTK_WIDGET(item));
+
+ return GTK_IMAGE_MENU_ITEM(item);
+}
+
+void
+moko_menu_position_cb (GtkMenu *menu, int *x, int *y, gboolean *push_in, GtkWidget *button)
+{
+ GtkAllocation* allocation = >K_WIDGET(button)->allocation;
+ //GtkRequisition req;
+ //GtkRequisition menu_req;
+ //GtkOrientation orientation;
+ //GtkTextDirection direction;
+
+ gdk_window_get_origin(GTK_BUTTON(button)->event_window, x, y);
+
+ *y += allocation->height;
+
+ *push_in = TRUE;
+}
+
Added: trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/stylusmenu.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/stylusmenu.h 2007-03-20 09:11:00 UTC (rev 1433)
+++ trunk/src/target/OM-2007/applications/openmoko-mainmenu/src/stylusmenu.h 2007-03-20 09:30:22 UTC (rev 1434)
@@ -0,0 +1,38 @@
+#ifndef _MOKO_STYLUS_MAIN_MENU_H
+#define _MOKO_STYLUS_MAIN_MENU_H
+
+#include <gtk/gtk.h>
+#include "mokodesktop.h"
+
+G_BEGIN_DECLS
+
+#define STYLUSMENU_TYPE (moko_stylus_menu_get_type())
+#define STYLUSMENU(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), STYLUSMENU_TYPE, MokoStylusMenu))
+#define STYLUSMENUCALSS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), STYLUSMENU_TYPE, MokoStylusMenuClass))
+#define IS_STYLUSMENU(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), STYLUSMENU_TYPE))
+#define IS_STYLUSMENUCALSS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), STYLUSMENU_TYPE))
+
+typedef struct _MokoStylusMenu MokoStylusMenu;
+typedef struct _MokoStylusMenuPrivate MokoStylusMenuPrivate;
+typedef struct _MokoStylusMenuClass MokoStylusMenuClass;
+
+struct _MokoStylusMenu{
+ GtkMenuShell parent;
+
+ MokoStylusMenuPrivate *priv;
+};
+
+struct _MokoStylusMenuClass{
+ GtkMenuShellClass parent_class;
+};
+
+GType moko_stylus_menu_get_type(void);
+
+MokoStylusMenu *moko_stylus_menu_new ();
+
+void moko_stylus_menu_build (GtkMenu *menu, MokoDesktopItem *dd_item);
+
+void moko_menu_position_cb (GtkMenu *menu, int *x, int *y, gboolean *push_in, GtkWidget *button);
+
+G_END_DECLS
+#endif /*_MOKO_STYLUS_MAIN_MENU_H*/
More information about the commitlog
mailing list