2009-10-18 20:06:24 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2007-2009 Christian Dywan <christian@twotoasts.de>
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
See the file COPYING for the full license text.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "katze-preferences.h"
|
|
|
|
|
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2012-06-26 21:38:30 +00:00
|
|
|
#ifdef HAVE_GRANITE
|
|
|
|
#if HAVE_OSX
|
|
|
|
#error FIXME granite on OSX is not implemented
|
|
|
|
#endif
|
|
|
|
#include <granite.h>
|
|
|
|
#endif
|
|
|
|
|
2009-10-25 14:19:34 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
#include "katze-scrolled.h"
|
2009-10-28 22:58:32 +00:00
|
|
|
#include <hildon/hildon.h>
|
2009-10-25 14:19:34 +00:00
|
|
|
#endif
|
2009-10-18 20:06:24 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
|
|
|
struct _KatzePreferencesPrivate
|
|
|
|
{
|
|
|
|
#if HAVE_HILDON
|
2009-10-25 14:19:34 +00:00
|
|
|
GtkWidget* scrolled;
|
|
|
|
GtkSizeGroup* sizegroup;
|
|
|
|
GtkSizeGroup* sizegroup2;
|
|
|
|
GtkWidget* box;
|
|
|
|
GtkWidget* hbox;
|
2009-10-18 20:06:24 +00:00
|
|
|
#else
|
|
|
|
GtkWidget* notebook;
|
|
|
|
GtkWidget* toolbar;
|
|
|
|
GtkWidget* toolbutton;
|
|
|
|
GtkSizeGroup* sizegroup;
|
|
|
|
GtkSizeGroup* sizegroup2;
|
|
|
|
GtkWidget* page;
|
|
|
|
GtkWidget* frame;
|
|
|
|
GtkWidget* box;
|
|
|
|
GtkWidget* hbox;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (KatzePreferences, katze_preferences, GTK_TYPE_DIALOG);
|
|
|
|
|
|
|
|
static void
|
|
|
|
katze_preferences_finalize (GObject* object);
|
|
|
|
|
|
|
|
static void
|
|
|
|
katze_preferences_class_init (KatzePreferencesClass* class)
|
|
|
|
{
|
|
|
|
GObjectClass* gobject_class = G_OBJECT_CLASS (class);
|
|
|
|
gobject_class->finalize = katze_preferences_finalize;
|
|
|
|
|
|
|
|
g_type_class_add_private (class, sizeof (KatzePreferencesPrivate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
katze_preferences_response_cb (KatzePreferences* preferences,
|
|
|
|
gint response)
|
|
|
|
{
|
2009-10-25 14:19:34 +00:00
|
|
|
if (response == GTK_RESPONSE_CLOSE || response == GTK_RESPONSE_APPLY)
|
2009-10-18 20:06:24 +00:00
|
|
|
gtk_widget_destroy (GTK_WIDGET (preferences));
|
|
|
|
}
|
|
|
|
|
2009-11-27 22:42:07 +00:00
|
|
|
#ifdef HAVE_HILDON_2_2
|
|
|
|
static void
|
|
|
|
katze_preferences_size_request_cb (KatzePreferences* preferences,
|
|
|
|
GtkRequisition* requisition)
|
|
|
|
{
|
|
|
|
GdkScreen* screen = gtk_widget_get_screen (GTK_WIDGET (preferences));
|
|
|
|
if (gdk_screen_get_height (screen) > gdk_screen_get_width (screen))
|
|
|
|
gtk_widget_hide (gtk_dialog_get_action_area (GTK_DIALOG (preferences)));
|
|
|
|
else
|
|
|
|
gtk_widget_show (gtk_dialog_get_action_area (GTK_DIALOG (preferences)));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-10-18 20:06:24 +00:00
|
|
|
static void
|
|
|
|
katze_preferences_init (KatzePreferences* preferences)
|
|
|
|
{
|
|
|
|
KatzePreferencesPrivate* priv;
|
|
|
|
gchar* dialog_title;
|
|
|
|
|
|
|
|
preferences->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE ((preferences),
|
|
|
|
KATZE_TYPE_PREFERENCES, KatzePreferencesPrivate);
|
|
|
|
|
|
|
|
dialog_title = g_strdup_printf (_("Preferences for %s"),
|
|
|
|
g_get_application_name ());
|
|
|
|
g_object_set (preferences,
|
|
|
|
"icon-name", GTK_STOCK_PREFERENCES,
|
|
|
|
"title", dialog_title,
|
2011-10-01 13:12:04 +00:00
|
|
|
#if !GTK_CHECK_VERSION (3, 0, 0)
|
2009-10-18 20:06:24 +00:00
|
|
|
"has-separator", FALSE,
|
2011-10-01 13:12:04 +00:00
|
|
|
#endif
|
2009-10-18 20:06:24 +00:00
|
|
|
NULL);
|
|
|
|
g_free (dialog_title);
|
|
|
|
|
|
|
|
#if !HAVE_OSX
|
|
|
|
gtk_dialog_add_buttons (GTK_DIALOG (preferences),
|
|
|
|
GTK_STOCK_HELP, GTK_RESPONSE_HELP,
|
2011-12-16 01:06:35 +00:00
|
|
|
NULL);
|
|
|
|
#if GTK_CHECK_VERSION (3, 0, 0)
|
|
|
|
gtk_style_context_add_class (gtk_widget_get_style_context (
|
|
|
|
gtk_dialog_get_widget_for_response (GTK_DIALOG (preferences),
|
|
|
|
GTK_RESPONSE_HELP)), "help_button");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gtk_dialog_add_buttons (GTK_DIALOG (preferences),
|
2009-10-25 14:19:34 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
GTK_STOCK_SAVE, GTK_RESPONSE_APPLY,
|
|
|
|
#else
|
2009-10-18 20:06:24 +00:00
|
|
|
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
2009-10-25 14:19:34 +00:00
|
|
|
#endif
|
2009-10-18 20:06:24 +00:00
|
|
|
NULL);
|
|
|
|
#endif
|
2009-11-27 22:42:07 +00:00
|
|
|
|
2009-10-18 20:06:24 +00:00
|
|
|
g_object_connect (preferences,
|
|
|
|
"signal::response", katze_preferences_response_cb, NULL,
|
|
|
|
NULL);
|
2009-11-27 22:42:07 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_HILDON_2_2
|
|
|
|
katze_preferences_size_request_cb (preferences, NULL);
|
|
|
|
g_object_connect (preferences,
|
|
|
|
"signal::size-request", katze_preferences_size_request_cb, NULL,
|
|
|
|
NULL);
|
|
|
|
#endif
|
2009-10-18 20:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
katze_preferences_finalize (GObject* object)
|
|
|
|
{
|
|
|
|
G_OBJECT_CLASS (katze_preferences_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* katze_preferences_new:
|
|
|
|
* @parent: the parent window, or %NULL
|
|
|
|
*
|
|
|
|
* Creates a new preferences dialog.
|
|
|
|
*
|
|
|
|
* Return value: a new #KatzePreferences
|
|
|
|
*
|
|
|
|
* Since: 0.2.1
|
|
|
|
**/
|
|
|
|
GtkWidget*
|
|
|
|
katze_preferences_new (GtkWindow* parent)
|
|
|
|
{
|
|
|
|
KatzePreferences* preferences;
|
|
|
|
|
|
|
|
g_return_val_if_fail (!parent || GTK_IS_WINDOW (parent), NULL);
|
|
|
|
|
|
|
|
preferences = g_object_new (KATZE_TYPE_PREFERENCES,
|
|
|
|
"transient-for", parent,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return GTK_WIDGET (preferences);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if HAVE_OSX
|
|
|
|
static void
|
|
|
|
katze_preferences_help_clicked_cb (GtkWidget* button,
|
|
|
|
GtkDialog* dialog)
|
|
|
|
{
|
|
|
|
gtk_dialog_response (dialog, GTK_RESPONSE_HELP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
katze_preferences_toolbutton_clicked_cb (GtkWidget* toolbutton,
|
|
|
|
GtkWidget* page)
|
|
|
|
{
|
|
|
|
gpointer notebook = g_object_get_data (G_OBJECT (toolbutton), "notebook");
|
|
|
|
guint n = gtk_notebook_page_num (notebook, page);
|
|
|
|
gtk_notebook_set_current_page (notebook, n);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-10-25 14:19:34 +00:00
|
|
|
static void
|
|
|
|
katze_preferences_prepare (KatzePreferences* preferences)
|
|
|
|
{
|
|
|
|
KatzePreferencesPrivate* priv = preferences->priv;
|
|
|
|
|
|
|
|
#if HAVE_HILDON
|
|
|
|
GtkWidget* viewport;
|
|
|
|
|
|
|
|
priv->scrolled = katze_scrolled_new (NULL, NULL);
|
2010-01-29 21:58:36 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (preferences))),
|
2009-10-25 14:19:34 +00:00
|
|
|
priv->scrolled, TRUE, TRUE, 4);
|
|
|
|
viewport = gtk_viewport_new (NULL, NULL);
|
|
|
|
gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->scrolled), viewport);
|
|
|
|
priv->box = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (viewport), priv->box);
|
|
|
|
|
|
|
|
priv->hbox = NULL;
|
|
|
|
priv->sizegroup = NULL;
|
|
|
|
priv->sizegroup2 = NULL;
|
|
|
|
|
2009-11-27 22:42:07 +00:00
|
|
|
g_signal_connect (priv->scrolled, "destroy",
|
|
|
|
G_CALLBACK (gtk_widget_destroyed), &priv->scrolled);
|
2009-10-25 14:19:34 +00:00
|
|
|
#else
|
2012-06-26 21:38:30 +00:00
|
|
|
#if HAVE_GRANITE
|
2012-07-11 22:14:48 +00:00
|
|
|
/* FIXME: granite: should return GtkWidget* like GTK+ */
|
|
|
|
priv->notebook = (GtkWidget*)granite_widgets_static_notebook_new (FALSE);
|
2012-06-26 21:38:30 +00:00
|
|
|
#else
|
2009-10-25 14:19:34 +00:00
|
|
|
priv->notebook = gtk_notebook_new ();
|
2012-06-26 21:38:30 +00:00
|
|
|
#endif
|
2009-10-25 14:19:34 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), 6);
|
|
|
|
|
|
|
|
#if HAVE_OSX
|
2009-11-16 22:33:32 +00:00
|
|
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
|
|
|
|
gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
|
2009-10-25 14:19:34 +00:00
|
|
|
priv->toolbar = gtk_toolbar_new ();
|
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (priv->toolbar), GTK_TOOLBAR_BOTH);
|
|
|
|
gtk_toolbar_set_show_arrow (GTK_TOOLBAR (priv->toolbar), FALSE);
|
2010-01-29 21:58:36 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (preferences))),
|
2009-10-25 14:19:34 +00:00
|
|
|
priv->toolbar, FALSE, FALSE, 0);
|
|
|
|
#else
|
|
|
|
priv->toolbar = NULL;
|
|
|
|
#endif
|
|
|
|
priv->toolbutton = NULL;
|
2010-01-29 21:58:36 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (preferences))),
|
2010-01-24 10:06:10 +00:00
|
|
|
priv->notebook, TRUE, TRUE, 4);
|
2009-10-25 14:19:34 +00:00
|
|
|
|
|
|
|
priv->sizegroup = NULL;
|
|
|
|
priv->sizegroup2 = NULL;
|
|
|
|
priv->page = NULL;
|
|
|
|
priv->frame = NULL;
|
|
|
|
priv->box = NULL;
|
|
|
|
priv->hbox = NULL;
|
|
|
|
|
2009-11-27 22:42:07 +00:00
|
|
|
g_signal_connect (priv->notebook, "destroy",
|
|
|
|
G_CALLBACK (gtk_widget_destroyed), &priv->notebook);
|
2009-10-25 14:19:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_OSX
|
|
|
|
GtkWidget* icon;
|
2009-11-16 22:33:32 +00:00
|
|
|
GtkWidget* hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
GtkWidget* button = gtk_button_new ();
|
2009-10-25 14:19:34 +00:00
|
|
|
icon = gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_button_set_image (GTK_BUTTON (button), icon);
|
|
|
|
g_signal_connect (button, "clicked",
|
|
|
|
G_CALLBACK (katze_preferences_help_clicked_cb), preferences);
|
2009-11-27 22:42:07 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 4);
|
2009-11-16 22:33:32 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (GTK_DIALOG (preferences)->action_area),
|
2009-10-25 14:19:34 +00:00
|
|
|
hbox, FALSE, FALSE, 0);
|
|
|
|
#endif
|
2010-01-29 21:58:36 +00:00
|
|
|
gtk_widget_show_all (gtk_dialog_get_content_area (GTK_DIALOG (preferences)));
|
2009-10-25 14:19:34 +00:00
|
|
|
}
|
|
|
|
|
2009-10-18 20:06:24 +00:00
|
|
|
/**
|
|
|
|
* katze_preferences_add_category:
|
|
|
|
* @preferences: a #KatzePreferences instance
|
|
|
|
* @label: a category label
|
|
|
|
* @icon: an icon name
|
|
|
|
*
|
|
|
|
* Adds a new category with the specified label to the dialog.
|
|
|
|
*
|
|
|
|
* Since: 0.2.1
|
2011-04-14 01:29:50 +00:00
|
|
|
*
|
|
|
|
* Since 0.3.4 a #GtkBox is returned that can be packed into.
|
2009-10-18 20:06:24 +00:00
|
|
|
**/
|
2011-04-14 01:29:50 +00:00
|
|
|
GtkWidget*
|
2009-10-18 20:06:24 +00:00
|
|
|
katze_preferences_add_category (KatzePreferences* preferences,
|
|
|
|
const gchar* label,
|
|
|
|
const gchar* icon)
|
|
|
|
{
|
2011-04-14 01:29:50 +00:00
|
|
|
KatzePreferencesPrivate* priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (KATZE_IS_PREFERENCES (preferences), NULL);
|
|
|
|
g_return_val_if_fail (label != NULL, NULL);
|
|
|
|
g_return_val_if_fail (icon != NULL, NULL);
|
|
|
|
|
|
|
|
priv = preferences->priv;
|
2009-10-18 20:06:24 +00:00
|
|
|
|
2009-10-25 14:19:34 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
GtkWidget* widget;
|
|
|
|
gchar* markup;
|
|
|
|
|
|
|
|
if (!priv->scrolled)
|
|
|
|
katze_preferences_prepare (preferences);
|
|
|
|
|
|
|
|
widget = gtk_label_new (NULL);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
markup = g_markup_printf_escaped ("<b>%s</b>", label);
|
|
|
|
gtk_label_set_markup (GTK_LABEL (widget), markup);
|
|
|
|
g_free (markup);
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->box), widget, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
priv->sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
priv->sizegroup2 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
2009-10-27 22:47:11 +00:00
|
|
|
priv->hbox = NULL;
|
2009-10-25 14:19:34 +00:00
|
|
|
#else
|
|
|
|
if (!priv->notebook)
|
|
|
|
katze_preferences_prepare (preferences);
|
|
|
|
|
2009-10-18 20:06:24 +00:00
|
|
|
priv->page = gtk_vbox_new (FALSE, 0);
|
2009-11-22 14:31:53 +00:00
|
|
|
priv->sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
2009-10-18 20:06:24 +00:00
|
|
|
gtk_widget_show (priv->page);
|
2009-10-25 14:19:34 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (priv->page), 4);
|
2012-06-26 21:38:30 +00:00
|
|
|
#if HAVE_GRANITE
|
|
|
|
granite_widgets_static_notebook_append_page (
|
|
|
|
GRANITE_WIDGETS_STATIC_NOTEBOOK (priv->notebook),
|
2012-07-02 22:23:33 +00:00
|
|
|
priv->page, GTK_LABEL (gtk_label_new (label)));
|
2012-06-26 21:38:30 +00:00
|
|
|
#else
|
2009-10-25 14:19:34 +00:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
|
|
|
|
priv->page, gtk_label_new (label));
|
2012-06-26 21:38:30 +00:00
|
|
|
#endif
|
2009-10-18 20:06:24 +00:00
|
|
|
#if HAVE_OSX
|
|
|
|
priv->toolbutton = GTK_WIDGET (priv->toolbutton ?
|
|
|
|
gtk_radio_tool_button_new_from_widget (
|
|
|
|
GTK_RADIO_TOOL_BUTTON (priv->toolbutton))
|
|
|
|
: gtk_radio_tool_button_new (NULL));
|
2009-11-16 22:33:32 +00:00
|
|
|
gtk_widget_show (priv->toolbutton);
|
2009-10-18 20:06:24 +00:00
|
|
|
gtk_tool_button_set_label (GTK_TOOL_BUTTON (priv->toolbutton), label);
|
|
|
|
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (priv->toolbutton), icon);
|
2009-11-16 22:33:32 +00:00
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar),
|
2009-10-18 20:06:24 +00:00
|
|
|
GTK_TOOL_ITEM (priv->toolbutton), -1);
|
|
|
|
g_signal_connect (priv->toolbutton, "clicked",
|
2009-11-16 22:33:32 +00:00
|
|
|
G_CALLBACK (katze_preferences_toolbutton_clicked_cb), priv->page);
|
2009-10-18 20:06:24 +00:00
|
|
|
if (priv->toolbutton)
|
|
|
|
g_object_set_data (G_OBJECT (priv->toolbutton), "notebook", priv->notebook);
|
|
|
|
#endif
|
2009-10-25 14:19:34 +00:00
|
|
|
#endif
|
2011-04-14 01:29:50 +00:00
|
|
|
|
|
|
|
return priv->page;
|
2009-10-18 20:06:24 +00:00
|
|
|
}
|
|
|
|
|
2009-10-25 14:19:34 +00:00
|
|
|
#if !HAVE_HILDON
|
2009-10-18 20:06:24 +00:00
|
|
|
static GtkWidget*
|
|
|
|
katze_hig_frame_new (const gchar* title)
|
|
|
|
{
|
|
|
|
/* Create a frame with no actual frame but a bold label and indentation */
|
|
|
|
GtkWidget* frame = gtk_frame_new (NULL);
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
gtk_frame_set_label (GTK_FRAME (frame), title);
|
|
|
|
#else
|
|
|
|
gchar* title_bold = g_strdup_printf ("<b>%s</b>", title);
|
|
|
|
GtkWidget* label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label), title_bold);
|
|
|
|
g_free (title_bold);
|
|
|
|
gtk_frame_set_label_widget (GTK_FRAME (frame), label);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
|
|
|
|
#endif
|
|
|
|
return frame;
|
|
|
|
}
|
2009-10-25 14:19:34 +00:00
|
|
|
#endif
|
2009-10-18 20:06:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* katze_preferences_add_group:
|
|
|
|
* @preferences: a #KatzePreferences instance
|
2011-05-01 22:02:54 +00:00
|
|
|
* @label: a group label, or %NULL
|
2009-10-18 20:06:24 +00:00
|
|
|
*
|
|
|
|
* Adds a new group with the specified label to the dialog.
|
|
|
|
*
|
|
|
|
* Since: 0.2.1
|
2011-05-01 22:02:54 +00:00
|
|
|
*
|
|
|
|
* Since 0.3.4 you can pass %NULL to hide the label.
|
2009-10-18 20:06:24 +00:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
katze_preferences_add_group (KatzePreferences* preferences,
|
|
|
|
const gchar* label)
|
|
|
|
{
|
2009-10-25 14:19:34 +00:00
|
|
|
#if !HAVE_HILDON
|
2011-04-14 01:29:50 +00:00
|
|
|
KatzePreferencesPrivate* priv;
|
|
|
|
|
|
|
|
g_return_if_fail (KATZE_IS_PREFERENCES (preferences));
|
2009-10-18 20:06:24 +00:00
|
|
|
|
2011-04-14 01:29:50 +00:00
|
|
|
priv = preferences->priv;
|
2009-10-18 20:06:24 +00:00
|
|
|
priv->sizegroup2 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
2011-05-01 22:02:54 +00:00
|
|
|
priv->frame = label ? katze_hig_frame_new (label) :
|
|
|
|
g_object_new (GTK_TYPE_FRAME, "shadow-type", GTK_SHADOW_NONE, NULL);
|
2009-10-18 20:06:24 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (priv->frame), 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->page), priv->frame, FALSE, FALSE, 0);
|
|
|
|
priv->box = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (priv->box), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->frame), priv->box);
|
|
|
|
gtk_widget_show_all (priv->frame);
|
2009-10-25 14:19:34 +00:00
|
|
|
#endif
|
2009-10-18 20:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* katze_preferences_add_widget:
|
|
|
|
* @preferences: a #KatzePreferences instance
|
|
|
|
* @widget: a widget representing an option
|
|
|
|
* @type: "filled", "indented", or "spanned"
|
|
|
|
*
|
|
|
|
* Adds a widget to the dialog.
|
|
|
|
*
|
|
|
|
* Since: 0.2.1
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
katze_preferences_add_widget (KatzePreferences* preferences,
|
|
|
|
GtkWidget* widget,
|
|
|
|
const gchar* type)
|
|
|
|
{
|
|
|
|
KatzePreferencesPrivate* priv;
|
|
|
|
const gchar* _type;
|
|
|
|
|
|
|
|
g_return_if_fail (KATZE_IS_PREFERENCES (preferences));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
g_return_if_fail (type != NULL);
|
|
|
|
|
|
|
|
priv = preferences->priv;
|
|
|
|
_type = g_intern_string (type);
|
|
|
|
|
|
|
|
/* Showing implicitly widget and children is not the best idea,
|
|
|
|
but lots of repeated function calls aren't either. */
|
|
|
|
gtk_widget_show_all (widget);
|
|
|
|
|
2009-10-28 22:58:32 +00:00
|
|
|
if (!priv->hbox)
|
|
|
|
_type = g_intern_string ("indented");
|
|
|
|
#ifdef HAVE_HILDON_2_2
|
|
|
|
else if (HILDON_IS_CHECK_BUTTON (widget) || HILDON_IS_PICKER_BUTTON (widget))
|
|
|
|
_type = g_intern_string ("indented");
|
|
|
|
#endif
|
2009-10-27 22:47:11 +00:00
|
|
|
|
2009-10-28 22:58:32 +00:00
|
|
|
if (_type != g_intern_static_string ("spanned"))
|
|
|
|
{
|
2009-10-18 20:06:24 +00:00
|
|
|
priv->hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_widget_show (priv->hbox);
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->hbox), widget, TRUE, FALSE, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_type == g_intern_static_string ("filled"))
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->box), priv->hbox, TRUE, FALSE, 0);
|
|
|
|
else if (_type == g_intern_static_string ("indented"))
|
|
|
|
{
|
|
|
|
GtkWidget* align = gtk_alignment_new (0, 0.5, 0, 0);
|
|
|
|
gtk_widget_show (align);
|
|
|
|
gtk_container_add (GTK_CONTAINER (align), priv->hbox);
|
2009-11-22 14:31:53 +00:00
|
|
|
#if HAVE_HILDON
|
|
|
|
if (!GTK_IS_SPIN_BUTTON (widget) && !GTK_IS_LABEL (widget))
|
|
|
|
#else
|
2009-10-18 20:06:24 +00:00
|
|
|
if (!GTK_IS_SPIN_BUTTON (widget))
|
2009-11-22 14:31:53 +00:00
|
|
|
#endif
|
2009-10-18 20:06:24 +00:00
|
|
|
gtk_size_group_add_widget (priv->sizegroup, widget);
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->box), align, TRUE, FALSE, 0);
|
|
|
|
}
|
|
|
|
else if (_type == g_intern_static_string ("spanned"))
|
|
|
|
{
|
|
|
|
GtkWidget* align = gtk_alignment_new (0, 0.5, 0, 0);
|
|
|
|
gtk_widget_show (align);
|
|
|
|
gtk_container_add (GTK_CONTAINER (align), widget);
|
|
|
|
if (!GTK_IS_LABEL (widget) && !GTK_IS_SPIN_BUTTON (widget)
|
|
|
|
&& !(GTK_IS_BUTTON (widget) && !GTK_IS_TOGGLE_BUTTON (widget)))
|
|
|
|
gtk_size_group_add_widget (priv->sizegroup2, widget);
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->hbox), align, TRUE, FALSE, 0);
|
|
|
|
}
|
2009-10-25 14:19:34 +00:00
|
|
|
|
|
|
|
#if HAVE_HILDON
|
|
|
|
if (GTK_IS_BUTTON (widget) && !GTK_WIDGET_IS_SENSITIVE (widget))
|
|
|
|
gtk_widget_hide (widget);
|
|
|
|
#endif
|
2009-10-18 20:06:24 +00:00
|
|
|
}
|