GLib/GTK+ functions, except for a couple of places were we use
GtkCList.]
* Makefile.am (INCLUDES): Add `-DG_DISABLE_DEPRECATED
-DGTK_DISABLE_DEPRECATED'.
* evolution-test-component.c (create_new_folder_selector): No
gtk_window_set_policy().
* main.c (quit_box_new): gtk_window_set_resizable() instead of
gtk_window_set_policy().
(view_map_callback): g_signal_handlers_disconnect_by_func()
instead of gtk_signal_disconnect_by_func().
(main): No need to push the GdkRGB visual/cmap anymore.
(new_view_created_callback): Likewise.
* e-task-widget.c: Renamed member pixmap of ETaskWidgetPrivate to
`image'.
(init): Updated accordingly.
(e_task_widget_construct): Use GtkImage, not GtkPixmap.
* e-storage.c (class_init): Converted from gtk_signal_new() to
g_signal_new().
* e-storage-set.c (class_init): Converted from gtk_signal_new() to
g_signal_new().
* e-storage-set-view.c
(setup_folder_properties_items_if_corba_storage_clicked):
g_string_append_printf() instead of g_string_sprintfa().
(class_init): Converted from gtk_signal_new() to g_signal_new().
(setup_folder_changed_callbacks): Use
e_signal_connect_while_alive() and
e_signal_connect_full_while_alive().
* e-splash.c (e_splash_construct): gtk_window_set_resizable()
instead of gtk_window_set_policy().
* e-shortcuts.c: Do not #include e-unicode.h.
(shortcut_item_update): Use g_path_get_basename() instead of
g_basename().
(e_shortcuts_add_default_shortcuts): No need to de-utfize strings.
(e_shortcuts_add_default_group): Same here.
* e-shortcuts-view.c: Do not #include <e-unicode.h>.
(class_init): Converted from gtk_signal_new() to g_signal_new().
(destroy_group_cb): No need to convert the text from UTF8.
* e-shell.c (impl_dispose): g_signal_handlers_disconnect_by_func()
instead of gtk_signal_disconnect_by_func().
(class_init): Use g_signal_new() instead of gtk_signal_new().
* e-shell-view.c: Do not #include e-unicode.h. Renamed member
offline_toggle_pixmap to offline_toggle_image in
EShellViewPrivate.
(update_folder_title_bar): No need to de-UTF8-ize the title.
(cleanup_delayed_selection):
g_signal_handlers_disconnect_by_func() instead of
gtk_signal_disconnect_by_func().
(ui_engine_add_hint_callback): gtk_label_set_text(), not
gtk_label_set().
(class_init): Use g_signal_new() instead of gtk_signal_new().
(update_for_current_uri): No need to convert the title from UTF8.
(setup_offline_toggle): Changed to set up a GtkImage, not a
GtkPixmap.
(update_offline_toggle_status): Accordingly (gtk_image* instead of
gtk_pixmap*).
(set_current_notebook_page): gtk_notebook_set_current_page(), not
gtk_notebook_set_page().
(get_storage_set_path_from_uri): g_ascii_strncasecmp() instead of
g_strncasecmp().
(folder_bar_popup_map_callback): Use
e_signal_connect_while_alive() instead of
gtk_signal_connect_while_alive().
(e_shell_view_construct): Likewise.
(display_uri): g_signal_connect_after() instead of
gtk_signal_connect_full().
(update_for_current_uri):
g_signal_handlers_{block,unblock}_by_func() instead of
gtk_signal_handler_{block,unblock}_by_func().
* e-shell-view-menu.c (command_about_box):
gtk_window_set_resizable() instead of gtk_window_set_policy().
* e-shell-utils.c (get_mini_name): g_path_get_basename() instead
of g_basename().
* e-shell-user-creatable-items-handler.c
(append_xml_for_menu_item): g_string_append_printf() instead of
g_string_sprintfa().
(create_menu_xml): Likewise.
* e-shell-shared-folder-picker-dialog.c: Do not #include
e-unicode.h.
(progress_bar_timeout_callback): Expect a GtkProgressBar data and
just use gtk_progress_bar_pulse().
(create_progress_dialog): gtk_window_set_resizable() instead of
gtk_window_set_policy(). No gtk_progress_set_activity_mode().
(setup_server_option_menu): Just use
gtk_menu_item_new_with_label() instead of
e_utf8_gtk_menu_item_new_with_label().
* e-shell-settings-dialog.c (set_dialog_size): Ported to Pango.
* e-shell-offline-sync.c
(impl_SyncFolderProgressListener_updateProgress):
gtk_progress_set_fraction() instead of
gtk_progress_bar_set_percentage().
(sync_folder): Likewise.
(setup_dialog): gtk_window_set_resizable() instead of
gtk_window_set_policy().
(sync_folder): No gtk_progress_set_activity_mode().
* e-shell-offline-handler.c: #undef {G,GTK}_DISABLE_DEPRECATED
here for now (need to port from GtkCList).
(class_init): Use g_signal_new()
* e-shell-importer.c: #undef {G,GTK}_DISABLE_DEPRECATED here for
now (need to port from GtkCList).
* e-shell-folder-title-bar.c (create_image_widget_from_xpm):
Renamed from create_pixmap_widget_from_xpm(); handle GtkImage
instead of GtkPixmap.
(new_empty_image_widget): Renamed from new_empty_pixmap_widget();
return a GtkImage instead of a GtkPixmap.
(add_navigation_buttons): Updated accordingly; so use GtkImages
instead of GtkPixmaps.
(e_shell_folder_title_bar_construct): Likewise.
(e_shell_folder_title_bar_set_icon): Use gtk_image_* instead of
gtk_pixmap_* on the image widgets.
(class_init): Converted to use g_signal_new() instead of
gtk_signal_new().
(e_shell_folder_title_bar_new): No need for pushing the GdkRGB
visual/cmap anymore.
* e-shell-folder-selection-dialog.c (check_folder_type_valid):
Just use strcmp instead of strcasecmp().
(class_init): g_signal_new() instead of gtk_signal_new().
(e_shell_folder_selection_dialog_construct): Removed call to
gtk_window_set_policy().
* e-shell-folder-creation-dialog.c
(type_with_display_name_compare_func): Changed to use
g_utf8_casefold().
* e-shell-folder-commands.c: Do not #include e-unicode.h.
(e_shell_command_rename_folder): g_path_get_dirname() instead of
g_dirname().
(folder_selection_dialog_folder_selected_callback):
g_path_get_basename() instead of g_basename().
(rename_cb): Likewise.
(delete_dialog): Do not convert from UTF8 for display purposes.
(e_shell_command_rename_folder): Likewise.
* e-shell-about-box.c (timeout_callback): Ported to Pango and use
gdk_window_invalidate_rect() instead of gtk_widget_draw().
* e-setup.c (check_evolution_directory): Use
gtk_window_set_resizable() instead of gtk_window_set_policy().
* e-local-storage.c: Do not include e-unicode.h.
(create_folder): Use g_path_get_basename() instead of
g_basename().
(create_folder_directory): Likewise.
(remove_folder_directory): Likewise.
(append_xfer_item_list): Likewise.
* e-local-folder.c (construct_loading_metadata): Use
g_path_get_basename() instead of g_basename().
* e-folder-dnd-bridge.c (handle_evolution_path_drag_motion): Use
g_path_get_basename() instead of g_basename().
* e-corba-storage-registry.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* e-corba-shortcuts.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* e-component-registry.c
(sleep_with_g_main_loop_timeout_callback): g_main_loop_* instead
of g_main_*.
(sleep_with_g_main_loop): Likewise.
* e-activity-handler.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-wizard.c (evolution_wizard_class_init): g_signal_new()
instead of gtk_signal_new().
* evolution-storage-listener.c (class_init): g_signal_new()
instead of gtk_signal_new().
* evolution-shell-view.c (class_init): g_signal_new() instead of
gtk_signal_new().
* evolution-shell-component-dnd.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-shell-component.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-session.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-folder-selector-button.c: Do not include e-unicode.h.
(set_folder): No need to convert from UTF8 to locale encoding
anymore. Removed unused variable.
* evolution-config-control.c (class_init): Use g_signal_new()
instead of gtk_signal_new().
* evolution-activity-client.c (class_init): Use g_signal_new()
instead of gtk_signal_new().
* e-folder-list.c: Do not include e-unicode.h. Use E_MAKE_TYPE().
(e_folder_list_get_type): Removed explicit implementation of this.
(e_folder_list_set_arg): Removed.
(e_folder_list_get_arg): Removed.
(e_folder_list_set_property): New.
(e_folder_list_get_property): New.
(e_folder_list_destroy): Removed.
(e_folder_list_dispose): New.
(e_folder_list_class_init): Updated accordingly.
* e-folder.c (impl_save_info): Use G_OBJECT_TYPE_NAME() instead of
gtk_type_name().
(impl_load_info): Likewise.
(impl_remove): Likewise.
(class_init): Use g_signal_new() instead of gtk_signal_new().
svn path=/trunk/; revision=19170
447 lines
12 KiB
C
447 lines
12 KiB
C
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||
/* evolution-folder-selector-button.c
|
||
*
|
||
* Copyright (C) 2002 Ximian, Inc.
|
||
*
|
||
* This program is free software; you can redistribute it and/or
|
||
* modify it under the terms of version 2 of the GNU General Public
|
||
* License as published by the Free Software Foundation.
|
||
*
|
||
* This program 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
|
||
* General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU General Public
|
||
* License along with this program; if not, write to the
|
||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||
* Boston, MA 02111-1307, USA.
|
||
*/
|
||
|
||
#ifdef HAVE_CONFIG_H
|
||
#include <config.h>
|
||
#endif
|
||
|
||
#include "evolution-folder-selector-button.h"
|
||
|
||
#include "e-shell-marshal.h"
|
||
|
||
#include <gal/util/e-util.h>
|
||
|
||
#include <gtk/gtkhbox.h>
|
||
#include <gtk/gtkimage.h>
|
||
#include <gtk/gtklabel.h>
|
||
|
||
#include <libgnome/gnome-i18n.h>
|
||
|
||
#include <string.h>
|
||
|
||
|
||
struct _EvolutionFolderSelectorButtonPrivate {
|
||
EvolutionShellClient *shell_client;
|
||
GNOME_Evolution_StorageRegistry corba_storage_registry;
|
||
GNOME_Evolution_Folder *selected_folder;
|
||
GtkWidget *icon, *label;
|
||
char *title, **possible_types;
|
||
};
|
||
|
||
enum {
|
||
POPPED_UP,
|
||
SELECTED,
|
||
CANCELED,
|
||
LAST_SIGNAL
|
||
};
|
||
static guint signals[LAST_SIGNAL] = { 0 };
|
||
|
||
#define PARENT_TYPE gtk_button_get_type ()
|
||
static GtkButtonClass *parent_class = NULL;
|
||
|
||
|
||
static GNOME_Evolution_Folder *
|
||
get_folder_for_uri (EvolutionFolderSelectorButton *folder_selector_button,
|
||
const char *uri)
|
||
{
|
||
EvolutionFolderSelectorButtonPrivate *priv = folder_selector_button->priv;
|
||
CORBA_Environment ev;
|
||
GNOME_Evolution_Folder *folder;
|
||
|
||
if (!uri)
|
||
return NULL;
|
||
|
||
CORBA_exception_init (&ev);
|
||
folder = GNOME_Evolution_StorageRegistry_getFolderByUri (
|
||
priv->corba_storage_registry, uri, &ev);
|
||
if (ev._major != CORBA_NO_EXCEPTION)
|
||
folder = CORBA_OBJECT_NIL;
|
||
CORBA_exception_free (&ev);
|
||
|
||
return folder;
|
||
}
|
||
|
||
static void
|
||
set_folder (EvolutionFolderSelectorButton *folder_selector_button,
|
||
GNOME_Evolution_Folder *folder)
|
||
{
|
||
EvolutionFolderSelectorButtonPrivate *priv;
|
||
GdkPixbuf *pixbuf;
|
||
char *storage_lname;
|
||
char *label_text;
|
||
const char *p;
|
||
|
||
priv = folder_selector_button->priv;
|
||
|
||
if (priv->selected_folder)
|
||
CORBA_free (priv->selected_folder);
|
||
priv->selected_folder = folder;
|
||
|
||
if (!folder) {
|
||
/* FIXME: Will this work? */
|
||
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), NULL);
|
||
gtk_label_set_text (GTK_LABEL (priv->label),
|
||
_("<click here to select a folder>"));
|
||
return;
|
||
}
|
||
|
||
pixbuf = evolution_shell_client_get_pixbuf_for_type (priv->shell_client, folder->type, TRUE);
|
||
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), pixbuf);
|
||
g_object_unref (pixbuf);
|
||
|
||
storage_lname = NULL;
|
||
p = strchr (folder->evolutionUri, '/');
|
||
if (p) {
|
||
p = strchr (p + 1, '/');
|
||
if (p) {
|
||
GNOME_Evolution_Folder *storage_folder;
|
||
char *storage_uri;
|
||
|
||
storage_uri = g_strndup (folder->evolutionUri,
|
||
p - folder->evolutionUri);
|
||
storage_folder = get_folder_for_uri (folder_selector_button, storage_uri);
|
||
storage_lname = g_strdup (storage_folder->displayName);
|
||
CORBA_free (storage_folder);
|
||
g_free (storage_uri);
|
||
}
|
||
}
|
||
|
||
if (storage_lname) {
|
||
label_text = g_strdup_printf (_("\"%s\" in \"%s\""), folder->displayName,
|
||
storage_lname);
|
||
g_free (storage_lname);
|
||
} else
|
||
label_text = g_strdup_printf ("\"%s\"", folder->displayName);
|
||
|
||
gtk_label_set_text (GTK_LABEL (priv->label), label_text);
|
||
g_free (label_text);
|
||
g_free (storage_lname);
|
||
}
|
||
|
||
static void
|
||
clicked (GtkButton *button)
|
||
{
|
||
EvolutionFolderSelectorButton *folder_selector_button;
|
||
EvolutionFolderSelectorButtonPrivate *priv;
|
||
GNOME_Evolution_Folder *return_folder;
|
||
GtkWindow *parent_window;
|
||
char *initial_uri;
|
||
|
||
parent_window = (GtkWindow *)
|
||
gtk_widget_get_ancestor (GTK_WIDGET (button),
|
||
GTK_TYPE_WINDOW);
|
||
|
||
gtk_widget_set_sensitive (GTK_WIDGET (parent_window), FALSE);
|
||
g_object_ref (parent_window);
|
||
|
||
folder_selector_button = EVOLUTION_FOLDER_SELECTOR_BUTTON (button);
|
||
priv = folder_selector_button->priv;
|
||
|
||
if (priv->selected_folder)
|
||
initial_uri = priv->selected_folder->evolutionUri;
|
||
else
|
||
initial_uri = "";
|
||
|
||
g_signal_emit (folder_selector_button, signals[POPPED_UP], 0);
|
||
|
||
g_object_add_weak_pointer (G_OBJECT (parent_window), (void **) &parent_window);
|
||
|
||
evolution_shell_client_user_select_folder (priv->shell_client,
|
||
parent_window,
|
||
priv->title,
|
||
initial_uri,
|
||
(const char **)priv->possible_types,
|
||
&return_folder);
|
||
|
||
g_object_remove_weak_pointer (G_OBJECT (parent_window), (void **) &parent_window);
|
||
|
||
/* If the parent gets destroyed despite our best efforts (eg,
|
||
* because its own parent got destroyed), then the folder
|
||
* selector button will have been destroyed too and we need
|
||
* to just bail out here.
|
||
*/
|
||
if (parent_window == NULL)
|
||
return;
|
||
|
||
gtk_widget_set_sensitive (GTK_WIDGET (parent_window), TRUE);
|
||
g_object_unref (parent_window);
|
||
|
||
if (!return_folder) {
|
||
g_signal_emit (folder_selector_button, signals[CANCELED], 0);
|
||
return;
|
||
}
|
||
|
||
set_folder (folder_selector_button, return_folder);
|
||
|
||
g_signal_emit (folder_selector_button, signals[SELECTED], 0, return_folder);
|
||
}
|
||
|
||
|
||
/* GObject methods. */
|
||
|
||
static void
|
||
impl_dispose (GObject *object)
|
||
{
|
||
EvolutionFolderSelectorButton *folder_selector_button;
|
||
EvolutionFolderSelectorButtonPrivate *priv;
|
||
|
||
folder_selector_button = EVOLUTION_FOLDER_SELECTOR_BUTTON (object);
|
||
priv = folder_selector_button->priv;
|
||
|
||
if (priv->shell_client != NULL) {
|
||
g_object_unref (priv->shell_client);
|
||
priv->shell_client = NULL;
|
||
}
|
||
|
||
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
|
||
}
|
||
|
||
static void
|
||
impl_finalize (GObject *object)
|
||
{
|
||
EvolutionFolderSelectorButton *folder_selector_button;
|
||
EvolutionFolderSelectorButtonPrivate *priv;
|
||
int i;
|
||
|
||
folder_selector_button = EVOLUTION_FOLDER_SELECTOR_BUTTON (object);
|
||
priv = folder_selector_button->priv;
|
||
|
||
g_free (priv->title);
|
||
for (i = 0; priv->possible_types[i]; i++)
|
||
g_free (priv->possible_types[i]);
|
||
g_free (priv->possible_types);
|
||
|
||
if (priv->selected_folder)
|
||
CORBA_free (priv->selected_folder);
|
||
|
||
g_free (priv);
|
||
|
||
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
|
||
}
|
||
|
||
|
||
static void
|
||
class_init (EvolutionFolderSelectorButtonClass *klass)
|
||
{
|
||
GObjectClass *object_class;
|
||
GtkButtonClass *button_class;
|
||
|
||
parent_class = g_type_class_ref(PARENT_TYPE);
|
||
|
||
object_class = G_OBJECT_CLASS (klass);
|
||
button_class = GTK_BUTTON_CLASS (klass);
|
||
|
||
button_class->clicked = clicked;
|
||
|
||
object_class->dispose = impl_dispose;
|
||
object_class->finalize = impl_finalize;
|
||
|
||
signals[POPPED_UP] = g_signal_new ("popped_up",
|
||
G_OBJECT_CLASS_TYPE (object_class),
|
||
G_SIGNAL_RUN_FIRST,
|
||
G_STRUCT_OFFSET (EvolutionFolderSelectorButtonClass, popped_up),
|
||
NULL, NULL,
|
||
e_shell_marshal_NONE__NONE,
|
||
G_TYPE_NONE, 0);
|
||
signals[SELECTED] = g_signal_new ("selected",
|
||
G_OBJECT_CLASS_TYPE (object_class),
|
||
G_SIGNAL_RUN_FIRST,
|
||
G_STRUCT_OFFSET (EvolutionFolderSelectorButtonClass, selected),
|
||
NULL, NULL,
|
||
e_shell_marshal_NONE__POINTER,
|
||
G_TYPE_NONE, 1,
|
||
G_TYPE_POINTER);
|
||
signals[CANCELED] = g_signal_new ("canceled",
|
||
G_OBJECT_CLASS_TYPE (object_class),
|
||
G_SIGNAL_RUN_FIRST,
|
||
G_STRUCT_OFFSET (EvolutionFolderSelectorButtonClass, canceled),
|
||
NULL, NULL,
|
||
e_shell_marshal_NONE__NONE,
|
||
G_TYPE_NONE, 0);
|
||
}
|
||
|
||
static void
|
||
init (EvolutionFolderSelectorButton *folder_selector_button)
|
||
{
|
||
EvolutionFolderSelectorButtonPrivate *priv;
|
||
GtkWidget *box;
|
||
|
||
priv = g_new0 (EvolutionFolderSelectorButtonPrivate, 1);
|
||
|
||
priv->icon = gtk_image_new ();
|
||
priv->label = gtk_label_new ("");
|
||
gtk_label_set_justify (GTK_LABEL (priv->label), GTK_JUSTIFY_LEFT);
|
||
gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.0);
|
||
box = gtk_hbox_new (FALSE, 4);
|
||
gtk_box_pack_start (GTK_BOX (box), priv->icon, FALSE, TRUE, 0);
|
||
gtk_box_pack_start (GTK_BOX (box), priv->label, TRUE, TRUE, 0);
|
||
gtk_widget_show_all (GTK_WIDGET (box));
|
||
gtk_container_add (GTK_CONTAINER (folder_selector_button), box);
|
||
|
||
folder_selector_button->priv = priv;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* evolution_folder_selector_button_construct:
|
||
* @folder_selector_button:
|
||
* @shell_client: the shell client that will be used for folder selection
|
||
* @title: the title to use for the selection dialog
|
||
* @initial_uri: the URI (evolution: or physical) of the
|
||
* initially-selected folder
|
||
* @possible_types: a %NULL-terminated array of selectable types.
|
||
*
|
||
* Construct @folder_selector_button.
|
||
**/
|
||
void
|
||
evolution_folder_selector_button_construct (EvolutionFolderSelectorButton *folder_selector_button,
|
||
EvolutionShellClient *shell_client,
|
||
const char *title,
|
||
const char *initial_uri,
|
||
const char *possible_types[])
|
||
{
|
||
EvolutionFolderSelectorButtonPrivate *priv;
|
||
GNOME_Evolution_Folder *folder;
|
||
int count;
|
||
|
||
g_return_if_fail (EVOLUTION_IS_FOLDER_SELECTOR_BUTTON (folder_selector_button));
|
||
g_return_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client));
|
||
g_return_if_fail (possible_types != NULL);
|
||
|
||
priv = folder_selector_button->priv;
|
||
|
||
priv->shell_client = shell_client;
|
||
g_object_ref (shell_client);
|
||
priv->corba_storage_registry = evolution_shell_client_get_storage_registry_interface (shell_client);
|
||
|
||
priv->title = g_strdup (title);
|
||
|
||
folder = get_folder_for_uri (folder_selector_button, initial_uri);
|
||
set_folder (folder_selector_button, folder);
|
||
|
||
for (count = 0; possible_types[count]; count++)
|
||
;
|
||
priv->possible_types = g_new (char *, count + 1);
|
||
for (count = 0; possible_types[count]; count++)
|
||
priv->possible_types[count] = g_strdup (possible_types[count]);
|
||
priv->possible_types[count] = NULL;
|
||
}
|
||
|
||
/**
|
||
* evolution_folder_selector_button_new:
|
||
* @shell_client: the shell client that will be used for folder selection
|
||
* @title: the title to use for the selection dialog
|
||
* @initial_uri: the URI (evolution: or physical) of the
|
||
* initially-selected folder
|
||
* @possible_types: a %NULL-terminated array of selectable types.
|
||
*
|
||
* Return value: a new folder selector button.
|
||
**/
|
||
GtkWidget *
|
||
evolution_folder_selector_button_new (EvolutionShellClient *shell_client,
|
||
const char *title,
|
||
const char *initial_uri,
|
||
const char *possible_types[])
|
||
{
|
||
EvolutionFolderSelectorButton *folder_selector_button;
|
||
|
||
folder_selector_button = g_object_new (evolution_folder_selector_button_get_type (), NULL);
|
||
|
||
evolution_folder_selector_button_construct (folder_selector_button,
|
||
shell_client,
|
||
title,
|
||
initial_uri,
|
||
possible_types);
|
||
return (GtkWidget *)folder_selector_button;
|
||
}
|
||
|
||
/**
|
||
* evolution_folder_selector_button_set_uri:
|
||
* @folder_selector_button:
|
||
* @uri: the URI (evolution: or physical) to select, or %NULL
|
||
*
|
||
* Attempts to make @folder_selector_button select @uri. If @uri
|
||
* doesn't point to a folder, or points to a folder of an incorrect
|
||
* type for this button, then the selected URI will be unchanged.
|
||
*
|
||
* If @uri is %NULL, the button will be returned to an unselected
|
||
* state.
|
||
*
|
||
* Return value: whether or not the URI was successfully set.
|
||
**/
|
||
gboolean
|
||
evolution_folder_selector_button_set_uri (EvolutionFolderSelectorButton *folder_selector_button,
|
||
const char *uri)
|
||
{
|
||
EvolutionFolderSelectorButtonPrivate *priv;
|
||
GNOME_Evolution_Folder *folder;
|
||
char *slash;
|
||
int i;
|
||
|
||
g_return_val_if_fail (EVOLUTION_IS_FOLDER_SELECTOR_BUTTON (folder_selector_button), FALSE);
|
||
g_return_val_if_fail (uri != NULL, FALSE);
|
||
|
||
priv = folder_selector_button->priv;
|
||
|
||
if (!uri) {
|
||
set_folder (folder_selector_button, NULL);
|
||
return TRUE;
|
||
}
|
||
|
||
folder = get_folder_for_uri (folder_selector_button, uri);
|
||
if (!folder)
|
||
return FALSE;
|
||
|
||
for (i = 0; priv->possible_types[i]; i++) {
|
||
if (!strcmp (folder->type, priv->possible_types[i])) {
|
||
set_folder (folder_selector_button, folder);
|
||
return TRUE;
|
||
}
|
||
slash = strchr (priv->possible_types[i], '/');
|
||
if (slash && slash[1] == '*' &&
|
||
!strncmp (folder->type, priv->possible_types[i],
|
||
slash - priv->possible_types[i])) {
|
||
set_folder (folder_selector_button, folder);
|
||
return TRUE;
|
||
}
|
||
}
|
||
|
||
CORBA_free (folder);
|
||
return FALSE;
|
||
}
|
||
|
||
/**
|
||
* evolution_folder_selector_button_get_folder:
|
||
* @folder_selector_button:
|
||
*
|
||
* Return value: the currently-selected folder, or %NULL
|
||
**/
|
||
GNOME_Evolution_Folder *
|
||
evolution_folder_selector_button_get_folder (EvolutionFolderSelectorButton *folder_selector_button)
|
||
{
|
||
g_return_val_if_fail (EVOLUTION_IS_FOLDER_SELECTOR_BUTTON (folder_selector_button), NULL);
|
||
|
||
return folder_selector_button->priv->selected_folder;
|
||
}
|
||
|
||
|
||
E_MAKE_TYPE (evolution_folder_selector_button, "EvolutionFolderSelectorButton", EvolutionFolderSelectorButton, class_init, init, PARENT_TYPE)
|