application-switcher.h

Go to the documentation of this file.
00001 
00002 /*
00003  * This file is part of maemo-af-desktop
00004  *
00005  * Copyright (C) 2005 Nokia Corporation.
00006  *
00007  * Contact: Karoliina Salminen <karoliina.t.salminen@nokia.com>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public License
00011  * as published by the Free Software Foundation; either version 2.1 of
00012  * the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00022  * 02110-1301 USA
00023  *
00024  */
00025 
00034 #ifndef APPLICATION_SWITCHER_H
00035 #define APPLICATION_SWITCHER_H
00036 
00037 #include <gtk/gtkbutton.h>
00038 #include <libosso.h>
00039 #include <gtk/gtkmenu.h>
00040 
00041 #include "hn-wm-types.h"
00042 
00043 /* Hardcoded list position for the four recently opened window items */
00044 #define ITEM_1_LIST_POS 2                          
00045 #define ITEM_2_LIST_POS 3
00046 #define ITEM_3_LIST_POS 4                             
00047 #define ITEM_4_LIST_POS 5
00048 
00049 /* Menu item strings */
00050 #define STRING_HOME _("tana_fi_home")
00051 
00052 /* Defined workarea atom */
00053 #define WORKAREA_ATOM "_NET_WORKAREA"
00054 
00055 /* Icon name of the Application switcher menu button */
00056 #define AS_SWITCHER_BUTTON_ICON "qgn_list_tasknavigator_appswitcher" 
00057 
00058 /* Icon name for the 'default' icon */
00059 #define MENU_ITEM_DEFAULT_APP_ICON    "qgn_list_gene_default_app"
00060 
00061 /* Icon name for the Home AS menu item icon */
00062 
00063 #define HOME_MENU_ITEM_ICON "qgn_list_home"
00064 
00065 /* Themed widget names */
00066 #define SMALL_BUTTON1_NORMAL "hildon-navigator-small-button1"
00067 #define SMALL_BUTTON2_NORMAL "hildon-navigator-small-button2"
00068 #define SMALL_BUTTON3_NORMAL "hildon-navigator-small-button3"
00069 #define SMALL_BUTTON4_NORMAL "hildon-navigator-small-button4"
00070 
00071 #define SMALL_BUTTON1_PRESSED "hildon-navigator-small-button1-pressed"
00072 #define SMALL_BUTTON2_PRESSED "hildon-navigator-small-button2-pressed"
00073 #define SMALL_BUTTON3_PRESSED "hildon-navigator-small-button3-pressed"
00074 #define SMALL_BUTTON4_PRESSED "hildon-navigator-small-button4-pressed"
00075 
00076 #define NAME_SMALL_MENU_BUTTON_ITEM "hildon-navigator-small-button5"
00077 
00078 #define NAME_UPPER_SEPARATOR "hildon-navigator-upper-separator"
00079 #define NAME_LOWER_SEPARATOR "hildon-navigator-lower-separator"
00080 
00081 /* Definitions for the application switcher menu position changes */
00082 
00083 #define AS_MENUITEM_SAME_POSITION 0
00084 #define AS_MENUITEM_TO_FIRST_POSITION 1
00085 #define AS_MENUITEM_TO_LAST_POSITION 2
00086 
00087 /* Hardcoded pixel perfecting values */
00088 #define BUTTON_BORDER_WIDTH 0 
00089 #define MENU_BORDER_WIDTH 20
00090 #define BIG_BUTTON_HEIGHT 90
00091 #define SMALL_BUTTON_HEIGHT 38
00092 #define ROW_HEIGHT 30
00093 #define ICON_SIZE 26
00094 #define MAX_AREA_WIDTH 360
00095 #define SEPARATOR_HEIGHT 10 /* Inactive skin graphic area height(10px) */
00096 #define BUTTON_1_Y_POS (BIG_BUTTON_HEIGHT * 3 + SEPARATOR_HEIGHT)
00097 #define BUTTON_2_Y_POS (BUTTON_1_Y_POS + SMALL_BUTTON_HEIGHT)
00098 #define BUTTON_3_Y_POS (BUTTON_2_Y_POS + SMALL_BUTTON_HEIGHT)
00099 #define BUTTON_4_Y_POS (BUTTON_3_Y_POS + SMALL_BUTTON_HEIGHT)
00100 
00101 /* Needed for catching the MCE D-BUS messages */
00102 
00103 #define MCE_SERVICE "com.nokia.mce"
00104 #define MCE_SIGNAL_INTERFACE "com.nokia.mce.signal"
00105 #define MCE_SIGNAL_PATH "/com/nokia/mce/signal"
00106 
00107 #define HOME_LONG_PRESS "sig_home_key_pressed_long_ind"
00108 #define HOME_PRESS "sig_home_key_pressed_ind"
00109 #define SHUTDOWN_IND "shutdown_ind"
00110 
00111 #define LOWMEM_ON_SIGNAL_INTERFACE "com.nokia.ke_recv.lowmem_on"
00112 #define LOWMEM_ON_SIGNAL_PATH "/com/nokia/ke_recv/lowmem_on"
00113 #define LOWMEM_ON_SIGNAL_NAME "lowmem_on"
00114 
00115 #define LOWMEM_OFF_SIGNAL_INTERFACE "com.nokia.ke_recv.lowmem_off"
00116 #define LOWMEM_OFF_SIGNAL_PATH "/com/nokia/ke_recv/lowmem_off"
00117 #define LOWMEM_OFF_SIGNAL_NAME "lowmem_off"
00118 
00119 #define BGKILL_ON_SIGNAL_INTERFACE "com.nokia.ke_recv.bgkill_on"
00120 #define BGKILL_ON_SIGNAL_PATH "/com/nokia/ke_recv/bgkill_on"
00121 #define BGKILL_ON_SIGNAL_NAME "bgkill_on"
00122 
00123 #define BGKILL_OFF_SIGNAL_INTERFACE "com.nokia.ke_recv.bgkill_off"
00124 #define BGKILL_OFF_SIGNAL_PATH "/com/nokia/ke_recv/bgkill_off"
00125 #define BGKILL_OFF_SIGNAL_NAME "bgkill_off"
00126 
00127 #define HILDON_NAVIGATOR_WINDOW_OPEN_SOUND DATADIR"/sounds/ui-window_open.wav"
00128 #define HILDON_NAVIGATOR_WINDOW_CLOSE_SOUND DATADIR"/sounds/ui-window_close.wav"
00129 
00130 #define LAST_AS_BUTTON 4
00131 
00132 #define TIMEOUT_HALF_SECOND 500
00133 #define TIMEOUT_ONE_AND_HALF_SECOND 1500
00134 #define TEMP_LABEL_BUFFER_SIZE 80
00135 
00136 typedef  struct ApplicationSwitcher ApplicationSwitcher_t;
00137 
00138 typedef void (_shutdown_callback)(void);
00139 typedef void (_lowmem_callback)(gboolean is_on);
00140 typedef void (_bgkill_callback)(gboolean is_on);
00141 
00142 /* Private data */
00143 struct ApplicationSwitcher {
00144     /* Application switcher menu */    
00145     GtkMenu *menu;
00146     
00147     /* Home item for application switcher */
00148     GtkWidget *home_menu_item;
00149     
00150     /* Tooltip menu */
00151     GtkWidget *tooltip_menu;
00152     
00153     /* Label of the tooltip menu */        
00154     GtkWidget *tooltip_menu_item;    
00155     
00156     /* VBox to pack buttons */
00157     GtkWidget *vbox;
00158     
00159     /* Small icon buttons */
00160     GtkWidget *toggle_button1;
00161     GtkWidget *toggle_button2;
00162     GtkWidget *toggle_button3;
00163     GtkWidget *toggle_button4;
00164     
00165     /* Application switcher menu button */
00166     GtkWidget *toggle_button_as;
00167     
00168     /* Application switcher menu button icon */
00169     GtkWidget *as_button_icon;
00170     gboolean   menu_icon_is_blinking;
00171     
00172     /* Used to define which button is pressed */
00173     gint toggled_button_id;
00174 
00175     /* These are needed to define pointer location */
00176     gboolean in_area;
00177     gboolean is_list;
00178     gboolean on_border;
00179     gboolean on_button;
00180     
00181     gint hide_tooltip_timeout_id;
00182     gint show_tooltip_timeout_id;
00183     gboolean tooltip_visible; 
00184     
00185     gboolean switched_to_desktop;
00186     
00187     gint start_y_position;
00188     /* Array of the items */
00189     GArray *items;
00190     
00191     osso_context_t *osso;
00192     void *dnotify_handler;
00193     _shutdown_callback *shutdown_handler;
00194     _lowmem_callback *lowmem_handler;
00195     _bgkill_callback *bgkill_handler;
00196 
00197     gboolean prev_sig_was_long_press;
00198     gboolean system_inactivity;
00199 
00200     /* Sound samples */
00201     gint esd_socket;
00202     gint start_sample;
00203     gint end_sample;
00204 };
00205 
00206 /* Information of the item */
00207 typedef struct container {
00208     GtkWidget *item;
00209     gchar *item_text;
00210     gchar *app_name;
00211     gchar *icon_name;
00212     gboolean killable_item;
00213     gboolean killed_item;
00214     gchar *dialog_name;
00215     GtkWidget *icon;
00216     gboolean is_blinking;
00217     gboolean ignore_blinking;
00218 } container;
00219 
00220 /* Enum to define which button is pressed */
00221 enum{
00222     AS_BUTTON_1 = 0,
00223     AS_BUTTON_2,
00224     AS_BUTTON_3,
00225     AS_BUTTON_4,
00226     AS_BUTTON_SWITCHER
00227 };
00228 
00229 /* application_switcher_init
00230  * Called to initialise the application switcher. This function 
00231  * creates widgets to the lowest task navigator area. Area includes four 
00232  * small icon buttons and application switcher menu button which are 
00233  * packed into a vbox.
00234  * 
00235  * @returns ApplicationSwitcher_t : pointer to a new ApplicationSwitcher.
00236  */
00237 ApplicationSwitcher_t *application_switcher_init( void );
00238 
00239 /* application_switcher_get_button
00240  * Called to return the lowest button area widget.
00241  *  
00242  * @param ApplicationSwitcher_t Returned by a previous call to
00243  *                              application_switcher_init()
00244  */
00245 GtkWidget *application_switcher_get_button(ApplicationSwitcher_t *as);
00246 
00247 /* application_switcher_initialize_menu
00248  * Called to initialise the application switcher menu and tooltip menu.
00249  * Function also sets the callbacks for widgets and creates an array to 
00250  * store information of open windows. Menu gets their information of 
00251  * added/updated/removed windows from window manager. 
00252  *  
00253  * @param ApplicationSwitcher_t Returned by a previous call to
00254  *                              application_switcher_init()
00255  */
00256 void application_switcher_initialize_menu(ApplicationSwitcher_t *as);
00257 
00258 /* application_switcher_get_killable_item
00259  * Called to return the first killable item from list of the open 
00260  * windows.
00261  *  
00262  * @param ApplicationSwitcher_t Returned by a previous call to
00263  *                              application_switcher_init()
00264  *
00265  * @returns the item of the killable window in the list, or NULL if
00266  * the list has no open windows.
00267  */
00268 GtkWidget *application_switcher_get_killable_item(
00269                                               ApplicationSwitcher_t *as);
00270 
00271 /* application_switcher_deinit
00272  * Used to clean up the structure just before it gets unloaded.
00273  *  
00274  * @param ApplicationSwitcher_t Returned by a previous call to
00275  *                              application_switcher_init()
00276  */
00277 void application_switcher_deinit(ApplicationSwitcher_t *as);
00278 
00279 
00280 /* application_switcher_get_menuitems
00281  * Used to get the list of AS menuitem pointers for session saving
00282  *
00283  * @param ApplicationSwitcher_t The structure containing the
00284  *                              Application Switcher information
00285  */
00286 
00287 GList *application_switcher_get_menuitems(ApplicationSwitcher_t *as);
00288 
00289 
00290 void *application_switcher_get_dnotify_handler(ApplicationSwitcher_t *as);
00291 
00292 void application_switcher_set_dnotify_handler(ApplicationSwitcher_t *as, 
00293                                               gpointer update_cb_ptr);
00294 
00295 void application_switcher_set_shutdown_handler(ApplicationSwitcher_t *as,
00296                                                gpointer shutdown_cb_ptr);
00297 
00298 void application_switcher_set_lowmem_handler(ApplicationSwitcher_t *as,
00299                                                 gpointer lowmem_cb_ptr);
00300 
00301 void application_switcher_set_bgkill_handler(ApplicationSwitcher_t *as,
00302                                                 gpointer bgkill_on_cb_ptr);
00303 
00304 void application_switcher_add_menubutton(ApplicationSwitcher_t *as);
00305 
00306 void application_switcher_update_lowmem_situation(ApplicationSwitcher_t *as,
00307                           gboolean lowmem);
00308 
00309 /* new api */
00310 
00311 GtkWidget*
00312 app_switcher_add_new_item (ApplicationSwitcher_t *as,
00313                HNWMWatchedWindow     *window,
00314                HNWMWatchedWindowView *view);
00315 
00316 void 
00317 app_switcher_remove_item (ApplicationSwitcher_t *as,
00318               GtkWidget             *menuitem);
00319 
00320 void 
00321 app_switcher_update_item (ApplicationSwitcher_t *as,
00322               HNWMWatchedWindow     *window,
00323               HNWMWatchedWindowView *view,
00324               guint                  position_change);
00325 void
00326 app_switcher_top_desktop_item (ApplicationSwitcher_t *as);
00327 
00328 void 
00329 app_switcher_item_icon_sync (ApplicationSwitcher_t *as,
00330                  HNWMWatchedWindow     *window);
00331 
00332 void
00333 app_switcher_system_inactivity_change(ApplicationSwitcher_t *as);
00334 
00335 #endif /* APPLICATION_SWITCHER_H */

Generated on Fri Jun 9 16:23:07 2006 for maemo-af-desktop-documentation by  doxygen 1.4.6