attachment:ui_dialog.c of UMEGuide/ApplicationDevelopment/PortingCAppsToUME


Attachment 'ui_dialog.c'

Download

Toggle line numbers
   1 /**
   2  * @file ui_dialog.c UI dialog handling
   3  *
   4  * Copyright (C) 2007 Lars Lindner <lars.lindner@gmail.com>
   5  *
   6  * This library is free software; you can redistribute it and/or
   7  * modify it under the terms of the GNU Library General Public
   8  * License as published by the Free Software Foundation; either
   9  * version 2 of the License, or (at your option) any later version.
  10  * 
  11  * This library is distributed in the hope that it will be useful,
  12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14  * Library General Public License for more details.
  15  * 
  16  * You should have received a copy of the GNU Library General Public License
  17  * along with this library; see the file COPYING.LIB.  If not, write to
  18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19  * Boston, MA 02111-1307, USA.
  20  */
  21 
  22 #ifdef HAVE_CONFIG_H
  23 #  include <config.h>
  24 #endif
  25 
  26 #include <gtk/gtk.h>
  27 #include <glade/glade.h>
  28 
  29 #include "ui/ui_dialog.h"
  30 #include "ui/ui_shell.h"
  31 
  32 static void liferea_dialog_class_init	(LifereaDialogClass *klass);
  33 static void liferea_dialog_init		(LifereaDialog *ld);
  34 
  35 #define LIFEREA_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), LIFEREA_DIALOG_TYPE, LifereaDialogPrivate))
  36 
  37 struct LifereaDialogPrivate {
  38 	GladeXML	*xml;
  39 	
  40 	GtkWidget	*dialog;
  41 };
  42 
  43 static GObjectClass *parent_class = NULL;
  44 
  45 GType
  46 liferea_dialog_get_type (void) 
  47 {
  48 	static GType type = 0;
  49 
  50 	if (G_UNLIKELY (type == 0)) 
  51 	{
  52 		static const GTypeInfo our_info = 
  53 		{
  54 			sizeof (LifereaDialogClass),
  55 			NULL, /* base_init */
  56 			NULL, /* base_finalize */
  57 			(GClassInitFunc) liferea_dialog_class_init,
  58 			NULL,
  59 			NULL, /* class_data */
  60 			sizeof (LifereaDialog),
  61 			0, /* n_preallocs */
  62 			(GInstanceInitFunc) liferea_dialog_init
  63 		};
  64 
  65 		type = g_type_register_static (G_TYPE_OBJECT,
  66 					       "LifereaDialog",
  67 					       &our_info, 0);
  68 	}
  69 
  70 	return type;
  71 }
  72 
  73 static void
  74 liferea_dialog_finalize (GObject *object)
  75 {
  76 	LifereaDialog *ls = LIFEREA_DIALOG (object);
  77 	
  78 	g_object_unref (ls->priv->xml);
  79 
  80 	G_OBJECT_CLASS (parent_class)->finalize (object);
  81 }
  82 
  83 static void
  84 liferea_dialog_destroy_cb (GtkWidget *widget, LifereaDialog *ld)
  85 {
  86 	g_object_unref (ld);
  87 }
  88 
  89 static void
  90 liferea_dialog_class_init (LifereaDialogClass *klass)
  91 {
  92 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
  93 
  94 	parent_class = g_type_class_peek_parent (klass);
  95 
  96 	object_class->finalize = liferea_dialog_finalize;
  97 
  98 	g_type_class_add_private (object_class, sizeof(LifereaDialogPrivate));
  99 }
 100 
 101 static void
 102 liferea_dialog_init (LifereaDialog *ld)
 103 {
 104 	ld->priv = LIFEREA_DIALOG_GET_PRIVATE (ld);
 105 }
 106 
 107 GtkWidget *
 108 liferea_dialog_lookup (GtkWidget *widget, const gchar *name)
 109 {
 110 	LifereaDialog	*ld;
 111 	
 112 	if (!widget)
 113 		return NULL;
 114 
 115 	ld = LIFEREA_DIALOG (g_object_get_data (G_OBJECT (widget), "LifereaDialog"));
 116 		
 117 	if (!IS_LIFEREA_DIALOG (ld)) {
 118 		g_warning ("Fatal: liferea_dialog_lookup() called with something that is not a Liferea dialog!");
 119 		return NULL;
 120 	}
 121 	
 122 	if (ld->priv->xml)
 123 		return glade_xml_get_widget (ld->priv->xml, name);
 124 		
 125 	return NULL;
 126 }
 127 
 128 
 129 GtkWidget *
 130 liferea_dialog_new (const gchar *filename, const gchar *name) 
 131 {
 132 	LifereaDialog	*ld;
 133 	
 134 	ld = LIFEREA_DIALOG (g_object_new (LIFEREA_DIALOG_TYPE, NULL));
 135 
 136 	if (filename)
 137 		ld->priv->xml = glade_xml_new (filename, name, GETTEXT_PACKAGE);
 138 	else
 139 #ifdef MAEMO_CHANGES
 140 		ld->priv->xml = glade_xml_new (PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "liferea_hildon.glade", name, GETTEXT_PACKAGE);
 141 #else
 142 		ld->priv->xml = glade_xml_new (PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "liferea.glade", name, GETTEXT_PACKAGE);
 143 #endif
 144 	g_return_val_if_fail (ld->priv->xml != NULL, NULL);
 145 
 146 	ld->priv->dialog = glade_xml_get_widget (ld->priv->xml, name);
 147 	glade_xml_signal_autoconnect (ld->priv->xml);
 148 	g_return_val_if_fail (ld->priv->dialog != NULL, NULL);
 149 	
 150 	g_object_set_data (G_OBJECT (ld->priv->dialog), "LifereaDialog", ld);
 151 	
 152 	gtk_window_set_transient_for (GTK_WINDOW (ld->priv->dialog), GTK_WINDOW (liferea_shell_lookup ("mainwindow")));
 153 
 154 	g_signal_connect_object (ld->priv->dialog, "destroy", G_CALLBACK (liferea_dialog_destroy_cb), ld, 0);
 155 	
 156 	return ld->priv->dialog;
 157 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2007-09-29 18:23:59, 2.0 KB) [[attachment:Makefile.am]]
  • [get | view] (2007-09-29 18:27:09, 0.9 KB) [[attachment:Makefile.am from ui directory]]
  • [get | view] (2007-09-29 18:19:25, 16.5 KB) [[attachment:configure.ac]]
  • [get | view] (2007-09-29 18:46:32, 110.7 KB) [[attachment:hildonized.png]]
  • [get | view] (2007-09-29 19:02:18, 6630.1 KB) [[attachment:liferea-1.4.2b.tar.gz]]
  • [get | view] (2007-09-29 18:31:43, 286.9 KB) [[attachment:liferea.glade]]
  • [get | view] (2007-09-29 18:43:07, 91.2 KB) [[attachment:liferea.png]]
  • [get | view] (2007-09-29 18:32:30, 286.8 KB) [[attachment:liferea_hildon.glade]]
  • [get | view] (2007-09-29 18:47:27, 62.2 KB) [[attachment:liferea_maemo.png]]
  • [get | view] (2007-09-29 18:28:40, 0.9 KB) [[attachment:ui makefile]]
  • [get | view] (2007-09-29 18:30:47, 0.9 KB) [[attachment:ui_Makefile.am]]
  • [get | view] (2007-09-29 18:36:26, 4.1 KB) [[attachment:ui_dialog.c]]
  • [get | view] (2007-09-29 18:53:17, 44.9 KB) [[attachment:ui_mainwindow.c]]
  • [get | view] (2007-09-29 18:35:59, 3.2 KB) [[attachment:ui_shell.c]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.