ergtkbusydialog.c

Go to the documentation of this file.
00001 /**
00002  * \file ergtkbusydialog.c
00003  * \brief ereader gtk library - GtkBusyDialog widget for ereader system
00004  */
00005 
00006 /*
00007  * This file is part of libergtk.
00008  *
00009  * libergtk is free software: you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation, either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * libergtk is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00021  */
00022 
00023 /**
00024  * Copyright (C) 2008 iRex Technologies B.V.
00025  * All rights reserved.
00026  */
00027 
00028 // system include files
00029 #include <gtk/gtk.h>
00030 
00031 // ereader library includes
00032 
00033 // local includes
00034 #include "ergtk_log.h"
00035 #include "ergtkbusydialog.h"
00036 
00037 
00038 G_DEFINE_TYPE (erGtkBusyDialog, ergtk_busy_dialog, GTK_TYPE_DIALOG)
00039 
00040 
00041 static void ergtk_busy_dialog_class_init (erGtkBusyDialogClass *klass)
00042 {
00043 //    GObjectClass *object_class = (GObjectClass *) klass;
00044 //    GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
00045 }
00046 
00047 // init instance
00048 static void ergtk_busy_dialog_init (erGtkBusyDialog *dialog)
00049 {
00050 //    GtkDialog *parent = (GtkDialog *) dialog;
00051     GtkWidget *vbox;
00052     GtkWidget *eventbox;
00053     GdkPixbuf *pixbuf;
00054     
00055     g_return_if_fail(ERGTK_IS_BUSY_DIALOG(dialog));
00056 
00057     // window settings
00058     gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
00059     gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
00060     gtk_window_set_title (GTK_WINDOW (dialog), "");
00061     gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), TRUE);
00062     gtk_window_set_decorated(GTK_WINDOW (dialog), FALSE);
00063     gtk_window_set_accept_focus(GTK_WINDOW(dialog), FALSE);
00064     gtk_widget_realize(GTK_WIDGET(dialog));
00065     gdk_window_set_decorations(GTK_WIDGET(dialog)->window, GDK_DECOR_BORDER);
00066 
00067     // Put the window in the center of its parent.
00068     gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT);
00069 
00070     // container settings
00071     gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE);
00072     gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
00073     gtk_box_set_spacing (GTK_BOX (GTK_DIALOG(dialog)->vbox), 2);
00074     gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), 5);
00075     
00076     // vbox
00077     //  |
00078     vbox = gtk_vbox_new (FALSE, 12);
00079     gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);    
00080     gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->vbox), vbox, TRUE, TRUE, 0);
00081     gtk_widget_show(vbox);
00082 
00083     //  |-- pixbuf image
00084     //  |
00085     pixbuf = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), "dialog-busy", 48, 0, NULL);
00086     dialog->image = gtk_image_new_from_pixbuf(pixbuf);
00087     gtk_box_pack_start (GTK_BOX (vbox), dialog->image, FALSE, FALSE, 25);
00088     gtk_widget_show(dialog->image);
00089 
00090     //  |-- eventbox (spacer)
00091     //  |
00092     eventbox = gtk_event_box_new();
00093     gtk_widget_set_size_request(eventbox, 400, 1);
00094     gtk_box_pack_start (GTK_BOX (vbox), eventbox, FALSE, FALSE, 0);
00095     gtk_widget_show(eventbox);
00096     
00097     //  |-- label text
00098     //
00099     dialog->label = gtk_label_new (NULL);
00100     gtk_label_set_line_wrap  (GTK_LABEL (dialog->label), FALSE);
00101     gtk_label_set_selectable (GTK_LABEL (dialog->label), FALSE);
00102     gtk_label_set_justify    (GTK_LABEL (dialog->label), GTK_JUSTIFY_CENTER);    
00103     gtk_box_pack_start (GTK_BOX (vbox), dialog->label, FALSE, FALSE, 0);
00104     gtk_widget_show(dialog->label);
00105 }
00106 
00107      
00108 GtkWidget *ergtk_busy_dialog_new (const gchar *label_text)
00109 {
00110     erGtkBusyDialog *dialog;
00111 
00112     LOGPRINTF("entry");
00113 
00114     dialog = g_object_new (ERGTK_TYPE_BUSY_DIALOG, NULL);
00115 
00116     if (label_text)
00117     {
00118         gtk_label_set_text (GTK_LABEL (dialog->label), label_text);
00119     }
00120 
00121     return GTK_WIDGET (dialog);
00122 }
Generated by  doxygen 1.6.2-20100208