app/widgets/gimpdockable.[ch] moved code for the drag widget to

2008-03-10  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpdockable.[ch]
	* app/widgets/gimpdockbook.c: moved code for the drag widget to
	GimpDockable. Use semi-bold text for the drag widget also.

svn path=/trunk/; revision=25082
This commit is contained in:
Sven Neumann 2008-03-10 16:01:48 +00:00 committed by Sven Neumann
parent aec9ef264e
commit c317f937e1
4 changed files with 158 additions and 139 deletions

View File

@ -1,3 +1,9 @@
2008-03-10 Sven Neumann <sven@gimp.org>
* app/widgets/gimpdockable.[ch]
* app/widgets/gimpdockbook.c: moved code for the drag widget to
GimpDockable. Use semi-bold text for the drag widget also.
2008-03-10 Sven Neumann <sven@gimp.org>
* app/paint/gimpink.c (gimp_ink_motion): formatting.

View File

@ -446,23 +446,12 @@ gimp_dockable_style_set (GtkWidget *widget,
}
}
static PangoLayout *
gimp_dockable_create_title_layout (GimpDockable *dockable,
GtkWidget *widget,
gint width)
static void
gimp_dockable_layout_set_weight (PangoLayout *layout,
PangoWeight weight)
{
PangoLayout *layout;
PangoAttrList *attrs;
PangoAttribute *attr;
GtkBin *bin = GTK_BIN (dockable);
gchar *title = NULL;
if (bin->child)
title = gimp_docked_get_title (GIMP_DOCKED (bin->child));
layout = gtk_widget_create_pango_layout (widget,
title ? title : dockable->blurb);
g_free (title);
attrs = pango_attr_list_new ();
@ -473,6 +462,25 @@ gimp_dockable_create_title_layout (GimpDockable *dockable,
pango_layout_set_attributes (layout, attrs);
pango_attr_list_unref (attrs);
}
static PangoLayout *
gimp_dockable_create_title_layout (GimpDockable *dockable,
GtkWidget *widget,
gint width)
{
PangoLayout *layout;
GtkBin *bin = GTK_BIN (dockable);
gchar *title = NULL;
if (bin->child)
title = gimp_docked_get_title (GIMP_DOCKED (bin->child));
layout = gtk_widget_create_pango_layout (widget,
title ? title : dockable->blurb);
g_free (title);
gimp_dockable_layout_set_weight (layout, PANGO_WEIGHT_SEMIBOLD);
if (width > 0)
{
@ -633,6 +641,91 @@ gimp_dockable_forall (GtkContainer *container,
callback, callback_data);
}
static GtkWidget *
gimp_dockable_get_tab_widget_internal (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
GtkIconSize size,
gboolean dnd)
{
GtkWidget *tab_widget = NULL;
GtkWidget *label = NULL;
GtkWidget *icon = NULL;
switch (tab_style)
{
case GIMP_TAB_STYLE_NAME:
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_PREVIEW_NAME:
label = gtk_label_new (dockable->name);
break;
case GIMP_TAB_STYLE_BLURB:
case GIMP_TAB_STYLE_ICON_BLURB:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
label = gtk_label_new (dockable->blurb);
break;
default:
break;
}
switch (tab_style)
{
case GIMP_TAB_STYLE_ICON:
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_ICON_BLURB:
icon = gtk_image_new_from_stock (dockable->stock_id, size);
break;
case GIMP_TAB_STYLE_PREVIEW:
case GIMP_TAB_STYLE_PREVIEW_NAME:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
if (GTK_BIN (dockable)->child)
icon = gimp_docked_get_preview (GIMP_DOCKED (GTK_BIN (dockable)->child),
context, size);
if (! icon)
icon = gtk_image_new_from_stock (dockable->stock_id, size);
break;
default:
break;
}
if (label && dnd)
gimp_label_set_attributes (GTK_LABEL (label),
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_SEMIBOLD,
-1);
switch (tab_style)
{
case GIMP_TAB_STYLE_ICON:
case GIMP_TAB_STYLE_PREVIEW:
tab_widget = icon;
break;
case GIMP_TAB_STYLE_NAME:
case GIMP_TAB_STYLE_BLURB:
tab_widget = label;
break;
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_ICON_BLURB:
case GIMP_TAB_STYLE_PREVIEW_NAME:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
tab_widget = gtk_hbox_new (FALSE, dnd ? 6 : 2);
gtk_box_pack_start (GTK_BOX (tab_widget), icon, FALSE, FALSE, 0);
gtk_widget_show (icon);
gtk_box_pack_start (GTK_BOX (tab_widget), label, FALSE, FALSE, 0);
gtk_widget_show (label);
break;
}
return tab_widget;
}
/* public functions */
@ -724,81 +817,34 @@ gimp_dockable_get_tab_widget (GimpDockable *dockable,
GimpTabStyle tab_style,
GtkIconSize size)
{
GtkWidget *tab_widget = NULL;
GtkWidget *label = NULL;
GtkWidget *icon = NULL;
g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
switch (tab_style)
{
case GIMP_TAB_STYLE_NAME:
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_PREVIEW_NAME:
label = gtk_label_new (dockable->name);
break;
return gimp_dockable_get_tab_widget_internal (dockable, context,
tab_style, size, FALSE);
}
case GIMP_TAB_STYLE_BLURB:
case GIMP_TAB_STYLE_ICON_BLURB:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
label = gtk_label_new (dockable->blurb);
break;
GtkWidget *
gimp_dockable_get_drag_widget (GimpDockable *dockable)
{
GtkWidget *frame;
GtkWidget *widget;
default:
break;
}
g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
switch (tab_style)
{
case GIMP_TAB_STYLE_ICON:
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_ICON_BLURB:
icon = gtk_image_new_from_stock (dockable->stock_id, size);
break;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
case GIMP_TAB_STYLE_PREVIEW:
case GIMP_TAB_STYLE_PREVIEW_NAME:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
if (GTK_BIN (dockable)->child)
icon = gimp_docked_get_preview (GIMP_DOCKED (GTK_BIN (dockable)->child),
context, size);
widget = gimp_dockable_get_tab_widget_internal (dockable,
dockable->context,
GIMP_TAB_STYLE_ICON_BLURB,
GTK_ICON_SIZE_DND,
TRUE);
gtk_container_set_border_width (GTK_CONTAINER (widget), 6);
gtk_container_add (GTK_CONTAINER (frame), widget);
gtk_widget_show (widget);
if (! icon)
icon = gtk_image_new_from_stock (dockable->stock_id, size);
break;
default:
break;
}
switch (tab_style)
{
case GIMP_TAB_STYLE_ICON:
case GIMP_TAB_STYLE_PREVIEW:
tab_widget = icon;
break;
case GIMP_TAB_STYLE_NAME:
case GIMP_TAB_STYLE_BLURB:
tab_widget = label;
break;
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_ICON_BLURB:
case GIMP_TAB_STYLE_PREVIEW_NAME:
case GIMP_TAB_STYLE_PREVIEW_BLURB:
tab_widget = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (tab_widget), icon, FALSE, FALSE, 0);
gtk_widget_show (icon);
gtk_box_pack_start (GTK_BOX (tab_widget), label, FALSE, FALSE, 0);
gtk_widget_show (label);
break;
}
return tab_widget;
return frame;
}
void

View File

@ -71,33 +71,34 @@ struct _GimpDockableClass
};
GType gimp_dockable_get_type (void) G_GNUC_CONST;
GType gimp_dockable_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_dockable_new (const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id);
GtkWidget * gimp_dockable_new (const gchar *name,
const gchar *blurb,
const gchar *stock_id,
const gchar *help_id);
void gimp_dockable_set_aux_info (GimpDockable *dockable,
GList *aux_info);
GList * gimp_dockable_get_aux_info (GimpDockable *dockable);
void gimp_dockable_set_aux_info (GimpDockable *dockable,
GList *aux_info);
GList * gimp_dockable_get_aux_info (GimpDockable *dockable);
void gimp_dockable_set_tab_style (GimpDockable *dockable,
GimpTabStyle tab_style);
GtkWidget * gimp_dockable_get_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
GtkIconSize size);
void gimp_dockable_set_context (GimpDockable *dockable,
GimpContext *context);
GimpUIManager * gimp_dockable_get_menu (GimpDockable *dockable,
const gchar **ui_path,
gpointer *popup_data);
void gimp_dockable_set_tab_style (GimpDockable *dockable,
GimpTabStyle tab_style);
GtkWidget * gimp_dockable_get_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
GtkIconSize size);
GtkWidget * gimp_dockable_get_drag_widget (GimpDockable *dockable);
void gimp_dockable_set_context (GimpDockable *dockable,
GimpContext *context);
GimpUIManager * gimp_dockable_get_menu (GimpDockable *dockable,
const gchar **ui_path,
gpointer *popup_data);
void gimp_dockable_detach (GimpDockable *dockable);
void gimp_dockable_detach (GimpDockable *dockable);
void gimp_dockable_blink (GimpDockable *dockable);
void gimp_dockable_blink_cancel (GimpDockable *dockable);
void gimp_dockable_blink (GimpDockable *dockable);
void gimp_dockable_blink_cancel (GimpDockable *dockable);
#endif /* __GIMP_DOCKABLE_H__ */

View File

@ -102,9 +102,6 @@ static gboolean gimp_dockbook_tab_drag_drop (GtkWidget *widget,
gint y,
guint time);
static gboolean gimp_dockbook_tab_drag_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gimp_dockbook_add_tab_timeout (GimpDockbook *dockbook,
GimpDockable *dockable);
static void gimp_dockbook_remove_tab_timeout (GimpDockbook *dockbook);
@ -587,21 +584,7 @@ gimp_dockbook_tab_drag_begin (GtkWidget *widget,
gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DND);
gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (widget));
view = gimp_dockable_get_tab_widget (dockable,
dockable->context,
GIMP_TAB_STYLE_ICON_BLURB,
DND_WIDGET_ICON_SIZE);
g_signal_connect (view, "expose-event",
G_CALLBACK (gimp_dockbook_tab_drag_expose),
NULL);
if (GTK_IS_CONTAINER (view))
gtk_container_set_border_width (GTK_CONTAINER (view), 6);
if (GTK_IS_HBOX (view))
gtk_box_set_spacing (GTK_BOX (view), 6);
view = gimp_dockable_get_drag_widget (dockable);
gtk_container_add (GTK_CONTAINER (window), view);
gtk_widget_show (view);
@ -772,24 +755,6 @@ gimp_dockbook_tab_drag_drop (GtkWidget *widget,
return FALSE;
}
static gboolean
gimp_dockbook_tab_drag_expose (GtkWidget *widget,
GdkEventExpose *event)
{
/* mimic the appearance of a notebook tab */
gtk_paint_extension (widget->style, widget->window,
widget->state, GTK_SHADOW_OUT,
&event->area, widget, "tab",
widget->allocation.x,
widget->allocation.y,
widget->allocation.width,
widget->allocation.height,
GTK_POS_BOTTOM);
return FALSE;
}
static void
gimp_dockbook_add_tab_timeout (GimpDockbook *dockbook,
GimpDockable *dockable)
@ -798,6 +763,7 @@ gimp_dockbook_add_tab_timeout (GimpDockbook *dockbook,
g_timeout_add (TAB_HOVER_TIMEOUT,
(GSourceFunc) gimp_dockbook_tab_timeout,
dockbook);
dockbook->tab_hover_dockable = dockable;
}