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
811 lines
22 KiB
C
811 lines
22 KiB
C
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||
/* e-shell-folder-title-bar.c
|
||
*
|
||
* Copyright (C) 2000, 2001 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.
|
||
*
|
||
* Author: Ettore Perazzoli
|
||
*/
|
||
|
||
#ifdef HAVE_CONFIG_H
|
||
#include <config.h>
|
||
#endif
|
||
|
||
#include <gtk/gtklabel.h>
|
||
#include <gtk/gtkimage.h>
|
||
#include <gtk/gtkrc.h>
|
||
#include <gtk/gtksignal.h>
|
||
#include <gtk/gtktogglebutton.h>
|
||
#include <libgnome/gnome-i18n.h>
|
||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||
|
||
#include <gal/util/e-util.h>
|
||
#include <gal/widgets/e-font.h>
|
||
|
||
#include "widgets/misc/e-clipped-label.h"
|
||
#include "e-shell-constants.h"
|
||
#include "e-shell-marshal.h"
|
||
#include "e-shell-folder-title-bar.h"
|
||
|
||
|
||
#define PARENT_TYPE GTK_TYPE_HBOX
|
||
static GtkHBox *parent_class = NULL;
|
||
|
||
struct _EShellFolderTitleBarPrivate {
|
||
GdkPixbuf *icon;
|
||
|
||
/* We have an icon, a label and a button that contains an icon and a
|
||
label. When the button is enabled, the stand-alone label icon get
|
||
hidden; when the button is disabled, the button gets hidden and the
|
||
label and the icon get shown. This is pretty ugly but it easier to
|
||
manage the GTK layout this way. */
|
||
|
||
/* The stand-alone icon/label combo. */
|
||
GtkWidget *title_icon;
|
||
GtkWidget *title_label;
|
||
|
||
/* The button. */
|
||
GtkWidget *title_button;
|
||
GtkWidget *title_button_icon;
|
||
GtkWidget *title_button_label;
|
||
GtkWidget *title_button_arrow;
|
||
|
||
/* Holds extra information that is to be shown on the bar. */
|
||
GtkWidget *folder_bar_label;
|
||
|
||
/* Navigation buttons. */
|
||
GtkWidget *back_button;
|
||
GtkWidget *forward_button;
|
||
|
||
gboolean title_clickable;
|
||
};
|
||
|
||
enum {
|
||
TITLE_TOGGLED,
|
||
BACK_CLICKED,
|
||
FORWARD_CLICKED,
|
||
LAST_SIGNAL
|
||
};
|
||
|
||
static guint signals[LAST_SIGNAL] = { 0 };
|
||
|
||
|
||
static const char *down_arrow_xpm[] = {
|
||
"11 5 2 1",
|
||
" c none",
|
||
". c #ffffffffffff",
|
||
" ......... ",
|
||
" ....... ",
|
||
" ..... ",
|
||
" ... ",
|
||
" . ",
|
||
};
|
||
|
||
static const char *left_arrow_xpm[] = {
|
||
"11 7 2 1",
|
||
" c none",
|
||
". c #ffffffffffff",
|
||
" . ",
|
||
" .. ",
|
||
" ........ ",
|
||
" ......... ",
|
||
" ........ ",
|
||
" .. ",
|
||
" . ",
|
||
};
|
||
|
||
static const char *right_arrow_xpm[] = {
|
||
"11 7 2 1",
|
||
" c none",
|
||
". c #ffffffffffff",
|
||
" . ",
|
||
" .. ",
|
||
" ........ ",
|
||
" ......... ",
|
||
" ........ ",
|
||
" .. ",
|
||
" . ",
|
||
};
|
||
|
||
|
||
/* Utility functions for managing icons and icon widgets. */
|
||
|
||
static GtkWidget *
|
||
create_image_widget_from_xpm (const char **xpm)
|
||
{
|
||
GdkPixbuf *pixbuf;
|
||
GdkPixmap *pixmap;
|
||
GdkBitmap *mask;
|
||
GtkWidget *widget;
|
||
|
||
pixbuf = gdk_pixbuf_new_from_xpm_data (xpm);
|
||
|
||
gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 127);
|
||
|
||
widget = gtk_image_new_from_pixmap (pixmap, mask);
|
||
gtk_widget_show (widget);
|
||
|
||
return widget;
|
||
}
|
||
|
||
static GdkPixbuf *
|
||
new_empty_pixbuf (void)
|
||
{
|
||
GdkPixbuf *empty_pixbuf;
|
||
unsigned char *pixels;
|
||
|
||
empty_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
|
||
pixels = gdk_pixbuf_get_pixels (empty_pixbuf);
|
||
|
||
memset (pixels, 0, 4);
|
||
|
||
return empty_pixbuf;
|
||
}
|
||
|
||
static GtkWidget *
|
||
new_empty_image_widget (void)
|
||
{
|
||
GtkWidget *image_widget;
|
||
GdkPixmap *pixmap;
|
||
GdkBitmap *mask;
|
||
GdkPixbuf *empty_pixbuf;
|
||
|
||
empty_pixbuf = new_empty_pixbuf ();
|
||
|
||
gdk_pixbuf_render_pixmap_and_mask (empty_pixbuf, &pixmap, &mask, 127);
|
||
image_widget = gtk_image_new_from_pixmap (pixmap, mask);
|
||
|
||
g_object_unref (empty_pixbuf);
|
||
|
||
return image_widget;
|
||
}
|
||
|
||
|
||
static void
|
||
set_title_bar_label_style (GtkWidget *widget)
|
||
{
|
||
GtkRcStyle *rc_style;
|
||
|
||
rc_style = gtk_rc_style_new();
|
||
|
||
rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG;
|
||
rc_style->fg[GTK_STATE_NORMAL].red = 0xffff;
|
||
rc_style->fg[GTK_STATE_NORMAL].green = 0xffff;
|
||
rc_style->fg[GTK_STATE_NORMAL].blue = 0xffff;
|
||
|
||
gtk_widget_modify_style (widget, rc_style);
|
||
gtk_rc_style_unref (rc_style);
|
||
}
|
||
|
||
|
||
/* Utility functions. */
|
||
|
||
static int
|
||
get_max_clipped_label_width (EClippedLabel *clipped_label)
|
||
{
|
||
PangoLayout *layout;
|
||
int width;
|
||
|
||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (clipped_label),
|
||
clipped_label->label);
|
||
|
||
pango_layout_get_pixel_size (layout, &width, NULL);
|
||
width += 2 * GTK_MISC (clipped_label)->xpad;
|
||
|
||
g_object_unref (layout);
|
||
|
||
return width;
|
||
}
|
||
|
||
static void
|
||
size_allocate_title_button (EShellFolderTitleBar *title_bar,
|
||
GtkAllocation *allocation,
|
||
int offset,
|
||
int *available_width_inout)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
GtkAllocation child_allocation;
|
||
GtkRequisition child_requisition;
|
||
int border_width;
|
||
|
||
priv = title_bar->priv;
|
||
|
||
/* Keep a little distance from the navigation arrows. */
|
||
allocation->x += 2;
|
||
|
||
border_width = GTK_CONTAINER (title_bar)->border_width;
|
||
|
||
gtk_widget_get_child_requisition (priv->title_button, &child_requisition);
|
||
child_allocation.x = allocation->x + border_width + offset;
|
||
child_allocation.y = allocation->y + border_width;
|
||
child_allocation.height = allocation->height - 2 * border_width;
|
||
|
||
child_allocation.width = child_requisition.width;
|
||
child_allocation.width += get_max_clipped_label_width (E_CLIPPED_LABEL (priv->title_button_label));
|
||
|
||
child_allocation.width = MIN (child_allocation.width, *available_width_inout);
|
||
|
||
gtk_widget_size_allocate (priv->title_button, & child_allocation);
|
||
|
||
*available_width_inout -= child_allocation.width;
|
||
}
|
||
|
||
static int
|
||
size_allocate_navigation_buttons_and_title_icon (EShellFolderTitleBar *title_bar,
|
||
GtkAllocation *allocation)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
GtkRequisition child_requisition;
|
||
GtkAllocation child_allocation;
|
||
int border_width;
|
||
|
||
priv = title_bar->priv;
|
||
|
||
border_width = GTK_CONTAINER (title_bar)->border_width;
|
||
|
||
child_allocation.x = allocation->x + border_width;
|
||
child_allocation.y = allocation->y + border_width;
|
||
child_allocation.height = allocation->height - 2 * border_width;
|
||
|
||
gtk_widget_size_request (priv->back_button, &child_requisition);
|
||
child_allocation.width = child_requisition.width;
|
||
gtk_widget_size_allocate (priv->back_button, &child_allocation);
|
||
|
||
child_allocation.x += child_allocation.width;
|
||
|
||
gtk_widget_size_request (priv->forward_button, &child_requisition);
|
||
child_allocation.width = child_requisition.width;
|
||
gtk_widget_size_allocate (priv->forward_button, &child_allocation);
|
||
|
||
if (! priv->title_clickable) {
|
||
/* Keep a little distance from the navigation arrows. */
|
||
child_allocation.x += child_allocation.width + 5;
|
||
|
||
gtk_widget_size_request (priv->title_icon, &child_requisition);
|
||
child_allocation.width = child_requisition.width;
|
||
gtk_widget_size_allocate (priv->title_icon, &child_allocation);
|
||
}
|
||
|
||
return child_allocation.x + child_allocation.width;
|
||
}
|
||
|
||
static void
|
||
size_allocate_label (EShellFolderTitleBar *title_bar,
|
||
GtkAllocation *allocation,
|
||
int offset,
|
||
int *available_width_inout)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
GtkAllocation child_allocation;
|
||
int border_width;
|
||
|
||
priv = title_bar->priv;
|
||
|
||
border_width = GTK_CONTAINER (title_bar)->border_width;
|
||
|
||
child_allocation.x = allocation->x + border_width + offset;
|
||
child_allocation.y = allocation->y + border_width;
|
||
child_allocation.height = allocation->height - 2 * border_width;
|
||
|
||
child_allocation.width = MIN (get_max_clipped_label_width (E_CLIPPED_LABEL (priv->title_label)),
|
||
*available_width_inout);
|
||
|
||
gtk_widget_size_allocate (priv->title_label, & child_allocation);
|
||
|
||
*available_width_inout -= child_allocation.width;
|
||
}
|
||
|
||
|
||
/* The back/forward navigation buttons. */
|
||
|
||
static void
|
||
back_button_clicked_callback (GtkButton *button,
|
||
void *data)
|
||
{
|
||
EShellFolderTitleBar *folder_title_bar;
|
||
|
||
folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (data);
|
||
|
||
g_signal_emit (folder_title_bar, signals[BACK_CLICKED], 0);
|
||
}
|
||
|
||
static void
|
||
forward_button_clicked_callback (GtkButton *button,
|
||
void *data)
|
||
{
|
||
EShellFolderTitleBar *folder_title_bar;
|
||
|
||
folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (data);
|
||
|
||
g_signal_emit (folder_title_bar, signals[FORWARD_CLICKED], 0);
|
||
}
|
||
|
||
static void
|
||
add_navigation_buttons (EShellFolderTitleBar *folder_title_bar)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
GtkWidget *back_image;
|
||
GtkWidget *forward_image;
|
||
|
||
priv = folder_title_bar->priv;
|
||
|
||
priv->back_button = gtk_button_new ();
|
||
gtk_button_set_relief (GTK_BUTTON (priv->back_button), GTK_RELIEF_NONE);
|
||
GTK_WIDGET_UNSET_FLAGS (priv->back_button, GTK_CAN_FOCUS);
|
||
|
||
back_image = create_image_widget_from_xpm (left_arrow_xpm);
|
||
gtk_container_add (GTK_CONTAINER (priv->back_button), back_image);
|
||
|
||
g_signal_connect (priv->back_button, "clicked",
|
||
G_CALLBACK (back_button_clicked_callback), folder_title_bar);
|
||
|
||
priv->forward_button = gtk_button_new ();
|
||
gtk_button_set_relief (GTK_BUTTON (priv->forward_button), GTK_RELIEF_NONE);
|
||
GTK_WIDGET_UNSET_FLAGS (priv->forward_button, GTK_CAN_FOCUS);
|
||
|
||
forward_image = create_image_widget_from_xpm (right_arrow_xpm);
|
||
gtk_container_add (GTK_CONTAINER (priv->forward_button), forward_image);
|
||
|
||
g_signal_connect (priv->forward_button, "clicked",
|
||
G_CALLBACK (forward_button_clicked_callback), folder_title_bar);
|
||
|
||
gtk_box_pack_start (GTK_BOX (folder_title_bar), priv->back_button, FALSE, FALSE, 0);
|
||
gtk_box_pack_start (GTK_BOX (folder_title_bar), priv->forward_button, FALSE, FALSE, 0);
|
||
|
||
gtk_widget_show_all (priv->back_button);
|
||
gtk_widget_show_all (priv->forward_button);
|
||
}
|
||
|
||
|
||
/* Popup button callback. */
|
||
|
||
static void
|
||
title_button_toggled_cb (GtkToggleButton *title_button,
|
||
void *data)
|
||
{
|
||
EShellFolderTitleBar *folder_title_bar;
|
||
|
||
folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (data);
|
||
g_signal_emit (folder_title_bar, signals[TITLE_TOGGLED], 0,
|
||
gtk_toggle_button_get_active (title_button));
|
||
}
|
||
|
||
|
||
/* GObject methods. */
|
||
|
||
static void
|
||
impl_dispose (GObject *object)
|
||
{
|
||
EShellFolderTitleBar *folder_title_bar;
|
||
EShellFolderTitleBarPrivate *priv;
|
||
|
||
folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (object);
|
||
priv = folder_title_bar->priv;
|
||
|
||
if (priv->icon != NULL) {
|
||
g_object_unref (priv->icon);
|
||
priv->icon = NULL;
|
||
}
|
||
|
||
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
|
||
}
|
||
|
||
static void
|
||
impl_finalize (GObject *object)
|
||
{
|
||
EShellFolderTitleBar *folder_title_bar;
|
||
EShellFolderTitleBarPrivate *priv;
|
||
|
||
folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (object);
|
||
priv = folder_title_bar->priv;
|
||
|
||
g_free (priv);
|
||
|
||
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
|
||
}
|
||
|
||
|
||
/* GTkWidget methods. */
|
||
|
||
static void
|
||
impl_size_allocate (GtkWidget *widget,
|
||
GtkAllocation *allocation)
|
||
{
|
||
EShellFolderTitleBar *title_bar;
|
||
EShellFolderTitleBarPrivate *priv;
|
||
GtkAllocation label_allocation;
|
||
int border_width;
|
||
int available_width;
|
||
int width_before_icon;
|
||
int offset;
|
||
|
||
title_bar = E_SHELL_FOLDER_TITLE_BAR (widget);
|
||
priv = title_bar->priv;
|
||
|
||
border_width = GTK_CONTAINER (widget)->border_width;
|
||
available_width = allocation->width - 2 * border_width;
|
||
|
||
offset = size_allocate_navigation_buttons_and_title_icon (title_bar, allocation);
|
||
available_width -= offset;
|
||
|
||
width_before_icon = available_width;
|
||
|
||
if (priv->title_clickable)
|
||
size_allocate_title_button (title_bar, allocation, offset, & available_width);
|
||
else
|
||
size_allocate_label (title_bar, allocation, offset, & available_width);
|
||
|
||
label_allocation.x = allocation->x + width_before_icon - available_width - border_width + offset;
|
||
label_allocation.y = allocation->y + border_width;
|
||
label_allocation.width = available_width - 2 * border_width;
|
||
label_allocation.height = allocation->height - 2 * border_width;
|
||
|
||
gtk_widget_size_allocate (priv->folder_bar_label, & label_allocation);
|
||
|
||
widget->allocation = *allocation;
|
||
}
|
||
|
||
|
||
static void
|
||
class_init (EShellFolderTitleBarClass *klass)
|
||
{
|
||
GObjectClass *object_class;
|
||
GtkWidgetClass *widget_class;
|
||
|
||
object_class = G_OBJECT_CLASS (klass);
|
||
object_class->dispose = impl_dispose;
|
||
object_class->finalize = impl_finalize;
|
||
|
||
widget_class = GTK_WIDGET_CLASS (klass);
|
||
widget_class->size_allocate = impl_size_allocate;
|
||
|
||
parent_class = g_type_class_ref(PARENT_TYPE);
|
||
|
||
signals[TITLE_TOGGLED]
|
||
= g_signal_new ("title_toggled",
|
||
G_OBJECT_CLASS_TYPE (object_class),
|
||
G_SIGNAL_RUN_FIRST,
|
||
G_STRUCT_OFFSET (EShellFolderTitleBarClass, title_toggled),
|
||
NULL, NULL,
|
||
e_shell_marshal_NONE__BOOL,
|
||
G_TYPE_NONE, 1,
|
||
G_TYPE_BOOLEAN);
|
||
|
||
signals[BACK_CLICKED]
|
||
= g_signal_new ("back_clicked",
|
||
G_OBJECT_CLASS_TYPE (object_class),
|
||
G_SIGNAL_RUN_FIRST,
|
||
G_STRUCT_OFFSET (EShellFolderTitleBarClass, back_clicked),
|
||
NULL, NULL,
|
||
e_shell_marshal_NONE__NONE,
|
||
G_TYPE_NONE, 0);
|
||
|
||
signals[FORWARD_CLICKED]
|
||
= g_signal_new ("forward_clicked",
|
||
G_OBJECT_CLASS_TYPE (object_class),
|
||
G_SIGNAL_RUN_FIRST,
|
||
G_STRUCT_OFFSET (EShellFolderTitleBarClass, forward_clicked),
|
||
NULL, NULL,
|
||
e_shell_marshal_NONE__NONE,
|
||
G_TYPE_NONE, 0);
|
||
}
|
||
|
||
static void
|
||
init (EShellFolderTitleBar *shell_folder_title_bar)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
|
||
priv = g_new (EShellFolderTitleBarPrivate, 1);
|
||
|
||
priv->icon = NULL;
|
||
|
||
priv->title_icon = NULL;
|
||
priv->title_label = NULL;
|
||
|
||
priv->title_button = NULL;
|
||
priv->title_button_icon = NULL;
|
||
priv->title_button_label = NULL;
|
||
priv->title_button_arrow = NULL;
|
||
|
||
priv->folder_bar_label = NULL;
|
||
|
||
priv->back_button = NULL;
|
||
priv->forward_button = NULL;
|
||
|
||
priv->title_clickable = TRUE;
|
||
|
||
shell_folder_title_bar->priv = priv;
|
||
}
|
||
|
||
|
||
/**
|
||
* e_shell_folder_title_bar_construct:
|
||
* @folder_title_bar:
|
||
*
|
||
* Construct the folder title bar widget.
|
||
**/
|
||
void
|
||
e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
GtkWidget *title_button_hbox;
|
||
GtkWidget *widget;
|
||
|
||
g_return_if_fail (folder_title_bar != NULL);
|
||
g_return_if_fail (E_IS_SHELL_FOLDER_TITLE_BAR (folder_title_bar));
|
||
|
||
priv = folder_title_bar->priv;
|
||
widget = GTK_WIDGET (folder_title_bar);
|
||
|
||
priv->title_icon = new_empty_image_widget ();
|
||
gtk_misc_set_alignment (GTK_MISC (priv->title_icon), 1.0, .5);
|
||
gtk_misc_set_padding (GTK_MISC (priv->title_icon), 2, 0);
|
||
gtk_widget_show (priv->title_icon);
|
||
|
||
priv->title_label = e_clipped_label_new ("");
|
||
gtk_misc_set_padding (GTK_MISC (priv->title_label), 0, 0);
|
||
gtk_misc_set_alignment (GTK_MISC (priv->title_label), 0.0, 0.5);
|
||
set_title_bar_label_style (priv->title_label);
|
||
|
||
priv->title_button_label = e_clipped_label_new ("");
|
||
gtk_misc_set_padding (GTK_MISC (priv->title_button_label), 2, 0);
|
||
gtk_misc_set_alignment (GTK_MISC (priv->title_button_label), 0.0, 0.5);
|
||
gtk_widget_show (priv->title_button_label);
|
||
set_title_bar_label_style (priv->title_button_label);
|
||
|
||
priv->folder_bar_label = e_clipped_label_new ("");
|
||
gtk_misc_set_alignment (GTK_MISC (priv->folder_bar_label), 1.0, 0.5);
|
||
gtk_widget_show (priv->folder_bar_label);
|
||
set_title_bar_label_style (priv->folder_bar_label);
|
||
|
||
priv->title_button_icon = new_empty_image_widget ();
|
||
gtk_widget_show (priv->title_button_icon);
|
||
|
||
title_button_hbox = gtk_hbox_new (FALSE, 0);
|
||
gtk_box_pack_start (GTK_BOX (title_button_hbox), priv->title_button_icon,
|
||
FALSE, TRUE, 2);
|
||
gtk_box_pack_start (GTK_BOX (title_button_hbox), priv->title_button_label,
|
||
TRUE, TRUE, 0);
|
||
gtk_box_pack_start (GTK_BOX (title_button_hbox), create_image_widget_from_xpm (down_arrow_xpm),
|
||
FALSE, TRUE, 2);
|
||
gtk_widget_show (title_button_hbox);
|
||
|
||
priv->title_button = gtk_toggle_button_new ();
|
||
gtk_button_set_relief (GTK_BUTTON (priv->title_button), GTK_RELIEF_NONE);
|
||
gtk_container_add (GTK_CONTAINER (priv->title_button), title_button_hbox);
|
||
GTK_WIDGET_UNSET_FLAGS (priv->title_button, GTK_CAN_FOCUS);
|
||
gtk_widget_show (priv->title_button);
|
||
|
||
gtk_container_set_border_width (GTK_CONTAINER (folder_title_bar), 2);
|
||
gtk_box_pack_start (GTK_BOX (folder_title_bar), priv->title_icon, FALSE, TRUE, 0);
|
||
gtk_box_pack_start (GTK_BOX (folder_title_bar), priv->title_label, FALSE, FALSE, 0);
|
||
gtk_box_pack_start (GTK_BOX (folder_title_bar), priv->title_button, FALSE, FALSE, 0);
|
||
gtk_box_pack_start (GTK_BOX (folder_title_bar), priv->folder_bar_label, TRUE, TRUE, 0);
|
||
|
||
/* Make the label have a border as large as the button's.
|
||
FIXME: This is really hackish. The hardcoded numbers should be OK
|
||
as the padding is hardcoded in GtkButton too (see CHILD_SPACING in
|
||
gtkbutton.c). */
|
||
gtk_misc_set_padding (GTK_MISC (priv->title_label),
|
||
GTK_WIDGET (priv->title_button)->style->xthickness,
|
||
GTK_WIDGET (priv->title_button)->style->ythickness + 2);
|
||
|
||
g_signal_connect (priv->title_button, "toggled",
|
||
G_CALLBACK (title_button_toggled_cb), folder_title_bar);
|
||
|
||
add_navigation_buttons (folder_title_bar);
|
||
|
||
e_shell_folder_title_bar_set_title (folder_title_bar, NULL);
|
||
}
|
||
|
||
/**
|
||
* e_shell_folder_title_bar_new:
|
||
* @void:
|
||
*
|
||
* Create a new title bar widget.
|
||
*
|
||
* Return value:
|
||
**/
|
||
GtkWidget *
|
||
e_shell_folder_title_bar_new (void)
|
||
{
|
||
EShellFolderTitleBar *new;
|
||
|
||
new = g_object_new (e_shell_folder_title_bar_get_type (), NULL);
|
||
|
||
e_shell_folder_title_bar_construct (new);
|
||
|
||
return GTK_WIDGET (new);
|
||
}
|
||
|
||
/**
|
||
* e_shell_folder_title_bar_set_title:
|
||
* @folder_title_bar:
|
||
* @title:
|
||
*
|
||
* Set the title for the title bar.
|
||
**/
|
||
void
|
||
e_shell_folder_title_bar_set_title (EShellFolderTitleBar *folder_title_bar,
|
||
const char *title)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
|
||
g_return_if_fail (folder_title_bar != NULL);
|
||
g_return_if_fail (E_IS_SHELL_FOLDER_TITLE_BAR (folder_title_bar));
|
||
|
||
priv = folder_title_bar->priv;
|
||
|
||
if (title == NULL) {
|
||
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->title_button_label), _("(Untitled)"));
|
||
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->title_label), _("(Untitled)"));
|
||
} else {
|
||
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->title_button_label), title);
|
||
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->title_label), title);
|
||
}
|
||
|
||
/* FIXME: There seems to be a bug in EClippedLabel, this is just a workaround. */
|
||
gtk_widget_queue_resize (GTK_WIDGET (folder_title_bar));
|
||
}
|
||
|
||
/**
|
||
* e_shell_folder_title_bar_set_folder_bar_label:
|
||
* @folder_title_bar:
|
||
* @text: Some text to show in the label.
|
||
*
|
||
* Sets the right-justified text label (to the left of the icon) for
|
||
* the title bar.
|
||
**/
|
||
void
|
||
e_shell_folder_title_bar_set_folder_bar_label (EShellFolderTitleBar *folder_title_bar,
|
||
const char *text)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
|
||
g_return_if_fail (folder_title_bar != NULL);
|
||
g_return_if_fail (E_IS_SHELL_FOLDER_TITLE_BAR (folder_title_bar));
|
||
|
||
priv = folder_title_bar->priv;
|
||
|
||
if (text == NULL)
|
||
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->folder_bar_label), "");
|
||
else
|
||
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->folder_bar_label), text);
|
||
|
||
/* FIXME: Might want to set the styles somewhere in here too,
|
||
black text on grey background isn't the best combination */
|
||
|
||
gtk_widget_queue_resize (GTK_WIDGET (folder_title_bar));
|
||
}
|
||
|
||
/**
|
||
* e_shell_folder_title_bar_set_icon:
|
||
* @folder_title_bar:
|
||
* @icon:
|
||
*
|
||
* Set the name of the icon for the title bar.
|
||
**/
|
||
void
|
||
e_shell_folder_title_bar_set_icon (EShellFolderTitleBar *folder_title_bar,
|
||
GdkPixbuf *icon)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
GdkPixmap *pixmap;
|
||
GdkBitmap *mask;
|
||
|
||
g_return_if_fail (folder_title_bar != NULL);
|
||
g_return_if_fail (E_IS_SHELL_FOLDER_TITLE_BAR (folder_title_bar));
|
||
|
||
priv = folder_title_bar->priv;
|
||
|
||
if (icon == NULL) {
|
||
if (priv->icon != NULL)
|
||
g_object_unref (priv->icon);
|
||
priv->icon = new_empty_pixbuf ();
|
||
} else {
|
||
g_object_ref (icon);
|
||
if (priv->icon != NULL)
|
||
g_object_unref (priv->icon);
|
||
priv->icon = icon;
|
||
}
|
||
|
||
gdk_pixbuf_render_pixmap_and_mask (priv->icon, &pixmap, &mask, 127);
|
||
gtk_image_set_from_pixmap (GTK_IMAGE (priv->title_button_icon), pixmap, mask);
|
||
|
||
gdk_pixbuf_render_pixmap_and_mask (priv->icon, &pixmap, &mask, 127);
|
||
gtk_image_set_from_pixmap (GTK_IMAGE (priv->title_icon), pixmap, mask);
|
||
}
|
||
|
||
|
||
/**
|
||
* e_shell_folder_title_bar_set_toggle_state:
|
||
* @folder_title_bar:
|
||
* @state:
|
||
*
|
||
* Set whether the title bar's button is in pressed state (TRUE) or not (FALSE).
|
||
**/
|
||
void
|
||
e_shell_folder_title_bar_set_toggle_state (EShellFolderTitleBar *folder_title_bar,
|
||
gboolean state)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
|
||
g_return_if_fail (folder_title_bar != NULL);
|
||
g_return_if_fail (E_IS_SHELL_FOLDER_TITLE_BAR (folder_title_bar));
|
||
|
||
priv = folder_title_bar->priv;
|
||
|
||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->title_button), state);
|
||
}
|
||
|
||
/**
|
||
* e_shell_folder_title_bar_set_clickable:
|
||
* @folder_title_bar:
|
||
* @clickable:
|
||
*
|
||
* Specify whether the title in the @folder_title_bar is clickable. If not,
|
||
* the arrow pixmap is not shown.
|
||
**/
|
||
void
|
||
e_shell_folder_title_bar_set_title_clickable (EShellFolderTitleBar *folder_title_bar,
|
||
gboolean title_clickable)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
|
||
g_return_if_fail (folder_title_bar != NULL);
|
||
g_return_if_fail (E_IS_SHELL_FOLDER_TITLE_BAR (folder_title_bar));
|
||
|
||
priv = folder_title_bar->priv;
|
||
|
||
if ((priv->title_clickable && title_clickable)
|
||
|| (! priv->title_clickable && ! title_clickable))
|
||
return;
|
||
|
||
if (title_clickable) {
|
||
gtk_widget_hide (priv->title_label);
|
||
gtk_widget_hide (priv->title_icon);
|
||
|
||
gtk_widget_show_all (priv->title_button);
|
||
} else {
|
||
gtk_widget_hide (priv->title_button);
|
||
|
||
gtk_widget_show (priv->title_icon);
|
||
gtk_widget_show (priv->title_label);
|
||
}
|
||
|
||
priv->title_clickable = !! title_clickable;
|
||
}
|
||
|
||
|
||
void
|
||
e_shell_folder_title_bar_update_navigation_buttons (EShellFolderTitleBar *folder_title_bar,
|
||
gboolean can_go_back,
|
||
gboolean can_go_forward)
|
||
{
|
||
EShellFolderTitleBarPrivate *priv;
|
||
|
||
g_return_if_fail (folder_title_bar != NULL);
|
||
g_return_if_fail (E_IS_SHELL_FOLDER_TITLE_BAR (folder_title_bar));
|
||
|
||
priv = folder_title_bar->priv;
|
||
|
||
gtk_widget_set_sensitive (priv->back_button, can_go_back);
|
||
gtk_widget_set_sensitive (priv->forward_button, can_go_forward);
|
||
}
|
||
|
||
|
||
E_MAKE_TYPE (e_shell_folder_title_bar, "EShellFolderTitleBar", EShellFolderTitleBar, class_init, init, PARENT_TYPE)
|