Add support for boundary offset and extra width and height.

* libnautilus-extensions/nautilus-graphic.c:
	(nautilus_graphic_initialize), (nautilus_graphic_size_allocate),
	(nautilus_graphic_size_request), (nautilus_graphic_set_label_text),
	(nautilus_graphic_set_label_font),
	(nautilus_graphic_set_left_offset),
	(nautilus_graphic_set_right_offset),
	(nautilus_graphic_set_top_offset),
	(nautilus_graphic_set_bottom_offset),
	(nautilus_graphic_set_extra_width),
	(nautilus_graphic_set_extra_height):
	* libnautilus-extensions/nautilus-graphic.h:
	Add support for boundary offset and extra width and height.

	* test/test-nautilus-graphic.c: (main):
	Update for new boundary offset support.

	components/services/install/nautilus-view/nautilus-service-install-
	view.c: (generate_install_form), (create_graphic_widget),
	(create_title_widget):
	* components/services/login/nautilus-view/nautilus-login-view.c:
	(generate_login_form), (create_graphic_widget),
	(create_title_widget):
	Use new graphic widget to make things prettier.
This commit is contained in:
Ramiro Estrugo 2000-07-10 23:31:37 +00:00
parent 5a7cda2daa
commit af7bd12d44
8 changed files with 568 additions and 141 deletions

View file

@ -38,6 +38,8 @@
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-string.h>
#include <libnautilus-extensions/nautilus-font-factory.h>
#include <libnautilus-extensions/nautilus-graphic.h>
#include <libnautilus-extensions/nautilus-gdk-extensions.h>
#include <stdio.h>
#include <fcntl.h>
#include <dirent.h>
@ -48,23 +50,24 @@
#define SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR "rgb:FFFF/FFFF/FFFF"
#define SERVICE_DOMAIN_NAME "testmachine.eazel.com"
static void nautilus_service_install_view_initialize_class (NautilusServiceInstallViewClass *klass);
static void nautilus_service_install_view_initialize (NautilusServiceInstallView *view);
static void nautilus_service_install_view_destroy (GtkObject *object);
static void service_install_load_location_callback (NautilusView *nautilus_view,
const char *location,
NautilusServiceInstallView *view);
static void generate_install_form (NautilusServiceInstallView *view);
static void generate_form_title (NautilusServiceInstallView *view,
const char *title_text);
static void fake_overall_install_progress (NautilusServiceInstallView *view);
static void generate_current_progress (NautilusServiceInstallView *view,
char *progress_message);
static void nautilus_service_install_view_update_from_uri (NautilusServiceInstallView *view,
const char *uri);
static void show_overall_feedback (NautilusServiceInstallView *view,
char *progress_message);
static void nautilus_service_install_view_initialize_class (NautilusServiceInstallViewClass *klass);
static void nautilus_service_install_view_initialize (NautilusServiceInstallView *view);
static void nautilus_service_install_view_destroy (GtkObject *object);
static void service_install_load_location_callback (NautilusView *nautilus_view,
const char *location,
NautilusServiceInstallView *view);
static void generate_install_form (NautilusServiceInstallView *view);
static void fake_overall_install_progress (NautilusServiceInstallView *view);
static void generate_current_progress (NautilusServiceInstallView *view,
char *progress_message);
static void nautilus_service_install_view_update_from_uri (NautilusServiceInstallView *view,
const char *uri);
static void show_overall_feedback (NautilusServiceInstallView *view,
char *progress_message);
static GtkWidget* create_title_widget (const char *title_text);
static GtkWidget* create_graphic_widget (const char *icon_name,
const char *background_color_spec,
NautilusGraphicPlacementType placement);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusServiceInstallView, nautilus_service_install_view, GTK_TYPE_EVENT_BOX)
@ -73,14 +76,18 @@ generate_install_form (NautilusServiceInstallView *view) {
GdkFont *font;
GtkWidget *temp_box;
GtkWidget *title;
/* allocate the parent box to hold everything */
view->details->form = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (view), view->details->form);
gtk_widget_show (view->details->form);
/* setup the title */
generate_form_title (view, "Easy Install");
/* Setup the title */
title = create_title_widget ("Easy Install");
gtk_box_pack_start (GTK_BOX (view->details->form), title, FALSE, FALSE, 0);
gtk_widget_show (title);
/* Add package information */
@ -159,34 +166,91 @@ generate_install_form (NautilusServiceInstallView *view) {
}
static void
generate_form_title (NautilusServiceInstallView *view,
const char *title_text) {
static GtkWidget*
create_graphic_widget (const char *icon_name,
const char *background_color_spec,
NautilusGraphicPlacementType placement)
{
char *path;
GtkWidget *graphic;
GdkPixbuf *pixbuf;
guint32 background_rgb;
GtkWidget *temp_widget;
char *file_name;
GtkWidget *temp_container;
GdkFont *font;
g_return_val_if_fail (icon_name != NULL, NULL);
g_return_val_if_fail (background_color_spec != NULL, NULL);
temp_container = gtk_hbox_new (FALSE, 0);
graphic = nautilus_graphic_new();
path = nautilus_pixmap_file (icon_name);
pixbuf = gdk_pixbuf_new_from_file (path);
g_free (path);
gtk_box_pack_start (GTK_BOX (view->details->form), temp_container, 0, 0, 4);
gtk_widget_show (temp_container);
if (pixbuf != NULL) {
nautilus_graphic_set_pixbuf (NAUTILUS_GRAPHIC (graphic), pixbuf);
gdk_pixbuf_unref (pixbuf);
}
else {
g_warning ("Could not find the requested icon.");
}
nautilus_graphic_set_background_type (NAUTILUS_GRAPHIC (graphic),
NAUTILUS_GRAPHIC_BACKGROUND_SOLID);
background_rgb = nautilus_parse_rgb_with_white_default (background_color_spec);
nautilus_graphic_set_background_color (NAUTILUS_GRAPHIC (graphic),
background_rgb);
file_name = nautilus_pixmap_file ("eazel-cloud-logo.png");
temp_widget = GTK_WIDGET (gnome_pixmap_new_from_file (file_name));
gtk_box_pack_start (GTK_BOX(temp_container), temp_widget, 0, 0, 8);
gtk_widget_show (temp_widget);
g_free (file_name);
nautilus_graphic_set_placement_type (NAUTILUS_GRAPHIC (graphic), placement);
view->details->form_title = gtk_label_new (title_text);
return graphic;
}
font = nautilus_font_factory_get_font_from_preferences (21);
nautilus_gtk_widget_set_font (view->details->form_title, font);
gdk_font_unref (font);
static GtkWidget*
create_title_widget (const char *title_text)
{
GtkWidget *title_hbox;
GtkWidget *logo_graphic;
GtkWidget *filler_graphic;
GtkWidget *text_graphic;
GdkFont *font;
gtk_box_pack_start (GTK_BOX (temp_container), view->details->form_title, 0, 0, 8);
gtk_widget_show (view->details->form_title);
g_assert (title_text != NULL);
title_hbox = gtk_hbox_new (FALSE, 0);
logo_graphic = create_graphic_widget ("eazel-services-logo.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_GRAPHIC_PLACEMENT_CENTER);
filler_graphic = create_graphic_widget ("eazel-services-logo-tile.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_GRAPHIC_PLACEMENT_TILE);
text_graphic = create_graphic_widget ("eazel-services-logo-tile.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_GRAPHIC_PLACEMENT_TILE);
font = nautilus_font_factory_get_font_by_family ("helvetica", 20);
nautilus_graphic_set_label_text (NAUTILUS_GRAPHIC (text_graphic), title_text);
nautilus_graphic_set_label_font (NAUTILUS_GRAPHIC (text_graphic), font);
nautilus_graphic_set_extra_width (NAUTILUS_GRAPHIC (text_graphic), 8);
nautilus_graphic_set_right_offset (NAUTILUS_GRAPHIC (text_graphic), 8);
nautilus_graphic_set_top_offset (NAUTILUS_GRAPHIC (text_graphic), 3);
gdk_font_unref (font);
gtk_widget_show (logo_graphic);
gtk_widget_show (filler_graphic);
gtk_widget_show (text_graphic);
gtk_box_pack_start (GTK_BOX (title_hbox), logo_graphic, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (title_hbox), filler_graphic, TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (title_hbox), text_graphic, FALSE, FALSE, 0);
return title_hbox;
}
static void

View file

@ -38,6 +38,8 @@
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-string.h>
#include <libnautilus-extensions/nautilus-font-factory.h>
#include <libnautilus-extensions/nautilus-graphic.h>
#include <libnautilus-extensions/nautilus-gdk-extensions.h>
#include <stdio.h>
#include <fcntl.h>
#include <dirent.h>
@ -48,23 +50,24 @@
#define SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR "rgb:FFFF/FFFF/FFFF"
#define SERVICE_DOMAIN_NAME "testmachine.eazel.com"
static void nautilus_service_install_view_initialize_class (NautilusServiceInstallViewClass *klass);
static void nautilus_service_install_view_initialize (NautilusServiceInstallView *view);
static void nautilus_service_install_view_destroy (GtkObject *object);
static void service_install_load_location_callback (NautilusView *nautilus_view,
const char *location,
NautilusServiceInstallView *view);
static void generate_install_form (NautilusServiceInstallView *view);
static void generate_form_title (NautilusServiceInstallView *view,
const char *title_text);
static void fake_overall_install_progress (NautilusServiceInstallView *view);
static void generate_current_progress (NautilusServiceInstallView *view,
char *progress_message);
static void nautilus_service_install_view_update_from_uri (NautilusServiceInstallView *view,
const char *uri);
static void show_overall_feedback (NautilusServiceInstallView *view,
char *progress_message);
static void nautilus_service_install_view_initialize_class (NautilusServiceInstallViewClass *klass);
static void nautilus_service_install_view_initialize (NautilusServiceInstallView *view);
static void nautilus_service_install_view_destroy (GtkObject *object);
static void service_install_load_location_callback (NautilusView *nautilus_view,
const char *location,
NautilusServiceInstallView *view);
static void generate_install_form (NautilusServiceInstallView *view);
static void fake_overall_install_progress (NautilusServiceInstallView *view);
static void generate_current_progress (NautilusServiceInstallView *view,
char *progress_message);
static void nautilus_service_install_view_update_from_uri (NautilusServiceInstallView *view,
const char *uri);
static void show_overall_feedback (NautilusServiceInstallView *view,
char *progress_message);
static GtkWidget* create_title_widget (const char *title_text);
static GtkWidget* create_graphic_widget (const char *icon_name,
const char *background_color_spec,
NautilusGraphicPlacementType placement);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusServiceInstallView, nautilus_service_install_view, GTK_TYPE_EVENT_BOX)
@ -73,14 +76,18 @@ generate_install_form (NautilusServiceInstallView *view) {
GdkFont *font;
GtkWidget *temp_box;
GtkWidget *title;
/* allocate the parent box to hold everything */
view->details->form = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (view), view->details->form);
gtk_widget_show (view->details->form);
/* setup the title */
generate_form_title (view, "Easy Install");
/* Setup the title */
title = create_title_widget ("Easy Install");
gtk_box_pack_start (GTK_BOX (view->details->form), title, FALSE, FALSE, 0);
gtk_widget_show (title);
/* Add package information */
@ -159,34 +166,91 @@ generate_install_form (NautilusServiceInstallView *view) {
}
static void
generate_form_title (NautilusServiceInstallView *view,
const char *title_text) {
static GtkWidget*
create_graphic_widget (const char *icon_name,
const char *background_color_spec,
NautilusGraphicPlacementType placement)
{
char *path;
GtkWidget *graphic;
GdkPixbuf *pixbuf;
guint32 background_rgb;
GtkWidget *temp_widget;
char *file_name;
GtkWidget *temp_container;
GdkFont *font;
g_return_val_if_fail (icon_name != NULL, NULL);
g_return_val_if_fail (background_color_spec != NULL, NULL);
temp_container = gtk_hbox_new (FALSE, 0);
graphic = nautilus_graphic_new();
path = nautilus_pixmap_file (icon_name);
pixbuf = gdk_pixbuf_new_from_file (path);
g_free (path);
gtk_box_pack_start (GTK_BOX (view->details->form), temp_container, 0, 0, 4);
gtk_widget_show (temp_container);
if (pixbuf != NULL) {
nautilus_graphic_set_pixbuf (NAUTILUS_GRAPHIC (graphic), pixbuf);
gdk_pixbuf_unref (pixbuf);
}
else {
g_warning ("Could not find the requested icon.");
}
nautilus_graphic_set_background_type (NAUTILUS_GRAPHIC (graphic),
NAUTILUS_GRAPHIC_BACKGROUND_SOLID);
background_rgb = nautilus_parse_rgb_with_white_default (background_color_spec);
nautilus_graphic_set_background_color (NAUTILUS_GRAPHIC (graphic),
background_rgb);
file_name = nautilus_pixmap_file ("eazel-cloud-logo.png");
temp_widget = GTK_WIDGET (gnome_pixmap_new_from_file (file_name));
gtk_box_pack_start (GTK_BOX(temp_container), temp_widget, 0, 0, 8);
gtk_widget_show (temp_widget);
g_free (file_name);
nautilus_graphic_set_placement_type (NAUTILUS_GRAPHIC (graphic), placement);
view->details->form_title = gtk_label_new (title_text);
return graphic;
}
font = nautilus_font_factory_get_font_from_preferences (21);
nautilus_gtk_widget_set_font (view->details->form_title, font);
gdk_font_unref (font);
static GtkWidget*
create_title_widget (const char *title_text)
{
GtkWidget *title_hbox;
GtkWidget *logo_graphic;
GtkWidget *filler_graphic;
GtkWidget *text_graphic;
GdkFont *font;
gtk_box_pack_start (GTK_BOX (temp_container), view->details->form_title, 0, 0, 8);
gtk_widget_show (view->details->form_title);
g_assert (title_text != NULL);
title_hbox = gtk_hbox_new (FALSE, 0);
logo_graphic = create_graphic_widget ("eazel-services-logo.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_GRAPHIC_PLACEMENT_CENTER);
filler_graphic = create_graphic_widget ("eazel-services-logo-tile.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_GRAPHIC_PLACEMENT_TILE);
text_graphic = create_graphic_widget ("eazel-services-logo-tile.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_GRAPHIC_PLACEMENT_TILE);
font = nautilus_font_factory_get_font_by_family ("helvetica", 20);
nautilus_graphic_set_label_text (NAUTILUS_GRAPHIC (text_graphic), title_text);
nautilus_graphic_set_label_font (NAUTILUS_GRAPHIC (text_graphic), font);
nautilus_graphic_set_extra_width (NAUTILUS_GRAPHIC (text_graphic), 8);
nautilus_graphic_set_right_offset (NAUTILUS_GRAPHIC (text_graphic), 8);
nautilus_graphic_set_top_offset (NAUTILUS_GRAPHIC (text_graphic), 3);
gdk_font_unref (font);
gtk_widget_show (logo_graphic);
gtk_widget_show (filler_graphic);
gtk_widget_show (text_graphic);
gtk_box_pack_start (GTK_BOX (title_hbox), logo_graphic, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (title_hbox), filler_graphic, TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (title_hbox), text_graphic, FALSE, FALSE, 0);
return title_hbox;
}
static void

View file

@ -35,6 +35,8 @@
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-string.h>
#include <libnautilus-extensions/nautilus-font-factory.h>
#include <libnautilus-extensions/nautilus-graphic.h>
#include <libnautilus-extensions/nautilus-gdk-extensions.h>
#include <stdio.h>
#include <unistd.h>
@ -60,24 +62,27 @@ struct _NautilusLoginViewDetails {
#define SERVICE_SUMMARY_LOCATION "eazel:summary"
#define SERVICE_HELP_LOCATION "http://www.eazel.com"
static void nautilus_login_view_initialize_class (NautilusLoginViewClass *klass);
static void nautilus_login_view_initialize (NautilusLoginView *view);
static void nautilus_login_view_destroy (GtkObject *object);
static void login_load_location_callback (NautilusView *nautilus_view,
const char *location,
NautilusLoginView *view);
static void show_feedback (NautilusLoginView *view,
char *error_message);
static void generate_login_form (NautilusLoginView *view);
static void entry_changed_cb (GtkWidget *entry,
NautilusLoginView *view);
static void login_button_cb (GtkWidget *button,
NautilusLoginView *view);
static void maintenance_button_cb (GtkWidget *button,
NautilusLoginView *view);
static void generate_form_title (NautilusLoginView *view,
const char *title_text);
static void go_to_uri (NautilusLoginView *view, char *uri);
static void nautilus_login_view_initialize_class (NautilusLoginViewClass *klass);
static void nautilus_login_view_initialize (NautilusLoginView *view);
static void nautilus_login_view_destroy (GtkObject *object);
static void login_load_location_callback (NautilusView *nautilus_view,
const char *location,
NautilusLoginView *view);
static void show_feedback (NautilusLoginView *view,
char *error_message);
static void generate_login_form (NautilusLoginView *view);
static void entry_changed_cb (GtkWidget *entry,
NautilusLoginView *view);
static void login_button_cb (GtkWidget *button,
NautilusLoginView *view);
static void maintenance_button_cb (GtkWidget *button,
NautilusLoginView *view);
static void go_to_uri (NautilusLoginView *view,
char *uri);
static GtkWidget* create_title_widget (const char *title_text);
static GtkWidget* create_graphic_widget (const char *icon_name,
const char *background_color_spec,
NautilusGraphicPlacementType placement);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusLoginView, nautilus_login_view, GTK_TYPE_EVENT_BOX)
@ -91,14 +96,18 @@ generate_login_form (NautilusLoginView *view) {
GtkWidget *maintenance_button;
GtkWidget *maintenance_label;
GdkFont *font;
GtkWidget *title;
/* allocate a box to hold everything */
view->details->form = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (view), view->details->form);
gtk_widget_show (view->details->form);
/* setup the title */
generate_form_title (view, "Please Sign in! ");
/* Setup the title */
title = create_title_widget ("Please Sign in!");
gtk_box_pack_start (GTK_BOX (view->details->form), title, FALSE, FALSE, 0);
gtk_widget_show (title);
/* initialize the parent form */
temp_box = gtk_hbox_new (FALSE, 4);
@ -246,37 +255,6 @@ go_to_uri (NautilusLoginView *view, char *uri) {
}
static void
generate_form_title (NautilusLoginView *view,
const char *title_text) {
GtkWidget *temp_widget;
char *file_name;
GtkWidget *temp_container;
GdkFont *font;
temp_container = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (view->details->form), temp_container, 0, 0, 4);
gtk_widget_show (temp_container);
file_name = nautilus_pixmap_file ("eazel-cloud-logo.png");
temp_widget = GTK_WIDGET (gnome_pixmap_new_from_file (file_name));
gtk_box_pack_start (GTK_BOX(temp_container), temp_widget, 0, 0, 8);
gtk_widget_show (temp_widget);
g_free (file_name);
view->details->form_title = gtk_label_new (title_text);
font = nautilus_font_factory_get_font_from_preferences (20);
nautilus_gtk_widget_set_font (view->details->form_title, font);
gdk_font_unref (font);
gtk_box_pack_end (GTK_BOX (temp_container), view->details->form_title, 0, 0, 8);
gtk_widget_show (view->details->form_title);
}
static void
nautilus_login_view_initialize_class (NautilusLoginViewClass *klass) {
@ -360,3 +338,94 @@ login_load_location_callback (NautilusView *nautilus_view,
nautilus_view_report_load_complete (nautilus_view);
}
/* FIXME bugzilla.eazel.com xxxx:
* create_graphic_widget() and create_title_widget() are cut-n-pasted from
* components/services/install/nautilus-view/nautilus-service-install-view.c
* These should be put in a common place.
*/
static GtkWidget*
create_graphic_widget (const char *icon_name,
const char *background_color_spec,
NautilusGraphicPlacementType placement)
{
char *path;
GtkWidget *graphic;
GdkPixbuf *pixbuf;
guint32 background_rgb;
g_return_val_if_fail (icon_name != NULL, NULL);
g_return_val_if_fail (background_color_spec != NULL, NULL);
graphic = nautilus_graphic_new();
path = nautilus_pixmap_file (icon_name);
pixbuf = gdk_pixbuf_new_from_file (path);
g_free (path);
if (pixbuf != NULL) {
nautilus_graphic_set_pixbuf (NAUTILUS_GRAPHIC (graphic), pixbuf);
gdk_pixbuf_unref (pixbuf);
}
else {
g_warning ("Could not find the requested icon.");
}
nautilus_graphic_set_background_type (NAUTILUS_GRAPHIC (graphic),
NAUTILUS_GRAPHIC_BACKGROUND_SOLID);
background_rgb = nautilus_parse_rgb_with_white_default (background_color_spec);
nautilus_graphic_set_background_color (NAUTILUS_GRAPHIC (graphic),
background_rgb);
nautilus_graphic_set_placement_type (NAUTILUS_GRAPHIC (graphic), placement);
return graphic;
}
static GtkWidget*
create_title_widget (const char *title_text)
{
GtkWidget *title_hbox;
GtkWidget *logo_graphic;
GtkWidget *filler_graphic;
GtkWidget *text_graphic;
GdkFont *font;
g_assert (title_text != NULL);
title_hbox = gtk_hbox_new (FALSE, 0);
logo_graphic = create_graphic_widget ("eazel-services-logo.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_GRAPHIC_PLACEMENT_CENTER);
filler_graphic = create_graphic_widget ("eazel-services-logo-tile.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_GRAPHIC_PLACEMENT_TILE);
text_graphic = create_graphic_widget ("eazel-services-logo-tile.png",
SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR,
NAUTILUS_GRAPHIC_PLACEMENT_TILE);
font = nautilus_font_factory_get_font_by_family ("helvetica", 20);
nautilus_graphic_set_label_text (NAUTILUS_GRAPHIC (text_graphic), title_text);
nautilus_graphic_set_label_font (NAUTILUS_GRAPHIC (text_graphic), font);
nautilus_graphic_set_extra_width (NAUTILUS_GRAPHIC (text_graphic), 8);
nautilus_graphic_set_right_offset (NAUTILUS_GRAPHIC (text_graphic), 8);
nautilus_graphic_set_top_offset (NAUTILUS_GRAPHIC (text_graphic), 3);
gdk_font_unref (font);
gtk_widget_show (logo_graphic);
gtk_widget_show (filler_graphic);
gtk_widget_show (text_graphic);
gtk_box_pack_start (GTK_BOX (title_hbox), logo_graphic, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (title_hbox), filler_graphic, TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (title_hbox), text_graphic, FALSE, FALSE, 0);
return title_hbox;
}

View file

@ -66,6 +66,15 @@ struct _NautilusGraphicDetail
GdkGC *copy_area_gc;
GdkPixbuf *buffer;
/* Offsets */
guint left_offset;
guint right_offset;
guint top_offset;
guint bottom_offset;
guint extra_width;
guint extra_height;
};
/* GtkObjectClass methods */
@ -272,6 +281,14 @@ nautilus_graphic_initialize (NautilusGraphic *graphic)
graphic->detail->background_tile_origin.y = 0;
graphic->detail->overall_alpha = NAUTILUS_ALPHA_NONE;
graphic->detail->background_tile_screen_relative = TRUE;
graphic->detail->left_offset = 0;
graphic->detail->right_offset = 0;
graphic->detail->top_offset = 0;
graphic->detail->bottom_offset = 0;
graphic->detail->extra_width = 0;
graphic->detail->extra_height = 0;
}
/* GtkObjectClass methods */
@ -590,8 +607,11 @@ nautilus_graphic_size_allocate (GtkWidget *widget, GtkAllocation* allocation)
graphic ->detail->label_text,
&text_size);
x = (widget->allocation.width - text_size.width) / 2;
y = (widget->allocation.height - text_size.height) / 2;
x = widget->allocation.width - text_size.width - graphic->detail->right_offset;
y = graphic->detail->top_offset;
// x = (widget->allocation.width - text_size.width) / 2;
// y = (widget->allocation.height - text_size.height) / 2;
text_rect.x0 = x;
text_rect.y0 = y;
@ -646,8 +666,13 @@ nautilus_graphic_size_request (GtkWidget *widget,
&text_size);
}
requisition->width = MAX (pixbuf_size.width, text_size.width);
requisition->height = MAX (pixbuf_size.height, text_size.height);
requisition->width =
MAX (pixbuf_size.width, text_size.width) +
graphic->detail->extra_width;
requisition->height =
MAX (pixbuf_size.height, text_size.height) +
graphic->detail->extra_height;
}
static void
@ -1376,6 +1401,8 @@ nautilus_graphic_set_label_text (NautilusGraphic *graphic,
g_free (graphic->detail->label_text);
graphic->detail->label_text = text ? g_strdup (text) : NULL;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
gchar*
@ -1399,6 +1426,8 @@ nautilus_graphic_set_label_font (NautilusGraphic *graphic,
graphic->detail->label_font = font;
NAUTILUS_GDK_FONT_REF_IF (graphic->detail->label_font);
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
GdkFont *
@ -1411,3 +1440,76 @@ nautilus_graphic_get_label_font (NautilusGraphic *graphic)
return graphic->detail->label_font;
}
void
nautilus_graphic_set_left_offset (NautilusGraphic *graphic,
guint left_offset)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->left_offset = left_offset;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
void
nautilus_graphic_set_right_offset (NautilusGraphic *graphic,
guint right_offset)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->right_offset = right_offset;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
void
nautilus_graphic_set_top_offset (NautilusGraphic *graphic,
guint top_offset)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->top_offset = top_offset;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
void
nautilus_graphic_set_bottom_offset (NautilusGraphic *graphic,
guint bottom_offset)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->bottom_offset = bottom_offset;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
void
nautilus_graphic_set_extra_width (NautilusGraphic *graphic,
guint extra_width)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->extra_width = extra_width;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
void
nautilus_graphic_set_extra_height (NautilusGraphic *graphic,
guint extra_height)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->extra_height = extra_height;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}

View file

@ -110,7 +110,18 @@ gchar* nautilus_graphic_get_label_text (NautilusGr
void nautilus_graphic_set_label_font (NautilusGraphic *graphic,
GdkFont *font);
GdkFont* nautilus_graphic_get_label_font (NautilusGraphic *graphic);
void nautilus_graphic_set_left_offset (NautilusGraphic *graphic,
guint left_offset);
void nautilus_graphic_set_right_offset (NautilusGraphic *graphic,
guint right_offset);
void nautilus_graphic_set_top_offset (NautilusGraphic *graphic,
guint top_offset);
void nautilus_graphic_set_bottom_offset (NautilusGraphic *graphic,
guint bottom_offset);
void nautilus_graphic_set_extra_width (NautilusGraphic *graphic,
guint extra_width);
void nautilus_graphic_set_extra_height (NautilusGraphic *graphic,
guint extra_width);
END_GNOME_DECLS
#endif /* NAUTILUS_GRAPHIC_H */

View file

@ -66,6 +66,15 @@ struct _NautilusGraphicDetail
GdkGC *copy_area_gc;
GdkPixbuf *buffer;
/* Offsets */
guint left_offset;
guint right_offset;
guint top_offset;
guint bottom_offset;
guint extra_width;
guint extra_height;
};
/* GtkObjectClass methods */
@ -272,6 +281,14 @@ nautilus_graphic_initialize (NautilusGraphic *graphic)
graphic->detail->background_tile_origin.y = 0;
graphic->detail->overall_alpha = NAUTILUS_ALPHA_NONE;
graphic->detail->background_tile_screen_relative = TRUE;
graphic->detail->left_offset = 0;
graphic->detail->right_offset = 0;
graphic->detail->top_offset = 0;
graphic->detail->bottom_offset = 0;
graphic->detail->extra_width = 0;
graphic->detail->extra_height = 0;
}
/* GtkObjectClass methods */
@ -590,8 +607,11 @@ nautilus_graphic_size_allocate (GtkWidget *widget, GtkAllocation* allocation)
graphic ->detail->label_text,
&text_size);
x = (widget->allocation.width - text_size.width) / 2;
y = (widget->allocation.height - text_size.height) / 2;
x = widget->allocation.width - text_size.width - graphic->detail->right_offset;
y = graphic->detail->top_offset;
// x = (widget->allocation.width - text_size.width) / 2;
// y = (widget->allocation.height - text_size.height) / 2;
text_rect.x0 = x;
text_rect.y0 = y;
@ -646,8 +666,13 @@ nautilus_graphic_size_request (GtkWidget *widget,
&text_size);
}
requisition->width = MAX (pixbuf_size.width, text_size.width);
requisition->height = MAX (pixbuf_size.height, text_size.height);
requisition->width =
MAX (pixbuf_size.width, text_size.width) +
graphic->detail->extra_width;
requisition->height =
MAX (pixbuf_size.height, text_size.height) +
graphic->detail->extra_height;
}
static void
@ -1376,6 +1401,8 @@ nautilus_graphic_set_label_text (NautilusGraphic *graphic,
g_free (graphic->detail->label_text);
graphic->detail->label_text = text ? g_strdup (text) : NULL;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
gchar*
@ -1399,6 +1426,8 @@ nautilus_graphic_set_label_font (NautilusGraphic *graphic,
graphic->detail->label_font = font;
NAUTILUS_GDK_FONT_REF_IF (graphic->detail->label_font);
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
GdkFont *
@ -1411,3 +1440,76 @@ nautilus_graphic_get_label_font (NautilusGraphic *graphic)
return graphic->detail->label_font;
}
void
nautilus_graphic_set_left_offset (NautilusGraphic *graphic,
guint left_offset)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->left_offset = left_offset;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
void
nautilus_graphic_set_right_offset (NautilusGraphic *graphic,
guint right_offset)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->right_offset = right_offset;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
void
nautilus_graphic_set_top_offset (NautilusGraphic *graphic,
guint top_offset)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->top_offset = top_offset;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
void
nautilus_graphic_set_bottom_offset (NautilusGraphic *graphic,
guint bottom_offset)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->bottom_offset = bottom_offset;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
void
nautilus_graphic_set_extra_width (NautilusGraphic *graphic,
guint extra_width)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->extra_width = extra_width;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}
void
nautilus_graphic_set_extra_height (NautilusGraphic *graphic,
guint extra_height)
{
g_return_if_fail (graphic != NULL);
g_return_if_fail (NAUTILUS_IS_GRAPHIC (graphic));
graphic->detail->extra_height = extra_height;
gtk_widget_queue_resize (GTK_WIDGET (graphic));
}

View file

@ -110,7 +110,18 @@ gchar* nautilus_graphic_get_label_text (NautilusGr
void nautilus_graphic_set_label_font (NautilusGraphic *graphic,
GdkFont *font);
GdkFont* nautilus_graphic_get_label_font (NautilusGraphic *graphic);
void nautilus_graphic_set_left_offset (NautilusGraphic *graphic,
guint left_offset);
void nautilus_graphic_set_right_offset (NautilusGraphic *graphic,
guint right_offset);
void nautilus_graphic_set_top_offset (NautilusGraphic *graphic,
guint top_offset);
void nautilus_graphic_set_bottom_offset (NautilusGraphic *graphic,
guint bottom_offset);
void nautilus_graphic_set_extra_width (NautilusGraphic *graphic,
guint extra_width);
void nautilus_graphic_set_extra_height (NautilusGraphic *graphic,
guint extra_width);
END_GNOME_DECLS
#endif /* NAUTILUS_GRAPHIC_H */

View file

@ -300,6 +300,10 @@ main (int argc, char* argv[])
nautilus_graphic_set_label_font (NAUTILUS_GRAPHIC (graphic3), font);
gdk_font_unref (font);
nautilus_graphic_set_extra_width (NAUTILUS_GRAPHIC (graphic3), 8);
nautilus_graphic_set_right_offset (NAUTILUS_GRAPHIC (graphic3), 8);
nautilus_graphic_set_top_offset (NAUTILUS_GRAPHIC (graphic3), 3);
}
graphic_box = gtk_hbox_new (FALSE, 0);