Example #1
0
/* Because GNOME HIG causes some usability problems under limited screen size,
 * this API is provided to adjust the dialogs, and try to fit them into
 * small screens via totally breaking GNOME HIG and compress spacings.
 */
void ptk_dialog_fit_small_screen( GtkDialog* dlg )
{
    GtkRequisition req;
    GdkRectangle wa;
    GtkAllocation allocation;
    int dw, dh, i;

    get_working_area( gtk_widget_get_screen((GtkWidget*)dlg), &wa );
    gtk_widget_size_request( GTK_WIDGET(dlg), &req );

    /* Try two times, so we won't be too aggrassive if mild shinkage can do the job.
     * First time shrink all spacings to their 1/3.
     * If this is not enough, shrink them again by dividing all spacings by 2. (1/6 size now)
     */
    for( i =0; (req.width > wa.width || req.height > wa.height) && i < 2; ++i )
    {
        break_gnome_hig( GTK_WIDGET(dlg), GINT_TO_POINTER((i == 0 ? 3 : 2)) );
        gtk_widget_size_request( GTK_WIDGET(dlg), &req );
        /* g_debug("%d, %d", req.width, req.height ); */
    }

    if( gtk_widget_get_realized( GTK_WIDGET(dlg) ) )
    {
        gtk_widget_get_allocation ( (GtkWidget*)dlg, &allocation);
        gboolean changed = FALSE;
        if( allocation.width > wa.width )
        {
            dw = wa.width;
            changed = TRUE;
        }
        if( allocation.height > wa.width )
        {
            dh = wa.height;
            changed = TRUE;
        }
        if( changed )
            gtk_window_resize( (GtkWindow*)dlg, dw, dh );
        /* gtk_window_move( dlg, 0, 0 ); */
    }
    else
    {
        gtk_window_get_default_size( (GtkWindow*)dlg, &dw, &dh );
        if( dw > wa.width )
            dw = wa.width;
        if( dh > wa.height )
            dh = wa.height;
        gtk_window_set_default_size( GTK_WINDOW(dlg), dw, dh );
    }
}
Example #2
0
void show_notify()
{
	HWND hwnd = CreateDialog( hinst, LPCTSTR(IDD_POPUP), HWND_DESKTOP, 
							  (DLGPROC)notifier_proc );
	SetWindowLong( hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) | WS_BORDER );

	RECT wa_rc, dlg_rc;
	GetWindowRect( hwnd, &dlg_rc );
	get_working_area( &wa_rc, hwnd );
	wa_rc.right -= (dlg_rc.right - dlg_rc.left + 10);
	wa_rc.bottom -= (dlg_rc.bottom - dlg_rc.top);
	SetWindowPos( hwnd, HWND_TOPMOST, wa_rc.right, wa_rc.bottom, 0, 0, SWP_NOSIZE );
	ShowWindow( hwnd, SW_SHOWNA );

	MSG msg;
	while( GetMessage( &msg, NULL, 0, 0 ) ){
		TranslateMessage( &msg );
		DispatchMessage( &msg );
	}
}