From e0c501b7018f12d37b10e32923f95b7a01c7982c Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 29 Aug 2008 22:32:46 +0000 Subject: Progress update: - Contacts module partially working! - Implement UI merging. Also merge EInfoLabel into ESidebar. The shell window now manages the icon and labels and keeps them up-to-date via EShellView properties. svn path=/branches/kill-bonobo/; revision=36214 --- widgets/misc/Makefile.am | 15 +-- widgets/misc/e-info-label.c | 245 ------------------------------------ widgets/misc/e-info-label.h | 57 --------- widgets/misc/e-preferences-window.c | 6 +- widgets/misc/e-preferences-window.h | 4 +- widgets/misc/test-info-label.c | 76 ----------- 6 files changed, 7 insertions(+), 396 deletions(-) delete mode 100644 widgets/misc/e-info-label.c delete mode 100644 widgets/misc/e-info-label.h delete mode 100644 widgets/misc/test-info-label.c (limited to 'widgets/misc') diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am index 2365fe668d..a59e16a811 100644 --- a/widgets/misc/Makefile.am +++ b/widgets/misc/Makefile.am @@ -52,7 +52,6 @@ widgetsinclude_HEADERS = \ e-expander.h \ e-icon-entry.h \ e-image-chooser.h \ - e-info-label.h \ e-map.h \ e-menu-tool-button.h \ e-preferences-window.h \ @@ -99,7 +98,6 @@ libemiscwidgets_la_SOURCES = \ e-expander.c \ e-icon-entry.c \ e-image-chooser.c \ - e-info-label.c \ e-map.c \ e-menu-tool-button.c \ e-preferences-window.c \ @@ -156,8 +154,7 @@ noinst_PROGRAMS = \ test-calendar \ test-dateedit \ test-dropdown-button \ - test-preferences-window \ - test-info-label + test-preferences-window # test-calendar @@ -199,16 +196,6 @@ test_preferences_window_LDADD = \ $(top_builddir)/e-util/libeutil.la \ $(E_WIDGETS_LIBS) -# test-info-label - -test_info_label_SOURCES = \ - test-info-label.c - -test_info_label_LDADD = \ - libemiscwidgets.la \ - $(top_builddir)/e-util/libeutil.la \ - $(E_WIDGETS_LIBS) - EXTRA_DIST = \ $(glade_DATA) \ diff --git a/widgets/misc/e-info-label.c b/widgets/misc/e-info-label.c deleted file mode 100644 index 4c3c04069f..0000000000 --- a/widgets/misc/e-info-label.c +++ /dev/null @@ -1,245 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "e-info-label.h" - -static GtkHBoxClass *el_parent; - -static void -el_init(GObject *o) -{ - /*EInfoLabel *el = (EInfoLabel *)o;*/ -} - -static void -el_finalise(GObject *o) -{ - ((GObjectClass *)el_parent)->finalize(o); -} - -static void -el_destroy (GtkObject *o) -{ - ((EInfoLabel *)o)->location = NULL; - ((EInfoLabel *)o)->info = NULL; - - ((GtkObjectClass *)el_parent)->destroy(o); -} - -static int -el_expose_event(GtkWidget *w, GdkEventExpose *event) -{ - int x = ((GtkContainer *)w)->border_width; - - /* This seems a hack to me, but playing with styles wouldn't affect the background */ - gtk_paint_flat_box(w->style, w->window, - GTK_STATE_ACTIVE, GTK_SHADOW_NONE, - &event->area, w, "EInfoLabel", - w->allocation.x+x, w->allocation.y+x, - w->allocation.width-x*2, w->allocation.height-x*2); - - return ((GtkWidgetClass *)el_parent)->expose_event(w, event); -} - -static int -get_text_full_width (GtkWidget *label) -{ - PangoLayout *layout; - PangoRectangle rect; - int width; - - g_return_val_if_fail (GTK_IS_LABEL (label), 0); - - layout = gtk_label_get_layout (GTK_LABEL (label)); - - if (!layout) - return 0; - - width = pango_layout_get_width (layout); - pango_layout_set_width (layout, -1); - pango_layout_get_extents (layout, NULL, &rect); - pango_layout_set_width (layout, width); - - return PANGO_PIXELS (rect.width); -} - -static void -el_size_allocate (GtkWidget *widget, GtkAllocation *pallocation) -{ - EInfoLabel *el; - GtkAllocation allocation; - int full_loc, full_nfo; - gint diff; - - /* let calculate parent class first, and then just make it not divide evenly */ - ((GtkWidgetClass *)el_parent)->size_allocate (widget, pallocation); - - g_return_if_fail (widget!= NULL); - - el = (EInfoLabel*) widget; - - if (!el->location) - return; - - full_loc = get_text_full_width (el->location) + 1; - full_nfo = get_text_full_width (el->info) + 1; - - /* do not know the width of text, thus return */ - if (full_loc == 1 && full_nfo == 1) - return; - - if (el->location->allocation.width + el->info->allocation.width >= full_loc + full_nfo) { - /* allocate for location only as many pixels as it requires to not ellipsize - and keep rest for the info part */ - diff = el->location->allocation.width - full_loc; - } else { - /* make both shorter, but based on the ratio of its full widths */ - gint total_have = el->location->allocation.width + el->info->allocation.width; - gint total_full = full_loc + full_nfo; - - diff = el->location->allocation.width - full_loc * total_have / total_full; - } - - if (!diff) - return; - - allocation = el->location->allocation; - allocation.width -= diff; - gtk_widget_size_allocate (el->location, &allocation); - - allocation = el->info->allocation; - allocation.x -= diff; - allocation.width += diff; - gtk_widget_size_allocate (el->info, &allocation); -} - -static void -el_class_init(GObjectClass *klass) -{ - klass->finalize = el_finalise; - - ((GtkObjectClass *)klass)->destroy = el_destroy; - ((GtkWidgetClass *)klass)->expose_event = el_expose_event; - ((GtkWidgetClass *)klass)->size_allocate = el_size_allocate; -} - -GType -e_info_label_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EInfoLabelClass), - NULL, NULL, - (GClassInitFunc)el_class_init, - NULL, NULL, - sizeof(EInfoLabel), 0, - (GInstanceInitFunc)el_init - }; - el_parent = g_type_class_ref(gtk_hbox_get_type()); - type = g_type_register_static(gtk_hbox_get_type(), "EInfoLabel", &info, 0); - } - - return type; -} - -/** - * e_info_label_new: - * @icon: - * - * Create a new info label widget. @icon is the name of the icon - * (from the icon theme) to use for the icon image. - * - * Return value: - **/ -GtkWidget * -e_info_label_new(const char *icon) -{ - EInfoLabel *el = g_object_new(e_info_label_get_type(), NULL); - GtkWidget *image; - - image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU); - gtk_misc_set_padding((GtkMisc *)image, 6, 6); - gtk_box_pack_start((GtkBox *)el, image, FALSE, TRUE, 0); - gtk_widget_show(image); - - gtk_container_set_border_width((GtkContainer *)el, 3); - - return (GtkWidget *)el; -} - -/** - * e_info_label_set_info: - * @el: - * @location: - * @info: - * - * Set the information to show on the label. @location is some - * context about the current view. e.g. the folder name. If the - * label is too wide, this will be truncated. - * - * @info is some info about this location. - **/ -void -e_info_label_set_info(EInfoLabel *el, const char *location, const char *info) -{ - gchar *markup; - - if (el->location == NULL) { - el->location = gtk_label_new (NULL); - el->info = gtk_label_new (NULL); - - gtk_label_set_ellipsize (GTK_LABEL (el->location), PANGO_ELLIPSIZE_END); - gtk_misc_set_alignment (GTK_MISC (el->location), 0.0, 0.0); - gtk_misc_set_padding (GTK_MISC (el->location), 0, 6); - - gtk_label_set_ellipsize (GTK_LABEL (el->info), PANGO_ELLIPSIZE_MIDDLE); - gtk_misc_set_alignment (GTK_MISC (el->info), 1.0, 1.0); - gtk_misc_set_padding (GTK_MISC (el->info), 0, 6); - - gtk_widget_show (el->location); - gtk_widget_show (el->info); - - gtk_box_pack_start ( - GTK_BOX (el), GTK_WIDGET (el->location), - TRUE, TRUE, 0); - gtk_box_pack_end ( - GTK_BOX (el), GTK_WIDGET (el->info), - TRUE, TRUE, 6); - gtk_widget_set_state (GTK_WIDGET (el), GTK_STATE_ACTIVE); - } - - markup = g_markup_printf_escaped ("%s", location); - gtk_label_set_markup (GTK_LABEL (el->location), markup); - g_free (markup); - - markup = g_markup_printf_escaped ("%s", info); - gtk_label_set_markup (GTK_LABEL (el->info), markup); - g_free (markup); -} - diff --git a/widgets/misc/e-info-label.h b/widgets/misc/e-info-label.h deleted file mode 100644 index 7122138cf8..0000000000 --- a/widgets/misc/e-info-label.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * - * Authors: Michael Zucchi - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef _E_INFO_LABEL_H -#define _E_INFO_LABEL_H - -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_INFO_LABEL_GET_CLASS(emfv) ((EInfoLabelClass *) G_OBJECT_GET_CLASS (emfv)) - -typedef struct _EInfoLabel EInfoLabel; -typedef struct _EInfoLabelClass EInfoLabelClass; - -struct _EInfoLabel { - GtkHBox parent; - - struct _GtkWidget *location; - struct _GtkWidget *info; -}; - -struct _EInfoLabelClass { - GtkHBoxClass parent_class; -}; - -GType e_info_label_get_type(void); - -GtkWidget *e_info_label_new(const char *icon); -void e_info_label_set_info(EInfoLabel *, const char *loc, const char *info); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* ! _E_INFO_LABEL_H */ diff --git a/widgets/misc/e-preferences-window.c b/widgets/misc/e-preferences-window.c index 883d6df280..988d065d76 100644 --- a/widgets/misc/e-preferences-window.c +++ b/widgets/misc/e-preferences-window.c @@ -303,8 +303,8 @@ e_preferences_window_add_page (EPreferencesWindow *dialog, const gchar *page_name, const gchar *icon_name, const gchar *caption, - gint sort_order, - GtkWidget *widget) + GtkWidget *widget, + gint sort_order) { GtkTreeRowReference *reference; GtkIconView *icon_view; @@ -346,6 +346,8 @@ e_preferences_window_add_page (EPreferencesWindow *dialog, if (page == 0) e_preferences_window_show_page (dialog, page_name); + + gtk_widget_queue_resize (GTK_WIDGET (dialog)); } void diff --git a/widgets/misc/e-preferences-window.h b/widgets/misc/e-preferences-window.h index 133bf8cdb3..379d41a977 100644 --- a/widgets/misc/e-preferences-window.h +++ b/widgets/misc/e-preferences-window.h @@ -63,8 +63,8 @@ void e_preferences_window_add_page (EPreferencesWindow *window, const gchar *page_name, const gchar *icon_name, const gchar *caption, - gint sort_order, - GtkWidget *widget); + GtkWidget *widget, + gint sort_order); void e_preferences_window_show_page (EPreferencesWindow *window, const gchar *page_name); diff --git a/widgets/misc/test-info-label.c b/widgets/misc/test-info-label.c deleted file mode 100644 index 890dfc2082..0000000000 --- a/widgets/misc/test-info-label.c +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-title-bar.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include "e-info-label.h" - -static void -delete_event_cb (GtkWidget *widget, - GdkEventAny *event, - gpointer data) -{ - gtk_main_quit (); -} - -int -main (int argc, char **argv) -{ - GtkWidget *app; - GtkWidget *info_label; - GtkWidget *label; - GtkWidget *vbox; - - gnome_program_init ( - "test-title-bar", "0.0", LIBGNOMEUI_MODULE, - argc, argv, GNOME_PARAM_NONE); - - app = gnome_app_new ("Test", "Test"); - gtk_window_set_default_size (GTK_WINDOW (app), 400, 400); - gtk_window_set_resizable (GTK_WINDOW (app), TRUE); - - g_signal_connect (app, "delete_event", G_CALLBACK (delete_event_cb), NULL); - - info_label = e_info_label_new ("stock_default-folder"); - e_info_label_set_info ((EInfoLabel *) info_label, "Component Name", "An annoyingly long component message"); - gtk_widget_show (info_label); - - label = gtk_label_new ("boo"); - gtk_widget_show (label); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), info_label, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - gnome_app_set_contents (GNOME_APP (app), vbox); - gtk_widget_show (app); - - gtk_main (); - - return 0; -} -- cgit v1.2.3