Commit a52bf479 authored by Ramiro Estrugo's avatar Ramiro Estrugo

New type of preference, EDITABLE_STRING.

* nautilus-widgets/nautilus-preferences-item.c:
(preferences_item_construct),
(preferences_item_create_editable_string),
(preferences_item_create_font_family),
(preferences_item_create_icon_theme),
(preferences_item_create_toolbar_icon_theme),
(text_item_changed_callback), (editable_string_changed_callback):
* nautilus-widgets/nautilus-preferences-item.h:
New type of preference, EDITABLE_STRING.

* libnautilus-extensions/nautilus-global-preferences.c:
(global_preferences_create_dialog):
Add a new pane, navigation pane.

Add support for manually keying in a home page.  Needs some more
work to work better.

* nautilus-widgets/Makefile.am:
* nautilus-widgets/nautilus-caption.c:
(nautilus_caption_initialize_class), (nautilus_caption_initialize),
(nautilus_caption_destroy), (nautilus_caption_new),
(nautilus_caption_set_title_label),
(nautilus_caption_get_title_label), (nautilus_caption_set_child):
* nautilus-widgets/nautilus-caption.h:
New class.  Common stuff for caption widgets.

* nautilus-widgets/nautilus-string-picker.c:
(nautilus_string_picker_initialize_class),
(nautilus_string_picker_initialize), (entry_changed_callback),
(nautilus_string_picker_set_string_list):
* nautilus-widgets/nautilus-string-picker.h:
Subclass from caption class.

* nautilus-widgets/nautilus-text-caption.h:
* nautilus-widgets/nautilus-text-caption.c:
(nautilus_text_caption_initialize_class),
(nautilus_text_caption_initialize),
(nautilus_text_caption_destroy), (entry_changed_callback),
(nautilus_text_caption_new), (nautilus_text_caption_get_text),
(nautilus_text_caption_set_text):
New caption sublcass that manages an text widget.

* nautilus-widgets/test-nautilus-widgets.c: (main),
(test_string_picker), (test_text_caption),
(string_picker_changed_callback), (text_caption_changed_callback):
Update for new class and caption changes.
parent a3a7ab42
2000-06-05 Ramiro Estrugo <ramiro@eazel.com>
* nautilus-widgets/nautilus-preferences-item.c:
(preferences_item_construct),
(preferences_item_create_editable_string),
(preferences_item_create_font_family),
(preferences_item_create_icon_theme),
(preferences_item_create_toolbar_icon_theme),
(text_item_changed_callback), (editable_string_changed_callback):
* nautilus-widgets/nautilus-preferences-item.h:
New type of preference, EDITABLE_STRING.
* libnautilus-extensions/nautilus-global-preferences.c:
(global_preferences_create_dialog):
Add a new pane, navigation pane.
Add support for manually keying in a home page. Needs some more
work to work better.
* nautilus-widgets/Makefile.am:
* nautilus-widgets/nautilus-caption.c:
(nautilus_caption_initialize_class), (nautilus_caption_initialize),
(nautilus_caption_destroy), (nautilus_caption_new),
(nautilus_caption_set_title_label),
(nautilus_caption_get_title_label), (nautilus_caption_set_child):
* nautilus-widgets/nautilus-caption.h:
New class. Common stuff for caption widgets.
* nautilus-widgets/nautilus-string-picker.c:
(nautilus_string_picker_initialize_class),
(nautilus_string_picker_initialize), (entry_changed_callback),
(nautilus_string_picker_set_string_list):
* nautilus-widgets/nautilus-string-picker.h:
Subclass from caption class.
* nautilus-widgets/nautilus-text-caption.h:
* nautilus-widgets/nautilus-text-caption.c:
(nautilus_text_caption_initialize_class),
(nautilus_text_caption_initialize),
(nautilus_text_caption_destroy), (entry_changed_callback),
(nautilus_text_caption_new), (nautilus_text_caption_get_text),
(nautilus_text_caption_set_text):
New caption sublcass that manages an text widget.
* nautilus-widgets/test-nautilus-widgets.c: (main),
(test_string_picker), (test_text_caption),
(string_picker_changed_callback), (text_caption_changed_callback):
Update for new class and caption changes.
2000-06-05 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus-extensions/nautilus-icon-factory.c: (embed_text):
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-caption.c - A captioned text widget
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 <ramiro@eazel.com>
*/
#include <config.h>
#include "nautilus-caption.h"
#include <libnautilus-extensions/nautilus-gtk-macros.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkentry.h>
static const gint CAPTION_INVALID = -1;
static const gint CAPTION_SPACING = 10;
struct _NautilusCaptionDetail
{
GtkWidget *title_label;
GtkWidget *child;
};
/* NautilusCaptionClass methods */
static void nautilus_caption_initialize_class (NautilusCaptionClass *klass);
static void nautilus_caption_initialize (NautilusCaption *caption);
/* GtkObjectClass methods */
static void nautilus_caption_destroy (GtkObject *object);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusCaption, nautilus_caption, GTK_TYPE_HBOX)
/*
* NautilusCaptionClass methods
*/
static void
nautilus_caption_initialize_class (NautilusCaptionClass *caption_class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = GTK_OBJECT_CLASS (caption_class);
widget_class = GTK_WIDGET_CLASS (caption_class);
/* GtkObjectClass */
object_class->destroy = nautilus_caption_destroy;
}
static void
nautilus_caption_initialize (NautilusCaption *caption)
{
caption->detail = g_new (NautilusCaptionDetail, 1);
gtk_box_set_homogeneous (GTK_BOX (caption), FALSE);
gtk_box_set_spacing (GTK_BOX (caption), CAPTION_SPACING);
caption->detail->title_label = gtk_label_new ("Title Label:");
caption->detail->child = NULL;
gtk_box_pack_start (GTK_BOX (caption),
caption->detail->title_label,
FALSE, /* expand */
TRUE, /* fill */
0); /* padding */
gtk_widget_show (caption->detail->title_label);
}
/*
* GtkObjectClass methods
*/
static void
nautilus_caption_destroy (GtkObject* object)
{
NautilusCaption * caption;
g_return_if_fail (object != NULL);
g_return_if_fail (NAUTILUS_IS_CAPTION (object));
caption = NAUTILUS_CAPTION (object);
g_free (caption->detail);
/* Chain */
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
/*
* NautilusCaption public methods
*/
GtkWidget*
nautilus_caption_new (void)
{
NautilusCaption *caption;
caption = gtk_type_new (nautilus_caption_get_type ());
return GTK_WIDGET (caption);
}
/**
* nautilus_caption_set_title_label:
* @caption: A NautilusCaption
* @title_label: The title label
*
*/
void
nautilus_caption_set_title_label (NautilusCaption *caption,
const char *title_label)
{
g_return_if_fail (caption != NULL);
g_return_if_fail (NAUTILUS_IS_CAPTION (caption));
g_return_if_fail (title_label != NULL);
gtk_label_set_text (GTK_LABEL (caption->detail->title_label), title_label);
}
/**
* nautilus_caption_get_title_label:
* @caption: A NautilusCaption
*
* Returns: A newly allocated copy of the title label.
*/
char *
nautilus_caption_get_title_label (const NautilusCaption *caption)
{
gchar *str;
g_return_val_if_fail (caption != NULL, NULL);
g_return_val_if_fail (NAUTILUS_IS_CAPTION (caption), NULL);
/* DANGER! DANGER!
*
* gtk_label_get () does not strdup the result.
*/
gtk_label_get (GTK_LABEL (caption->detail->title_label), &str);
return str ? g_strdup (str) : NULL;
}
/**
* nautilus_caption_get_title_label:
* @caption: A NautilusCaption
*
* Returns: A newly allocated copy of the title label.
*/
void
nautilus_caption_set_child (NautilusCaption *caption,
GtkWidget *child)
{
g_return_if_fail (caption != NULL);
g_return_if_fail (NAUTILUS_IS_CAPTION (caption));
g_return_if_fail (child != NULL);
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (caption->detail->child == NULL);
caption->detail->child = child;
gtk_box_pack_end (GTK_BOX (caption),
caption->detail->child,
TRUE, /* expand */
TRUE, /* fill */
0); /* padding */
gtk_widget_show (caption->detail->child);
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-caption.h - A captioned text widget
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 <ramiro@eazel.com>
*/
#ifndef NAUTILUS_CAPTION_H
#define NAUTILUS_CAPTION_H
#include <gtk/gtkvbox.h>
#include <gnome.h>
#include <libnautilus-extensions/nautilus-string-list.h>
/*
* NautilusCaption is made up of 2 widgets.
*
* [title label] [something]
*
*/
BEGIN_GNOME_DECLS
#define NAUTILUS_TYPE_CAPTION (nautilus_caption_get_type ())
#define NAUTILUS_CAPTION(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_CAPTION, NautilusCaption))
#define NAUTILUS_CAPTION_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_CAPTION, NautilusCaptionClass))
#define NAUTILUS_IS_CAPTION(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_CAPTION))
typedef struct _NautilusCaption NautilusCaption;
typedef struct _NautilusCaptionClass NautilusCaptionClass;
typedef struct _NautilusCaptionDetail NautilusCaptionDetail;
struct _NautilusCaption
{
/* Super Class */
GtkHBox hbox;
/* Private stuff */
NautilusCaptionDetail *detail;
};
struct _NautilusCaptionClass
{
GtkHBoxClass parent_class;
};
GtkType nautilus_caption_get_type (void);
GtkWidget* nautilus_caption_new (void);
/* Title label mutator. */
void nautilus_caption_set_title_label (NautilusCaption *caption,
const char *title_label);
/* Title label accessor. */
char *nautilus_caption_get_title_label (const NautilusCaption *caption);
/* Set the child. */
void nautilus_caption_set_child (NautilusCaption *caption,
GtkWidget *child);
BEGIN_GNOME_DECLS
#endif /* NAUTILUS_CAPTION_H */
......@@ -86,6 +86,7 @@ global_preferences_create_dialog (void)
GtkWidget *sidebar_panels_pane;
GtkWidget *appearance_pane;
GtkWidget *tradeoffs_pane;
GtkWidget *navigation_pane;
/*
* In the soon to come star trek future, the following widgetry
......@@ -215,8 +216,23 @@ global_preferences_create_dialog (void)
0,
NAUTILUS_PREFERENCES_SHOW_TEXT_IN_REMOTE_ICONS,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
/* all done */
/*
* Tradeoffs
*/
navigation_pane = nautilus_preferences_box_add_pane (preference_box,
"Navigation",
"Navigation Settings");
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), "Home Location");
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
0,
NAUTILUS_PREFERENCES_HOME_URI,
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING);
/* all done */
return prefs_dialog;
}
......
......@@ -32,8 +32,9 @@
#include <gtk/gtkcheckbutton.h>
#include <nautilus-widgets/nautilus-radio-button-group.h>
#include <nautilus-widgets/nautilus-string-picker.h>
#include "nautilus-radio-button-group.h"
#include "nautilus-string-picker.h"
#include "nautilus-text-caption.h"
/* Arguments */
enum
......@@ -83,6 +84,8 @@ static void preferences_item_create_enum (NautilusPreferencesItem
const NautilusPreference *prefrence);
static void preferences_item_create_boolean (NautilusPreferencesItem *item,
const NautilusPreference *prefrence);
static void preferences_item_create_editable_string (NautilusPreferencesItem *item,
const NautilusPreference *prefrence);
static void preferences_item_create_font_family (NautilusPreferencesItem *item,
const NautilusPreference *prefrence);
static void preferences_item_create_icon_theme (NautilusPreferencesItem *item,
......@@ -96,6 +99,8 @@ static void boolean_button_toggled_callback (GtkWidget
gpointer user_data);
static void text_item_changed_callback (GtkWidget *string_picker,
gpointer user_data);
static void editable_string_changed_callback (GtkWidget *caption,
gpointer user_data);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferencesItem, nautilus_preferences_item, GTK_TYPE_VBOX)
......@@ -277,11 +282,13 @@ preferences_item_construct (NautilusPreferencesItem *item,
case NAUTILUS_PREFERENCE_ITEM_ICON_THEME:
preferences_item_create_icon_theme (item, preference);
break;
case NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING:
preferences_item_create_editable_string (item, preference);
break;
case NAUTILUS_PREFERENCE_ITEM_TOOLBAR_ICON_THEME:
preferences_item_create_toolbar_icon_theme (item, preference);
break;
}
gtk_object_unref (GTK_OBJECT (preference));
......@@ -366,6 +373,38 @@ preferences_item_create_boolean (NautilusPreferencesItem *item,
(gpointer) item);
}
static void
preferences_item_create_editable_string (NautilusPreferencesItem *item,
const NautilusPreference *preference)
{
char *current_value;
char *description;
g_assert (item != NULL);
g_assert (preference != NULL);
g_assert (item->details->preference_name != NULL);
description = nautilus_preference_get_description (preference);
g_assert (description != NULL);
item->details->child = nautilus_text_caption_new ();
nautilus_caption_set_title_label (NAUTILUS_CAPTION (item->details->child), description);
g_free (description);
current_value = nautilus_preferences_get (item->details->preference_name, "file://home/pavel");
g_assert (current_value != NULL);
nautilus_text_caption_set_text (NAUTILUS_TEXT_CAPTION (item->details->child), current_value);
gtk_signal_connect (GTK_OBJECT (item->details->child),
"changed",
GTK_SIGNAL_FUNC (editable_string_changed_callback),
(gpointer) item);
}
static void
preferences_item_create_font_family (NautilusPreferencesItem *item,
const NautilusPreference *preference)
......@@ -384,7 +423,7 @@ preferences_item_create_font_family (NautilusPreferencesItem *item,
item->details->child = nautilus_string_picker_new ();
nautilus_string_picker_set_title_label (NAUTILUS_STRING_PICKER (item->details->child), description);
nautilus_caption_set_title_label (NAUTILUS_CAPTION (item->details->child), description);
g_free (description);
......@@ -508,7 +547,7 @@ preferences_item_create_icon_theme (NautilusPreferencesItem *item,
item->details->child = nautilus_string_picker_new ();
nautilus_string_picker_set_title_label (NAUTILUS_STRING_PICKER (item->details->child), description);
nautilus_caption_set_title_label (NAUTILUS_CAPTION (item->details->child), description);
g_free (description);
......@@ -554,7 +593,7 @@ preferences_item_create_toolbar_icon_theme (NautilusPreferencesItem *item,
item->details->child = nautilus_string_picker_new ();
nautilus_string_picker_set_title_label (NAUTILUS_STRING_PICKER (item->details->child), description);
nautilus_caption_set_title_label (NAUTILUS_CAPTION (item->details->child), description);
g_free (description);
......@@ -661,3 +700,26 @@ text_item_changed_callback (GtkWidget *button, gpointer user_data)
g_free (text);
}
}
static void
editable_string_changed_callback (GtkWidget *button, gpointer user_data)
{
NautilusPreferencesItem *item;
char *text;
g_assert (user_data != NULL);
g_assert (NAUTILUS_IS_PREFERENCES_ITEM (user_data));
item = NAUTILUS_PREFERENCES_ITEM (user_data);
g_assert (item->details->child != NULL);
g_assert (NAUTILUS_IS_TEXT_CAPTION (item->details->child));
text = nautilus_text_caption_get_text (NAUTILUS_TEXT_CAPTION (item->details->child));
if (text != NULL)
{
nautilus_preferences_set (item->details->preference_name, text);
g_free (text);
}
}
......@@ -67,8 +67,9 @@ typedef enum
NAUTILUS_PREFERENCE_ITEM_BOOLEAN,
NAUTILUS_PREFERENCE_ITEM_ENUM,
NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY,
NAUTILUS_PREFERENCE_ITEM_TOOLBAR_ICON_THEME,
NAUTILUS_PREFERENCE_ITEM_ICON_THEME
NAUTILUS_PREFERENCE_ITEM_ICON_THEME,
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING,
NAUTILUS_PREFERENCE_ITEM_TOOLBAR_ICON_THEME
} NautilusPreferencesItemType;
GtkType nautilus_preferences_item_get_type (void);
......
......@@ -41,11 +41,11 @@ typedef enum
{
CHANGED,
LAST_SIGNAL
} RadioGroupSignals;
} NautilusStringPickerSignals;
struct _NautilusStringPickerDetail
{
GtkWidget *title_label;
// GtkWidget *title_label;
GtkWidget *combo_box;
NautilusStringList *string_list;
};
......@@ -64,7 +64,7 @@ static GtkEntry *string_picker_get_entry_widget (NautilusStringPicker
static void entry_changed_callback (GtkWidget *entry,
gpointer user_data);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusStringPicker, nautilus_string_picker, GTK_TYPE_HBOX)
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusStringPicker, nautilus_string_picker, NAUTILUS_TYPE_CAPTION)
static guint string_picker_signals[LAST_SIGNAL] = { 0 };
......@@ -80,11 +80,9 @@ nautilus_string_picker_initialize_class (NautilusStringPickerClass *string_picke
object_class = GTK_OBJECT_CLASS (string_picker_class);
widget_class = GTK_WIDGET_CLASS (string_picker_class);
parent_class = gtk_type_class (gtk_hbox_get_type ());
/* GtkObjectClass */
object_class->destroy = nautilus_string_picker_destroy;
/* Signals */
string_picker_signals[CHANGED] =
gtk_signal_new ("changed",
......@@ -108,29 +106,32 @@ nautilus_string_picker_initialize (NautilusStringPicker *string_picker)
string_picker->detail->string_list = NULL;
string_picker->detail->title_label = gtk_label_new ("Title Label:");
// string_picker->detail->title_label = gtk_label_new ("Title Label:");
string_picker->detail->combo_box = gtk_combo_new ();
gtk_entry_set_editable (string_picker_get_entry_widget (string_picker), FALSE);
gtk_box_pack_start (GTK_BOX (string_picker),
string_picker->detail->title_label,
FALSE, /* expand */
TRUE, /* fill */
0); /* padding */
// gtk_box_pack_start (GTK_BOX (string_picker),
// string_picker->detail->title_label,
// FALSE, /* expand */
// TRUE, /* fill */
// 0); /* padding */
gtk_box_pack_end (GTK_BOX (string_picker),
string_picker->detail->combo_box,
TRUE, /* expand */
TRUE, /* fill */
0); /* padding */
// gtk_box_pack_end (GTK_BOX (string_picker),
// string_picker->detail->combo_box,
// TRUE, /* expand */
// TRUE, /* fill */
// 0); /* padding */
nautilus_caption_set_child (NAUTILUS_CAPTION (string_picker),
string_picker->detail->combo_box);
gtk_signal_connect (GTK_OBJECT (string_picker_get_entry_widget (string_picker)),
"changed",
GTK_SIGNAL_FUNC (entry_changed_callback),
(gpointer) string_picker);
gtk_widget_show (string_picker->detail->title_label);
gtk_widget_show (string_picker->detail->combo_box);
}
......@@ -175,8 +176,6 @@ string_picker_get_entry_widget (NautilusStringPicker *string_picker)
static void
entry_changed_callback (GtkWidget *entry, gpointer user_data)
{
const char *entry_text;
NautilusStringPicker *string_picker;
g_assert (user_data != NULL);
......@@ -184,12 +183,6 @@ entry_changed_callback (GtkWidget *entry, gpointer user_data)
string_picker = NAUTILUS_STRING_PICKER (user_data);
/* WATCHOUT:
* As of gtk1.2, gtk_entry_get_text() returns a non const reference to
* the internal string.
*/
entry_text = (const char *) gtk_entry_get_text (string_picker_get_entry_widget (string_picker));
gtk_signal_emit (GTK_OBJECT (string_picker), string_picker_signals[CHANGED]);
}
......@@ -230,23 +223,6 @@ nautilus_string_picker_set_string_list (NautilusStringPicker *string_picker,
nautilus_g_list_free_deep (strings);
}
/**
* nautilus_string_picker_set_title_label:
* @string_picker: A NautilusStringPicker
* @title_label: The title label
*
*/
void
nautilus_string_picker_set_title_label (NautilusStringPicker *string_picker,
const char *title_label)
{
g_return_if_fail (string_picker != NULL);
g_return_if_fail (NAUTILUS_IS_STRING_PICKER (string_picker));
g_return_if_fail (title_label != NULL);
gtk_label_set_text (GTK_LABEL (string_picker->detail->title_label), title_label);
}
/**
* nautilus_string_picker_get_text
* @string_picker: A NautilusStringPicker
......
......@@ -25,8 +25,7 @@
#ifndef NAUTILUS_STRING_PICKER_H
#define NAUTILUS_STRING_PICKER_H
#include <gtk/gtkvbox.h>
#include <gnome.h>
#include <nautilus-widgets/nautilus-caption.h>
#include <libnautilus-extensions/nautilus-string-list.h>