~ubuntu-branches/ubuntu/precise/mpeg4ip/precise

« back to all changes in this revision

Viewing changes to player/src/gui_showmsg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello
  • Date: 2008-01-12 15:59:56 UTC
  • Revision ID: james.westby@ubuntu.com-20080112155956-1vznw5njidvrh649
Tags: upstream-1.6dfsg
ImportĀ upstreamĀ versionĀ 1.6dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * The contents of this file are subject to the Mozilla Public
 
3
 * License Version 1.1 (the "License"); you may not use this file
 
4
 * except in compliance with the License. You may obtain a copy of
 
5
 * the License at http://www.mozilla.org/MPL/
 
6
 * 
 
7
 * Software distributed under the License is distributed on an "AS
 
8
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
9
 * implied. See the License for the specific language governing
 
10
 * rights and limitations under the License.
 
11
 * 
 
12
 * The Original Code is MPEG4IP.
 
13
 * 
 
14
 * The Initial Developer of the Original Code is Cisco Systems Inc.
 
15
 * Portions created by Cisco Systems Inc. are
 
16
 * Copyright (C) Cisco Systems Inc. 2000, 2001.  All Rights Reserved.
 
17
 * 
 
18
 * Contributor(s): 
 
19
 *              Bill May        wmay@cisco.com
 
20
 */
 
21
/*
 
22
 * Showmessage.c  from Developing Linux Applications
 
23
 */
 
24
 
 
25
#include <gtk/gtk.h>
 
26
#include "gui_utils.h"
 
27
 
 
28
/*
 
29
 * CloseShowMessage
 
30
 *
 
31
 * Routine to close the about dialog window.
 
32
 */
 
33
static void CloseShowMessage (GtkWidget *widget, gpointer data)
 
34
{
 
35
    GtkWidget *dialog_widget = (GtkWidget *) data;
 
36
 
 
37
    gtk_grab_remove (dialog_widget);
 
38
 
 
39
    /* --- Close the widget --- */
 
40
    gtk_widget_destroy (dialog_widget);
 
41
}
 
42
 
 
43
 
 
44
 
 
45
/*
 
46
 * ClearShowMessage
 
47
 *
 
48
 * Release the window "grab" 
 
49
 * Clear out the global dialog_window since that
 
50
 * is checked when the dialog is brought up.
 
51
 */
 
52
static void ClearShowMessage (GtkWidget *widget, gpointer data)
 
53
{
 
54
    gtk_grab_remove (widget);
 
55
}
 
56
 
 
57
 
 
58
/*
 
59
 * ShowMessage
 
60
 *
 
61
 * Show a popup message to the user.
 
62
 */
 
63
void ShowMessage (const char *szTitle, const char *szMessage)
 
64
{
 
65
    GtkWidget *label;
 
66
    GtkWidget *button;
 
67
    GtkWidget *dialog_window;
 
68
 
 
69
    /* --- Create a dialog window --- */
 
70
    dialog_window = gtk_dialog_new ();
 
71
 
 
72
    gtk_signal_connect (GTK_OBJECT (dialog_window), "destroy",
 
73
              GTK_SIGNAL_FUNC (ClearShowMessage),
 
74
              NULL);
 
75
 
 
76
    /* --- Set the title and add a border --- */
 
77
    gtk_window_set_title (GTK_WINDOW (dialog_window), szTitle);
 
78
    gtk_container_border_width (GTK_CONTAINER (dialog_window), 0);
 
79
 
 
80
    /* --- Create an "Ok" button with the focus --- */
 
81
    button = gtk_button_new_with_label ("OK");
 
82
 
 
83
    gtk_signal_connect (GTK_OBJECT (button), "clicked",
 
84
              GTK_SIGNAL_FUNC (CloseShowMessage),
 
85
              dialog_window);
 
86
 
 
87
    /* --- Default the "Ok" button --- */
 
88
    GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
 
89
    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->action_area), 
 
90
              button, TRUE, TRUE, 0);
 
91
    gtk_widget_grab_default (button);
 
92
    gtk_widget_show (button);
 
93
 
 
94
    /* --- Create a descriptive label --- */
 
95
    label = gtk_label_new (szMessage);
 
96
 
 
97
    /* --- Put some room around the label text --- */
 
98
    gtk_misc_set_padding (GTK_MISC (label), 10, 10);
 
99
 
 
100
    /* --- Add label to designated area on dialog --- */
 
101
    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_window)->vbox), 
 
102
              label, TRUE, TRUE, 0);
 
103
 
 
104
    /* --- Show the label --- */
 
105
    gtk_widget_show (label);
 
106
 
 
107
 
 
108
    /* --- Show the dialog --- */
 
109
    gtk_widget_show (dialog_window);
 
110
 
 
111
    /* --- Only this window can have actions done. --- */
 
112
    gtk_grab_add (dialog_window);
 
113
}
 
114