/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* nautilus-preferences-pane.h - Interface for a prefs pane superclass. Copyright (C) 1999, 2000 Eazel, Inc. The Gnome Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The Gnome Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the Gnome Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Authors: Ramiro Estrugo */ #include #include #include #include #include #include enum { ACTIVATE, LAST_SIGNAL }; static const guint PREFS_PANE_GROUPS_BOX_TOP_OFFSET = 0; struct _NautilusPreferencesPaneDetails { GtkWidget *title_box; GtkWidget *title_frame; GtkWidget *title_label; GtkWidget *description_label; GtkWidget *groups_box; gboolean show_title; GSList *groups; }; typedef void (*GnomeBoxSignal1) (GtkObject* object, gint arg1, gpointer data); /* NautilusPreferencesPaneClass methods */ static void nautilus_preferences_pane_initialize_class (NautilusPreferencesPaneClass *klass); static void nautilus_preferences_pane_initialize (NautilusPreferencesPane *prefs_pane); /* GtkObjectClass methods */ static void nautilus_preferences_pane_destroy (GtkObject *object); /* Private stuff */ static void prefs_pane_construct (NautilusPreferencesPane *prefs_pane, const gchar *pane_title, const gchar *pane_description); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferencesPane, nautilus_preferences_pane, GTK_TYPE_VBOX) /* * NautilusPreferencesPaneClass methods */ static void nautilus_preferences_pane_initialize_class (NautilusPreferencesPaneClass *prefs_pane_class) { GtkObjectClass *object_class; GtkWidgetClass *widget_class; object_class = GTK_OBJECT_CLASS (prefs_pane_class); widget_class = GTK_WIDGET_CLASS (prefs_pane_class); parent_class = gtk_type_class (gtk_vbox_get_type ()); /* GtkObjectClass */ object_class->destroy = nautilus_preferences_pane_destroy; } static void nautilus_preferences_pane_initialize (NautilusPreferencesPane *prefs_pane) { prefs_pane->details = g_new (NautilusPreferencesPaneDetails, 1); prefs_pane->details->title_label = NULL; prefs_pane->details->description_label = NULL; prefs_pane->details->title_box = NULL; prefs_pane->details->title_frame = NULL; prefs_pane->details->groups_box = NULL; prefs_pane->details->groups = NULL; prefs_pane->details->show_title = FALSE; } /* * GtkObjectClass methods */ static void nautilus_preferences_pane_destroy(GtkObject* object) { NautilusPreferencesPane * prefs_pane; g_return_if_fail (object != NULL); g_return_if_fail (NAUTILUS_IS_PREFS_PANE (object)); prefs_pane = NAUTILUS_PREFERENCES_PANE (object); if (prefs_pane->details->groups) { g_slist_free (prefs_pane->details->groups); } g_free (prefs_pane->details); /* Chain */ if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } /* * Private stuff */ static void prefs_pane_construct (NautilusPreferencesPane *prefs_pane, const gchar *pane_title, const gchar *pane_description) { g_assert (prefs_pane != NULL); g_assert (prefs_pane->details != NULL); g_assert (pane_title != NULL); g_assert (pane_description != NULL); g_assert (prefs_pane->details->title_label == NULL); g_assert (prefs_pane->details->description_label == NULL); g_assert (prefs_pane->details->title_box == NULL); g_assert (prefs_pane->details->groups_box == NULL); g_assert (prefs_pane->details->title_frame == NULL); g_assert (prefs_pane->details->groups == NULL); prefs_pane->details->groups = g_slist_alloc (); if (prefs_pane->details->show_title) { /* Title frame */ prefs_pane->details->title_frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (prefs_pane->details->title_frame), GTK_SHADOW_ETCHED_IN); /* Title box */ prefs_pane->details->title_box = gtk_hbox_new (FALSE, 0); /* Title labels */ prefs_pane->details->title_label = gtk_label_new (pane_title); prefs_pane->details->description_label = gtk_label_new (pane_description); gtk_box_pack_start (GTK_BOX (prefs_pane->details->title_box), prefs_pane->details->title_label, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (prefs_pane->details->title_box), prefs_pane->details->description_label, FALSE, FALSE, 0); gtk_widget_show (prefs_pane->details->title_label); gtk_widget_show (prefs_pane->details->description_label); /* Add title box to title frame */ gtk_container_add (GTK_CONTAINER (prefs_pane->details->title_frame), prefs_pane->details->title_box); gtk_widget_show (prefs_pane->details->title_box); /* Add title frame to ourselves */ gtk_box_pack_start (GTK_BOX (prefs_pane), prefs_pane->details->title_frame, FALSE, FALSE, 0); gtk_widget_show (prefs_pane->details->title_frame); } /* Groups box */ prefs_pane->details->groups_box = gtk_vbox_new (TRUE, 0); /* Add groups box to ourselves */ gtk_box_pack_start (GTK_BOX (prefs_pane), prefs_pane->details->groups_box, FALSE, FALSE, PREFS_PANE_GROUPS_BOX_TOP_OFFSET); gtk_widget_show (prefs_pane->details->groups_box); } /* * NautilusPreferencesPane public methods */ GtkWidget* nautilus_preferences_pane_new (const gchar *pane_title, const gchar *pane_description) { NautilusPreferencesPane *prefs_pane; g_return_val_if_fail (pane_title != NULL, NULL); g_return_val_if_fail (pane_description != NULL, NULL); prefs_pane = gtk_type_new (nautilus_preferences_pane_get_type ()); prefs_pane_construct (prefs_pane, pane_title, pane_description); return GTK_WIDGET (prefs_pane); } void nautilus_preferences_pane_set_title (NautilusPreferencesPane *prefs_pane, const gchar *pane_title) { g_return_if_fail (prefs_pane != NULL); g_return_if_fail (NAUTILUS_IS_PREFS_PANE (prefs_pane)); g_assert (prefs_pane->details->title_label != NULL); gtk_label_set_text (GTK_LABEL (prefs_pane->details->title_label), pane_title); } void nautilus_preferences_pane_set_description (NautilusPreferencesPane *prefs_pane, const gchar *pane_description) { g_return_if_fail (prefs_pane != NULL); g_return_if_fail (NAUTILUS_IS_PREFS_PANE (prefs_pane)); g_assert (prefs_pane->details->description_label != NULL); gtk_label_set_text (GTK_LABEL (prefs_pane->details->description_label), pane_description); } void nautilus_preferences_pane_add_group (NautilusPreferencesPane *prefs_pane, GtkWidget *prefs_group) { g_return_if_fail (prefs_pane != NULL); g_return_if_fail (NAUTILUS_IS_PREFS_PANE (prefs_pane)); g_return_if_fail (prefs_group != NULL); gtk_box_pack_start (GTK_BOX (prefs_pane->details->groups_box), prefs_group, TRUE, TRUE, 0); }