mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-11-05 16:04:31 +00:00
Moved widgets and preferences test to nautilus/test.
* libnautilus-extensions/test-nautilus-preferences.c: * libnautilus-extensions/test-nautilus-widgets.c: * libnautilus-extensions/test-preferences.c: Moved widgets and preferences test to nautilus/test. * test/.cvsignore: * test/Makefile.am: * test/test-nautilus-preferences.c: (main), (test_preferences_item), (test_preferences_group), (create_enum_item), (register_global_preferences): * test/test-nautilus-widgets.c: (main), (test_radio_group), (test_caption_table), (test_string_picker), (test_text_caption), (test_authenticate_boink_callback), (string_picker_changed_callback), (text_caption_changed_callback), (test_password_dialog), (test_radio_changed_callback), (test_caption_table_activate_callback): Ressurect my widgets/preferences test over here. They got whacked in the nautilus-widgets -> libnautilus-extensions renamings.
This commit is contained in:
parent
5ed6ea8af7
commit
a356df0de7
10 changed files with 73 additions and 871 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
2000-07-05 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
* libnautilus-extensions/test-nautilus-preferences.c:
|
||||
* libnautilus-extensions/test-nautilus-widgets.c:
|
||||
* libnautilus-extensions/test-preferences.c:
|
||||
Moved widgets and preferences test to nautilus/test.
|
||||
|
||||
* test/.cvsignore:
|
||||
* test/Makefile.am:
|
||||
* test/test-nautilus-preferences.c: (main),
|
||||
(test_preferences_item), (test_preferences_group),
|
||||
(create_enum_item), (register_global_preferences):
|
||||
* test/test-nautilus-widgets.c: (main), (test_radio_group),
|
||||
(test_caption_table), (test_string_picker), (test_text_caption),
|
||||
(test_authenticate_boink_callback),
|
||||
(string_picker_changed_callback), (text_caption_changed_callback),
|
||||
(test_password_dialog), (test_radio_changed_callback),
|
||||
(test_caption_table_activate_callback):
|
||||
Ressurect my widgets/preferences test over here. They got whacked
|
||||
in the nautilus-widgets -> libnautilus-extensions renamings.
|
||||
|
||||
2000-07-05 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
* libnautilus-extensions/nautilus-directory.c:
|
||||
|
|
|
@ -1,281 +0,0 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include "nautilus-caption-table.h"
|
||||
#include "nautilus-password-dialog.h"
|
||||
#include "nautilus-radio-button-group.h"
|
||||
#include "nautilus-string-picker.h"
|
||||
#include "nautilus-text-caption.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void test_radio_group (void);
|
||||
static void test_caption_table (void);
|
||||
static void test_password_dialog (void);
|
||||
static void test_string_picker (void);
|
||||
static void test_text_caption (void);
|
||||
|
||||
/* Callbacks */
|
||||
static void test_radio_changed_callback (GtkWidget *button_group,
|
||||
gpointer user_data);
|
||||
static void test_authenticate_boink_callback (GtkWidget *button,
|
||||
gpointer user_data);
|
||||
static void string_picker_changed_callback (GtkWidget *string_picker,
|
||||
gpointer user_data);
|
||||
static void text_caption_changed_callback (GtkWidget *text_caption,
|
||||
gpointer user_data);
|
||||
static void test_caption_table_activate_callback (GtkWidget *button_group,
|
||||
gint active_index,
|
||||
gpointer user_data);
|
||||
|
||||
int
|
||||
main (int argc, char * argv[])
|
||||
{
|
||||
gnome_init ("foo", "bar", argc, argv);
|
||||
|
||||
test_radio_group ();
|
||||
test_caption_table ();
|
||||
test_password_dialog ();
|
||||
test_string_picker ();
|
||||
test_text_caption ();
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
test_radio_group (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * buttons;
|
||||
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
buttons = nautilus_radio_button_group_new ();
|
||||
|
||||
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Apples");
|
||||
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Oranges");
|
||||
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Strawberries");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (buttons),
|
||||
"changed",
|
||||
GTK_SIGNAL_FUNC (test_radio_changed_callback),
|
||||
(gpointer) NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), buttons);
|
||||
|
||||
gtk_widget_show (buttons);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_caption_table (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * table;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
table = nautilus_caption_table_new (4);
|
||||
|
||||
nautilus_caption_table_set_row_info (NAUTILUS_CAPTION_TABLE (table),
|
||||
0,
|
||||
"Something",
|
||||
"Text",
|
||||
TRUE,
|
||||
FALSE);
|
||||
|
||||
nautilus_caption_table_set_row_info (NAUTILUS_CAPTION_TABLE (table),
|
||||
1,
|
||||
"ReadOnly",
|
||||
"Cant Change Me",
|
||||
TRUE,
|
||||
TRUE);
|
||||
|
||||
nautilus_caption_table_set_row_info (NAUTILUS_CAPTION_TABLE (table),
|
||||
2,
|
||||
"Password",
|
||||
"sekret",
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
nautilus_caption_table_set_row_info (NAUTILUS_CAPTION_TABLE (table),
|
||||
3,
|
||||
"This is a very long label",
|
||||
"Text",
|
||||
TRUE,
|
||||
FALSE);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (table),
|
||||
"activate",
|
||||
GTK_SIGNAL_FUNC (test_caption_table_activate_callback),
|
||||
(gpointer) NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), table);
|
||||
|
||||
gtk_widget_show (table);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_string_picker (void)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *picker;
|
||||
NautilusStringList *font_list;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
picker = nautilus_string_picker_new ();
|
||||
|
||||
nautilus_caption_set_title_label (NAUTILUS_CAPTION (picker), "Icon Font Family:");
|
||||
|
||||
font_list = nautilus_string_list_new ();
|
||||
|
||||
nautilus_string_list_insert (font_list, "Helvetica");
|
||||
nautilus_string_list_insert (font_list, "Times");
|
||||
nautilus_string_list_insert (font_list, "Courier");
|
||||
nautilus_string_list_insert (font_list, "Lucida");
|
||||
nautilus_string_list_insert (font_list, "Fixed");
|
||||
|
||||
nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (picker), font_list);
|
||||
|
||||
nautilus_string_list_free (font_list);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), picker);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (picker),
|
||||
"changed",
|
||||
GTK_SIGNAL_FUNC (string_picker_changed_callback),
|
||||
(gpointer) NULL);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_text_caption (void)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *picker;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
picker = nautilus_text_caption_new ();
|
||||
|
||||
nautilus_caption_set_title_label (NAUTILUS_CAPTION (picker), "Home Page:");
|
||||
|
||||
nautilus_text_caption_set_text (NAUTILUS_TEXT_CAPTION (picker), "file:///tmp");
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), picker);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (picker),
|
||||
"changed",
|
||||
GTK_SIGNAL_FUNC (text_caption_changed_callback),
|
||||
(gpointer) NULL);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_authenticate_boink_callback (GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
gboolean rv;
|
||||
char *username;
|
||||
char *password;
|
||||
|
||||
dialog = nautilus_password_dialog_new ("Authenticate Me",
|
||||
"foouser",
|
||||
"sekret",
|
||||
FALSE);
|
||||
|
||||
rv = nautilus_password_dialog_run_and_block (NAUTILUS_PASSWORD_DIALOG (dialog));
|
||||
|
||||
username = nautilus_password_dialog_get_username (NAUTILUS_PASSWORD_DIALOG (dialog));
|
||||
password = nautilus_password_dialog_get_password (NAUTILUS_PASSWORD_DIALOG (dialog));
|
||||
|
||||
g_assert (username != NULL);
|
||||
g_assert (password != NULL);
|
||||
|
||||
g_print ("test_authenticate_boink_callback (rv=%d , username='%s' , password='%s')\n",
|
||||
rv,
|
||||
username,
|
||||
password);
|
||||
|
||||
g_free (username);
|
||||
g_free (password);
|
||||
}
|
||||
|
||||
static void
|
||||
string_picker_changed_callback (GtkWidget *string_picker, gpointer user_data)
|
||||
{
|
||||
char *text;
|
||||
|
||||
g_assert (string_picker != NULL);
|
||||
g_assert (NAUTILUS_IS_STRING_PICKER (string_picker));
|
||||
|
||||
text = nautilus_string_picker_get_text (NAUTILUS_STRING_PICKER (string_picker));
|
||||
|
||||
g_print ("string_picker_changed_callback(%s)\n", text);
|
||||
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
text_caption_changed_callback (GtkWidget *text_caption, gpointer user_data)
|
||||
{
|
||||
char *text;
|
||||
|
||||
g_assert (text_caption != NULL);
|
||||
g_assert (NAUTILUS_IS_TEXT_CAPTION (text_caption));
|
||||
|
||||
text = nautilus_text_caption_get_text (NAUTILUS_TEXT_CAPTION (text_caption));
|
||||
|
||||
g_print ("text_caption_changed_callback(%s)\n", text);
|
||||
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
test_password_dialog (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * button;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
button = gtk_button_new_with_label ("Boink me to authenticate");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button),
|
||||
"clicked",
|
||||
GTK_SIGNAL_FUNC (test_authenticate_boink_callback),
|
||||
(gpointer) NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), button);
|
||||
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_radio_changed_callback (GtkWidget *buttons, gpointer user_data)
|
||||
{
|
||||
gint i;
|
||||
|
||||
i = nautilus_radio_button_group_get_active_index (NAUTILUS_RADIO_BUTTON_GROUP (buttons));
|
||||
|
||||
g_print ("test_radio_changed_callback (%d)\n", i);
|
||||
}
|
||||
|
||||
static void
|
||||
test_caption_table_activate_callback (GtkWidget *button_group,
|
||||
gint active_index,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_print ("test_caption_table_activate_callback (active_index=%d)\n", active_index);
|
||||
}
|
|
@ -1,227 +0,0 @@
|
|||
|
||||
#include <config.h>
|
||||
#include "nautilus-radio-button-group.h"
|
||||
#include "nautilus-preferences-group.h"
|
||||
#include "nautilus-preferences-item.h"
|
||||
#include "nautilus-preferences.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static void test_radio_group (void);
|
||||
static void test_preferences_group (void);
|
||||
static void test_preferences_item (void);
|
||||
|
||||
|
||||
static void test_radio_changed_signal (GtkWidget *button_group, gpointer user_data);
|
||||
|
||||
static GtkObject *
|
||||
create_dummy_prefs (void);
|
||||
|
||||
GtkWidget *
|
||||
create_enum_item (void);
|
||||
|
||||
GtkWidget *
|
||||
create_bool_item (void);
|
||||
|
||||
static GtkObject * dummy_prefs = NULL;
|
||||
|
||||
int
|
||||
main (int argc, char * argv[])
|
||||
{
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
dummy_prefs = create_dummy_prefs ();
|
||||
|
||||
test_preferences_group ();
|
||||
test_preferences_item ();
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
test_radio_group (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * buttons;
|
||||
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
buttons = nautilus_radio_button_group_new ();
|
||||
|
||||
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Apples");
|
||||
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Oranges");
|
||||
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Strawberries");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (buttons),
|
||||
"changed",
|
||||
GTK_SIGNAL_FUNC (test_radio_changed_signal),
|
||||
(gpointer) NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), buttons);
|
||||
|
||||
gtk_widget_show (buttons);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_preferences_item (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * item;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
item = create_enum_item ();
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), item);
|
||||
|
||||
gtk_widget_show (item);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_preferences_group (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * group;
|
||||
|
||||
GtkWidget * item;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
group = nautilus_preferences_group_new ("A group");
|
||||
|
||||
item = create_enum_item ();
|
||||
|
||||
nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group),
|
||||
item);
|
||||
|
||||
gtk_widget_show (item);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), group);
|
||||
|
||||
gtk_widget_show (group);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_radio_changed_signal (GtkWidget *buttons, gpointer user_data)
|
||||
{
|
||||
gint i;
|
||||
|
||||
i = nautilus_radio_button_group_get_active_index (NAUTILUS_RADIO_BUTTON_GROUP (buttons));
|
||||
|
||||
printf ("test_radio_changed_signal (%d)\n", i);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
create_enum_item (void)
|
||||
{
|
||||
GtkWidget * item;
|
||||
|
||||
item = nautilus_preferences_item_new (dummy_prefs,
|
||||
"user_level",
|
||||
NAUTILUS_PREFERENCES_ITEM_ENUM);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
create_bool_item (void)
|
||||
{
|
||||
GtkWidget * item;
|
||||
|
||||
item = nautilus_preferences_item_new (dummy_prefs,
|
||||
"foo",
|
||||
NAUTILUS_PREFERENCES_ITEM_BOOL);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
static const gchar * prefs_global_user_level_names[] =
|
||||
{
|
||||
"novice",
|
||||
"intermediate",
|
||||
"hacker",
|
||||
"ettore"
|
||||
};
|
||||
|
||||
static const gchar * prefs_global_user_level_descriptions[] =
|
||||
{
|
||||
"Novice",
|
||||
"Intermediate",
|
||||
"Hacker",
|
||||
"Ettore"
|
||||
};
|
||||
|
||||
static const gint prefs_global_user_level_values[] =
|
||||
{
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3
|
||||
};
|
||||
|
||||
static NautilusPrefEnumData prefs_global_user_level_data =
|
||||
{
|
||||
prefs_global_user_level_names,
|
||||
prefs_global_user_level_descriptions,
|
||||
prefs_global_user_level_values,
|
||||
4
|
||||
};
|
||||
|
||||
static NautilusPrefInfo prefs_global_static_pref_info[] =
|
||||
{
|
||||
{
|
||||
"user_level",
|
||||
"User Level",
|
||||
GTK_TYPE_ENUM,
|
||||
FALSE,
|
||||
&prefs_global_user_level_data
|
||||
},
|
||||
{
|
||||
"foo",
|
||||
"Create new window for each new page",
|
||||
GTK_TYPE_BOOL,
|
||||
FALSE,
|
||||
NULL
|
||||
},
|
||||
{
|
||||
"bar",
|
||||
"Do not open more than one window with the same page",
|
||||
GTK_TYPE_BOOL,
|
||||
FALSE,
|
||||
NULL
|
||||
},
|
||||
};
|
||||
|
||||
static GtkObject *
|
||||
create_dummy_prefs (void)
|
||||
{
|
||||
GtkObject * dummy_prefs;
|
||||
guint i;
|
||||
|
||||
dummy_prefs = nautilus_preferences_new ("dummy");
|
||||
|
||||
/* Register the static prefs */
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
nautilus_preferences_register_from_info (NAUTILUS_PREFS (dummy_prefs),
|
||||
&prefs_global_static_pref_info[i]);
|
||||
}
|
||||
|
||||
|
||||
nautilus_preferences_set_enum (NAUTILUS_PREFS (dummy_prefs),
|
||||
"user_level",
|
||||
2);
|
||||
|
||||
return dummy_prefs;
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
|
||||
#include <config.h>
|
||||
#include "nautilus-radio-button-group.h"
|
||||
#include "nautilus-caption-table.h"
|
||||
#include "nautilus-password-dialog.h"
|
||||
#include "nautilus-preferences-group.h"
|
||||
#include "nautilus-preferences-item.h"
|
||||
#include "nautilus-preferences.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void test_preferences_group (void);
|
||||
static void test_preferences_item (void);
|
||||
static void register_global_preferences (void);
|
||||
GtkWidget * create_enum_item (const char *preference_name);
|
||||
GtkWidget * create_bool_item (const char *preference_name);
|
||||
|
||||
enum
|
||||
{
|
||||
FRUIT_APPLE,
|
||||
FRUIT_ORANGE,
|
||||
FRUIT_BANNANA
|
||||
};
|
||||
|
||||
static const char FRUIT_PREFERENCE[] = "/a/very/fruity/path";
|
||||
|
||||
int
|
||||
main (int argc, char * argv[])
|
||||
{
|
||||
gnome_init ("foo", "bar", argc, argv);
|
||||
|
||||
register_global_preferences ();
|
||||
|
||||
test_preferences_group ();
|
||||
test_preferences_item ();
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
test_preferences_item (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * item;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
item = create_enum_item (FRUIT_PREFERENCE);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), item);
|
||||
|
||||
gtk_widget_show (item);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_preferences_group (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * group;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
group = nautilus_preferences_group_new ("A group");
|
||||
|
||||
nautilus_preferences_group_add_item (NAUTILUS_PREFERENCES_GROUP (group),
|
||||
FRUIT_PREFERENCE,
|
||||
NAUTILUS_PREFERENCE_ITEM_ENUM);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), group);
|
||||
|
||||
gtk_widget_show (group);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
create_enum_item (const char *preference_name)
|
||||
{
|
||||
return nautilus_preferences_item_new (preference_name, NAUTILUS_PREFERENCE_ITEM_ENUM);
|
||||
}
|
||||
|
||||
// GtkWidget *
|
||||
// create_bool_item (const char *preference_name)
|
||||
// {
|
||||
// return nautilus_preferences_item_new (global_preferences,
|
||||
// preference_name,
|
||||
// NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
|
||||
// }
|
||||
|
||||
static void
|
||||
register_global_preferences (void)
|
||||
{
|
||||
gconstpointer default_values[3] = { (gconstpointer)FRUIT_ORANGE, (gconstpointer)FRUIT_ORANGE, (gconstpointer)FRUIT_ORANGE };
|
||||
|
||||
nautilus_preference_set_info_by_name (FRUIT_PREFERENCE,
|
||||
"Fruits",
|
||||
NAUTILUS_PREFERENCE_ENUM,
|
||||
default_values,
|
||||
3);
|
||||
|
||||
nautilus_preference_enum_add_entry_by_name (FRUIT_PREFERENCE,
|
||||
"apple",
|
||||
"Apple",
|
||||
FRUIT_APPLE);
|
||||
|
||||
nautilus_preference_enum_add_entry_by_name (FRUIT_PREFERENCE,
|
||||
"orange",
|
||||
"Orange",
|
||||
FRUIT_ORANGE);
|
||||
|
||||
nautilus_preference_enum_add_entry_by_name (FRUIT_PREFERENCE,
|
||||
"bannana",
|
||||
"Bannana",
|
||||
FRUIT_BANNANA);
|
||||
|
||||
nautilus_preferences_set_enum (FRUIT_PREFERENCE,
|
||||
FRUIT_BANNANA);
|
||||
}
|
|
@ -1,227 +0,0 @@
|
|||
|
||||
#include <config.h>
|
||||
#include "nautilus-radio-button-group.h"
|
||||
#include "nautilus-preferences-group.h"
|
||||
#include "nautilus-preferences-item.h"
|
||||
#include "nautilus-preferences.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static void test_radio_group (void);
|
||||
static void test_preferences_group (void);
|
||||
static void test_preferences_item (void);
|
||||
|
||||
|
||||
static void test_radio_changed_signal (GtkWidget *button_group, gpointer user_data);
|
||||
|
||||
static GtkObject *
|
||||
create_dummy_prefs (void);
|
||||
|
||||
GtkWidget *
|
||||
create_enum_item (void);
|
||||
|
||||
GtkWidget *
|
||||
create_bool_item (void);
|
||||
|
||||
static GtkObject * dummy_prefs = NULL;
|
||||
|
||||
int
|
||||
main (int argc, char * argv[])
|
||||
{
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
dummy_prefs = create_dummy_prefs ();
|
||||
|
||||
test_preferences_group ();
|
||||
test_preferences_item ();
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
test_radio_group (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * buttons;
|
||||
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
buttons = nautilus_radio_button_group_new ();
|
||||
|
||||
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Apples");
|
||||
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Oranges");
|
||||
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Strawberries");
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (buttons),
|
||||
"changed",
|
||||
GTK_SIGNAL_FUNC (test_radio_changed_signal),
|
||||
(gpointer) NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), buttons);
|
||||
|
||||
gtk_widget_show (buttons);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_preferences_item (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * item;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
item = create_enum_item ();
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), item);
|
||||
|
||||
gtk_widget_show (item);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_preferences_group (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * group;
|
||||
|
||||
GtkWidget * item;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
group = nautilus_preferences_group_new ("A group");
|
||||
|
||||
item = create_enum_item ();
|
||||
|
||||
nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group),
|
||||
item);
|
||||
|
||||
gtk_widget_show (item);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), group);
|
||||
|
||||
gtk_widget_show (group);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_radio_changed_signal (GtkWidget *buttons, gpointer user_data)
|
||||
{
|
||||
gint i;
|
||||
|
||||
i = nautilus_radio_button_group_get_active_index (NAUTILUS_RADIO_BUTTON_GROUP (buttons));
|
||||
|
||||
printf ("test_radio_changed_signal (%d)\n", i);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
create_enum_item (void)
|
||||
{
|
||||
GtkWidget * item;
|
||||
|
||||
item = nautilus_preferences_item_new (dummy_prefs,
|
||||
"user_level",
|
||||
NAUTILUS_PREFERENCES_ITEM_ENUM);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
create_bool_item (void)
|
||||
{
|
||||
GtkWidget * item;
|
||||
|
||||
item = nautilus_preferences_item_new (dummy_prefs,
|
||||
"foo",
|
||||
NAUTILUS_PREFERENCES_ITEM_BOOL);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
static const gchar * prefs_global_user_level_names[] =
|
||||
{
|
||||
"novice",
|
||||
"intermediate",
|
||||
"hacker",
|
||||
"ettore"
|
||||
};
|
||||
|
||||
static const gchar * prefs_global_user_level_descriptions[] =
|
||||
{
|
||||
"Novice",
|
||||
"Intermediate",
|
||||
"Hacker",
|
||||
"Ettore"
|
||||
};
|
||||
|
||||
static const gint prefs_global_user_level_values[] =
|
||||
{
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3
|
||||
};
|
||||
|
||||
static NautilusPrefEnumData prefs_global_user_level_data =
|
||||
{
|
||||
prefs_global_user_level_names,
|
||||
prefs_global_user_level_descriptions,
|
||||
prefs_global_user_level_values,
|
||||
4
|
||||
};
|
||||
|
||||
static NautilusPrefInfo prefs_global_static_pref_info[] =
|
||||
{
|
||||
{
|
||||
"user_level",
|
||||
"User Level",
|
||||
GTK_TYPE_ENUM,
|
||||
FALSE,
|
||||
&prefs_global_user_level_data
|
||||
},
|
||||
{
|
||||
"foo",
|
||||
"Create new window for each new page",
|
||||
GTK_TYPE_BOOL,
|
||||
FALSE,
|
||||
NULL
|
||||
},
|
||||
{
|
||||
"bar",
|
||||
"Do not open more than one window with the same page",
|
||||
GTK_TYPE_BOOL,
|
||||
FALSE,
|
||||
NULL
|
||||
},
|
||||
};
|
||||
|
||||
static GtkObject *
|
||||
create_dummy_prefs (void)
|
||||
{
|
||||
GtkObject * dummy_prefs;
|
||||
guint i;
|
||||
|
||||
dummy_prefs = nautilus_preferences_new ("dummy");
|
||||
|
||||
/* Register the static prefs */
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
nautilus_preferences_register_from_info (NAUTILUS_PREFS (dummy_prefs),
|
||||
&prefs_global_static_pref_info[i]);
|
||||
}
|
||||
|
||||
|
||||
nautilus_preferences_set_enum (NAUTILUS_PREFS (dummy_prefs),
|
||||
"user_level",
|
||||
2);
|
||||
|
||||
return dummy_prefs;
|
||||
}
|
|
@ -6,3 +6,5 @@ Makefile
|
|||
Makefile.in
|
||||
test-nautilus-mime-actions
|
||||
test-nautilus-mime-actions-set
|
||||
test-nautilus-widgets
|
||||
test-nautilus-preferences
|
||||
|
|
|
@ -30,15 +30,21 @@ LDADD =\
|
|||
$(XML_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
test-nautilus-mime-actions \
|
||||
test-nautilus-mime-actions-set \
|
||||
noinst_PROGRAMS =\
|
||||
test-nautilus-mime-actions \
|
||||
test-nautilus-mime-actions-set \
|
||||
test-nautilus-widgets \
|
||||
test-nautilus-preferences \
|
||||
$(NULL)
|
||||
|
||||
test_nautilus_mime_actions_SOURCES = test-nautilus-mime-actions.c
|
||||
|
||||
test_nautilus_mime_actions_set_SOURCES = test-nautilus-mime-actions-set.c
|
||||
|
||||
test_nautilus_widgets_SOURCES = test-nautilus-widgets.c
|
||||
|
||||
test_nautilus_preferences_SOURCES = test-nautilus-preferences.c
|
||||
|
||||
#libleakcheck_la_SOURCES = \
|
||||
# nautilus-leak-checker.c \
|
||||
# nautilus-leak-checker.h \
|
||||
|
|
|
@ -51,6 +51,11 @@ void *(* real_memalign) (size_t boundary, size_t size);
|
|||
void *(* real_realloc) (void *ptr, size_t size);
|
||||
void *(* real_calloc) (void *ptr, size_t size);
|
||||
void (* real_free) (void *ptr);
|
||||
int (* real_start_main) (int (*main) (int, char **, char **), int argc,
|
||||
char **argv, void (*init) (void), void (*fini) (void),
|
||||
void (*rtld_fini) (void), void *stack_end);
|
||||
|
||||
|
||||
|
||||
const char *app_path;
|
||||
|
||||
|
@ -146,6 +151,7 @@ nautilus_leak_initialize (void)
|
|||
real_free = dlsym (RTLD_NEXT, "__libc_free");
|
||||
real_memalign = dlsym (RTLD_NEXT, "__libc_memalign");
|
||||
real_calloc = dlsym (RTLD_NEXT, "__libc_calloc");
|
||||
real_start_main = dlsym (RTLD_NEXT, "__libc_start_main");
|
||||
|
||||
nautilus_leak_hooks_initialized = TRUE;
|
||||
nautilus_leak_check_leaks = TRUE;
|
||||
|
@ -504,6 +510,20 @@ __libc_free (void *ptr)
|
|||
(real_free) (ptr);
|
||||
}
|
||||
|
||||
int
|
||||
__libc_start_main (int (*main) (int, char **, char **), int argc,
|
||||
char **argv, void (*init) (void), void (*fini) (void),
|
||||
void (*rtld_fini) (void), void *stack_end)
|
||||
{
|
||||
nautilus_leak_initialize_if_needed ();
|
||||
|
||||
nautilus_leak_checker_init (argv[0]);
|
||||
|
||||
printf ("once\n");
|
||||
|
||||
return real_start_main (main, argc, argv, init, fini, rtld_fini, stack_end);
|
||||
}
|
||||
|
||||
/* We try to keep a lot of code in between __libc_free and malloc to make
|
||||
* the reentry detection that depends on call address proximity work.
|
||||
*/
|
||||
|
@ -587,6 +607,13 @@ nautilus_leak_print_leaks (int stack_grouping_depth, int stack_print_depth,
|
|||
nautilus_leak_print_symbol_cleanup ();
|
||||
}
|
||||
|
||||
static void
|
||||
print_leaks_at_exit (void)
|
||||
{
|
||||
/* If leak checking, dump all the outstanding allocations just before exiting. */
|
||||
nautilus_leak_print_leaks (8, 15, 40, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_leak_checker_init (const char *path)
|
||||
{
|
||||
|
@ -595,6 +622,8 @@ nautilus_leak_checker_init (const char *path)
|
|||
*/
|
||||
printf("setting up the leakchecker for %s\n", path);
|
||||
app_path = path;
|
||||
|
||||
g_atexit (print_leaks_at_exit);
|
||||
}
|
||||
|
||||
void *
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
|
||||
#include <config.h>
|
||||
#include "nautilus-radio-button-group.h"
|
||||
#include "nautilus-caption-table.h"
|
||||
#include "nautilus-password-dialog.h"
|
||||
#include "nautilus-preferences-group.h"
|
||||
#include "nautilus-preferences-item.h"
|
||||
#include "nautilus-preferences.h"
|
||||
|
||||
#include <libnautilus-extensions/nautilus-radio-button-group.h>
|
||||
#include <libnautilus-extensions/nautilus-caption-table.h>
|
||||
#include <libnautilus-extensions/nautilus-password-dialog.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences-group.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences-item.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include "nautilus-caption-table.h"
|
||||
#include "nautilus-password-dialog.h"
|
||||
#include "nautilus-radio-button-group.h"
|
||||
#include "nautilus-string-picker.h"
|
||||
#include "nautilus-text-caption.h"
|
||||
#include <libnautilus-extensions/nautilus-caption-table.h>
|
||||
#include <libnautilus-extensions/nautilus-password-dialog.h>
|
||||
#include <libnautilus-extensions/nautilus-radio-button-group.h>
|
||||
#include <libnautilus-extensions/nautilus-string-picker.h>
|
||||
#include <libnautilus-extensions/nautilus-text-caption.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
Loading…
Reference in a new issue