Changeset 1641


Ignore:
Timestamp:
04/03/07 00:16:12 (6 years ago)
Author:
mickey
Message:

libmokoui: force application and filter menu to always be of a certain size. closes #130

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-menu-box.c

    r987 r1641  
    11/* 
    22 * libmokoui -- OpenMoko Application Framework UI Library 
    3  *  
     3 * 
    44 * Authored by Michael 'Mickey' Lauer <mlauer@vanille-media.de> 
    5  *  
     5 * 
    66 * Copyright (C) 2006-2007 OpenMoko Inc. 
    7  *  
     7 * 
    88 * This program is free software; you can redistribute it and/or modify 
    99 * it under the terms of the GNU Lesser Public License as published by 
    1010 * the Free Software Foundation; version 2 of the license. 
    11  *  
     11 * 
    1212 * This program is distributed in the hope that it will be useful, 
    1313 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1414 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1515 * GNU Lesser Public License for more details. 
    16  *  
     16 * 
    1717 * Current Version: $Rev$ ($Date$) [$Author$] 
    1818 */ 
     
    8686} 
    8787 
    88 void moko_menu_box_clear(MokoMenuBox *f) /* Destruction */ 
     88void moko_menu_box_clear(MokoMenuBox* f) /* Destruction */ 
    8989{ 
    9090    /* destruct your widgets here */ 
     
    142142} 
    143143 
     144static void cb_menu_size_request( GtkWidget* widget, GtkRequisition* requisition, MokoMenuBox* self ) 
     145{ 
     146    // force popup menus to open with a certain width as per designer's request. See bug #130 
     147    GtkAllocation* a = &( GTK_WIDGET(self) )->allocation; 
     148    moko_debug( "size request of menu = %d / %d -- forcing width to %d", requisition->width, requisition->height, a->width / 2.5 ); 
     149    if ( requisition->width != a->width / 2.5 ) 
     150        requisition->width = a->width / 2.5; 
     151} 
     152 
    144153void moko_menu_box_set_application_menu(MokoMenuBox* self, GtkMenu* menu) 
    145154{ 
     
    156165    GtkWidget* appitem = gtk_image_menu_item_new_with_label( g_get_application_name() ); 
    157166    GtkWidget* appicon = gtk_image_new_from_stock( "openmoko-application-menu-icon", GTK_ICON_SIZE_MENU ); 
    158     gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM (appitem), appicon ); 
     167    gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(appitem), appicon ); 
    159168    gtk_widget_set_name( GTK_WIDGET(appitem), "transparent" ); 
    160169    priv->appitem = appitem; 
    161     priv->appmenu = GTK_WIDGET (menu); 
    162     gtk_menu_item_set_submenu( GTK_MENU_ITEM (appitem), GTK_WIDGET (menu) ); 
    163     gtk_menu_shell_append( GTK_MENU_SHELL (priv->menubar_l), appitem ); 
     170    priv->appmenu = GTK_WIDGET(menu); 
     171    g_signal_connect( G_OBJECT(menu), "size-request", G_CALLBACK(cb_menu_size_request), self ); 
     172    gtk_menu_item_set_submenu( GTK_MENU_ITEM(appitem), GTK_WIDGET(menu) ); 
     173    gtk_menu_shell_append( GTK_MENU_SHELL(priv->menubar_l), appitem ); 
    164174 
    165175    //FIXME hack to popup the first menu if user clicks on menubar 
     
    178188        gtk_widget_set_name( priv->menubar_r, "mokomenubox-filter-menubar" ); 
    179189        gtk_box_pack_end( GTK_BOX(self), priv->menubar_r, TRUE, TRUE, 0 ); 
    180      
     190 
    181191        filtitem = gtk_image_menu_item_new_with_label( "Filter Menu" ); 
    182192        GtkWidget* filticon = gtk_image_new_from_stock( "openmoko-filter-menu-icon", GTK_ICON_SIZE_MENU ); 
    183         gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM (filtitem), filticon ); 
     193        gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(filtitem), filticon ); 
    184194        gtk_widget_set_name( filtitem, "transparent" ); 
    185195        priv->filteritem = filtitem; 
    186         priv->filtermenu = GTK_WIDGET (menu); 
    187         gtk_menu_shell_append( GTK_MENU_SHELL (priv->menubar_r), priv->filteritem ); 
    188         gtk_menu_item_set_submenu( GTK_MENU_ITEM (priv->filteritem), priv->filtermenu ); 
     196        priv->filtermenu = GTK_WIDGET(menu); 
     197        g_signal_connect( G_OBJECT(menu), "size-request", G_CALLBACK(cb_menu_size_request), self ); 
     198        gtk_menu_shell_append( GTK_MENU_SHELL(priv->menubar_r), priv->filteritem ); 
     199        gtk_menu_item_set_submenu( GTK_MENU_ITEM(priv->filteritem), priv->filtermenu ); 
    189200    } 
    190201    priv->filtermenu = GTK_WIDGET (menu); 
Note: See TracChangeset for help on using the changeset viewer.