LIB_BARCODE_DIR = ../barcode-0.98
-SUBDIRS= pixmaps stock-pixmaps
+SUBDIRS= pixmaps stock-pixmaps mygal
bin_PROGRAMS = glabels glabels-batch
glabels_LDADD = \
$(GLABELS_LIBS) \
+ mygal/libmygal.la \
-L$(LIB_BARCODE_DIR) -lbarcode
glabels_batch_LDFLAGS = -export-dynamic
stock.h \
ui.h \
ui.c \
+ ui-property-bar.h \
+ ui-property-bar.c \
+ ui-util.h \
+ ui-util.c \
commands.h \
commands.c \
file.h \
return gdk_color;
}
+/*****************************************************************************/
+/* Convert GdkColor into a canvas color */
+/*****************************************************************************/
+guint
+gl_color_from_gdk_color (GdkColor *gdk_color)
+{
+ guint color;
+
+ color = GL_COLOR ((gdk_color->red >>8),
+ (gdk_color->green >>8),
+ (gdk_color->blue >>8));
+
+ return color;
+}
+
#define GL_COLOR(r,g,b) GNOME_CANVAS_COLOR(r,g,b)
#define GL_COLOR_A(r,g,b,a) GNOME_CANVAS_COLOR_A(r,g,b,a)
+#define GL_COLOR_NONE GL_COLOR_A(0,0,0,0)
+
#define GL_COLOR_I_RED(x) (((x)>>24) & 0xff)
#define GL_COLOR_I_GREEN(x) (((x)>>16) & 0xff)
#define GL_COLOR_I_BLUE(x) (((x)>>8) & 0xff)
guint gl_color_set_opacity (guint color, gdouble opacity);
-GdkColor *gl_color_to_gdk_color (guint color);
+GdkColor *gl_color_to_gdk_color (guint color);
+guint gl_color_from_gdk_color (GdkColor *gdk_color);
G_END_DECLS
gint gl_debug_recent = 0;
gint gl_debug_window = 0;
gint gl_debug_ui = 0;
+gint gl_debug_property_bar = 0;
gint gl_debug_media_select = 0;
gint gl_debug_mini_preview = 0;
gint gl_debug_pixbuf_cache = 0;
(gl_debug_recent && section == GL_DEBUG_RECENT) ||
(gl_debug_window && section == GL_DEBUG_WINDOW) ||
(gl_debug_ui && section == GL_DEBUG_UI) ||
+ (gl_debug_property_bar && section == GL_DEBUG_PROPERTY_BAR) ||
(gl_debug_media_select && section == GL_DEBUG_MEDIA_SELECT) ||
(gl_debug_mini_preview && section == GL_DEBUG_MINI_PREVIEW) ||
(gl_debug_pixbuf_cache && section == GL_DEBUG_PIXBUF_CACHE) ||
GL_DEBUG_COMMANDS,
GL_DEBUG_WINDOW,
GL_DEBUG_UI,
+ GL_DEBUG_PROPERTY_BAR,
GL_DEBUG_MEDIA_SELECT,
GL_DEBUG_MINI_PREVIEW,
GL_DEBUG_PIXBUF_CACHE,
extern gint gl_debug_recent;
extern gint gl_debug_window;
extern gint gl_debug_ui;
+extern gint gl_debug_property_bar;
extern gint gl_debug_media_select;
extern gint gl_debug_mini_preview;
extern gint gl_debug_pixbuf_cache;
#define DEBUG_COMMANDS GL_DEBUG_COMMANDS,__FILE__, __LINE__, __FUNCTION__
#define DEBUG_WINDOW GL_DEBUG_WINDOW, __FILE__, __LINE__, __FUNCTION__
#define DEBUG_UI GL_DEBUG_UI, __FILE__, __LINE__, __FUNCTION__
+#define DEBUG_PROPERTY_BAR GL_DEBUG_PROPERTY_BAR, __FILE__, __LINE__, __FUNCTION__
#define DEBUG_MEDIA_SELECT GL_DEBUG_MEDIA_SELECT, __FILE__, __LINE__, __FUNCTION__
#define DEBUG_MINI_PREVIEW GL_DEBUG_MINI_PREVIEW, __FILE__, __LINE__, __FUNCTION__
#define DEBUG_PIXBUF_CACHE GL_DEBUG_PIXBUF_CACHE, __FILE__, __LINE__, __FUNCTION__
<Root>
-<commands>
- <cmd name="FileNew" _label="New"
- _tip="Create a new document" pixtype="stock" pixname="gtk-new" accel="*Control*N"/>
-
- <cmd name="FileProperties" _label="Properties"
- _tip="Create a new document" pixtype="stock" pixname="gtk-properties"/>
-
- <cmd name="FileOpen" _label="Open"
- _tip="Open a file" pixtype="stock" pixname="gtk-open" accel="*Control*O"/>
-
- <cmd name="FileSave" _label="Save"
- _tip="Save the current file" pixtype="stock" pixname="gtk-save"
- accel="*Control*S"/>
-
- <cmd name="FileSaveAs" _label="Save As"
- _tip="Save the current file with a different name"
- pixtype="stock" pixname="gtk-save-as"
- accel="*Shift**Control*S"/>
-
- <cmd name="FilePrint" _label="Print"
- _tip="Print the current file" pixtype="stock" pixname="gtk-print"
- accel="*Control*P"/>
-
- <cmd name="FileClose" _label="Close"
- _tip="Close the current file" pixtype="stock" pixname="gtk-close"
- accel="*Alt*F4"/>
-
- <cmd name="FileExit" _label="Quit" _tip="Quit the program"
- pixtype="stock" pixname="gtk-quit" accel="*Control*Q"/>
-
-
-
- <cmd name="EditUndo" _label="Undo" _tip="Undo the last action"
- pixtype="stock" pixname="gtk-undo" accel="*Control*Z"/>
-
- <cmd name="EditRedo" _label="Redo" _tip="Redo the undone action"
- pixtype="stock" pixname="gtk-redo" accel="*Shift**Control*Z"/>
-
- <cmd name="EditCut" _label="Cut" _tip="Cut the selection"
- pixtype="stock" pixname="gtk-cut" accel="*Control*X"/>
-
- <cmd name="EditCopy" _label="Copy"
- _tip="Copy the selection" pixtype="stock" pixname="gtk-copy" accel="*Control*c"/>
-
- <cmd name="EditPaste" _label="Paste"
- _tip="Paste the clipboard" pixtype="stock" pixname="gtk-paste" accel="*Control*v"/>
-
- <cmd name="EditDelete" _label="Delete"
- _tip="Delete the selected objects"/>
-
- <cmd name="EditSelectAll" _label="Select All" _tip="Select all objects"
- accel="*Control*A"/>
-
- <cmd name="EditUnSelectAll" _label="Un-select All" _tip="Remove all selections"/>
-
- <cmd name="ViewMainToolbar" _label="_Main Toolbar" type="toggle"
- _tip="Change the visibility of the main toolbar in the current window" state="0"/>
-
- <cmd name="MainToolbarSystem" id="MainToolbarSystem" _label="_Desktop Default" type="radio"
- group="main_buttons" state = "1" _tip="Set main toolbar button style according to desktop default"/>
-
- <cmd name="MainToolbarIcon" id="MainToolbarIcon" _label="_Icon" type="radio"
- group="main_buttons" _tip="Only show icons in the main toolbar"/>
-
- <cmd name="MainToolbarIconText" id="MainToolbarIconText" _label="Icon and _Text" type="radio"
- group="main_buttons" _tip ="Show both icons and texts in the main toolbar"/>
-
- <cmd name="MainToolbarTooltips" id="MainToolbarTooltips" _label="Show _Tooltips" type="toggle"
- _tip="Show tooltips in the main toolbar" state="1"/>
-
- <cmd name="ViewDrawingToolbar" _label="_Drawing Toolbar" type="toggle"
- _tip="Change the visibility of the drawing toolbar in the current window" state="0"/>
-
- <cmd name="DrawingToolbarSystem" id="DrawingToolbarSystem" _label="_Desktop Default" type="radio"
- group="drawing_buttons" state = "1" _tip="Set drawing toolbar button style according to desktop default"/>
-
- <cmd name="DrawingToolbarIcon" id="DrawingToolbarIcon" _label="_Icon" type="radio"
- group="drawing_buttons" _tip="Only show icons in the drawing toolbar"/>
-
- <cmd name="DrawingToolbarIconText" id="DrawingToolbarIconText" _label="Icon and _Text" type="radio"
- group="drawing_buttons" _tip ="Show both icons and texts in the drawing toolbar"/>
-
- <cmd name="DrawingToolbarTooltips" id="DrawingToolbarTooltips" _label="Show _Tooltips" type="toggle"
- _tip="Show tooltips in the drawing toolbar" state="1"/>
-
- <cmd name="ViewGrid" _label="_Grid" type="toggle"
- _tip="Change the visibility of the grid in the current window" state="1"/>
-
- <cmd name="ViewMarkup" _label="Markup" type="toggle"
- _tip="Change the visibility of markup lines in the current window" state="1"/>
-
- <cmd name="SettingsPreferences" _label="Preferences" _tip="Configure the application"
- pixtype="stock" pixname="gtk-preferences"/>
-
- <cmd name="BonoboCustomize" _label="Customize" _tip="Customize toolbars"/>
-
- <cmd name="ToolsArrow"
- _tip="Select, move and modify objects"
- pixtype="stock" pixname="gl_stock_arrow"/>
-
- <cmd name="ToolsText"
- _tip="Create text object"
- pixtype="stock" pixname="gl_stock_text"/>
-
- <cmd name="ToolsLine"
- _tip="Create line object"
- pixtype="stock" pixname="gl_stock_line"/>
-
- <cmd name="ToolsBox"
- _tip="Create box/rectangle object"
- pixtype="stock" pixname="gl_stock_box"/>
-
- <cmd name="ToolsEllipse"
- _tip="Create ellipse/circle object"
- pixtype="stock" pixname="gl_stock_ellipse"/>
-
- <cmd name="ToolsImage"
- _tip="Create image object"
- pixtype="stock" pixname="gl_stock_image"/>
-
- <cmd name="ToolsBarcode"
- _tip="Create barcode object"
- pixtype="stock" pixname="gl_stock_barcode"/>
-
- <cmd name="ToolsZoomIn"
- _tip="Increase magnification"
- pixtype="stock" pixname="gtk-zoom-in"/>
-
- <cmd name="ToolsZoomOut"
- _tip="Decrease magnification"
- pixtype="stock" pixname="gtk-zoom-out"/>
-
- <cmd name="ToolsZoom1to1"
- _tip="Restore scale to 100%"
- pixtype="stock" pixname="gtk-zoom-100"/>
-
- <cmd name="ToolsMergeProperties"
- _tip="Edit merge properties"
- pixtype="stock" pixname="gl_stock_merge"/>
-
- <cmd name="ToolsObjectProperties"
- _tip="Edit object properties"
- pixtype="stock" pixname="gl_stock_properties"/>
-
- <cmd name="ToolsRaiseObjects"
- _tip="Raise object to top"
- pixtype="stock" pixname="gl_stock_order_top"/>
-
- <cmd name="ToolsLowerObjects"
- _tip="Lower object to bottom"
- pixtype="stock" pixname="gl_stock_order_bottom"/>
-
- <cmd name="ToolsRotateLeft"
- _tip="Rotate object 90 counter-clockwise"
- pixtype="stock" pixname="gl_stock_rotate_left"/>
-
- <cmd name="ToolsRotateRight"
- _tip="Rotate object 90 clockwise"
- pixtype="stock" pixname="gl_stock_rotate_right"/>
-
- <cmd name="ToolsFlipHorizontal"
- _tip="Flip object horizontally"
- pixtype="stock" pixname="gl_stock_flip_horiz"/>
-
- <cmd name="ToolsFlipVertical"
- _tip="Flip object vertically"
- pixtype="stock" pixname="gl_stock_flip_vert"/>
-
- <cmd name="ToolsAlignLeft"
- _tip="Align objects to left edges"
- pixtype="stock" pixname="gl_stock_align_left"/>
-
- <cmd name="ToolsAlignHCenter"
- _tip="Align objects to horizontal centers"
- pixtype="stock" pixname="gl_stock_align_hcenter"/>
-
- <cmd name="ToolsAlignRight"
- _tip="Align objects to right edges"
- pixtype="stock" pixname="gl_stock_align_right"/>
-
- <cmd name="ToolsAlignTop"
- _tip="Align objects to tops"
- pixtype="stock" pixname="gl_stock_align_top"/>
-
- <cmd name="ToolsAlignVCenter"
- _tip="Align objects to vertical centers"
- pixtype="stock" pixname="gl_stock_align_vcenter"/>
-
- <cmd name="ToolsAlignBottom"
- _tip="Align objects to bottoms"
- pixtype="stock" pixname="gl_stock_align_bottom"/>
-
- <cmd name="ToolsCenterHorizontal"
- _tip="Center objects to horizontal label center"
- pixtype="stock" pixname="gl_stock_center_horiz"/>
-
- <cmd name="ToolsCenterVertical"
- _tip="Center objects to vertical label center"
- pixtype="stock" pixname="gl_stock_center_vert"/>
-
-
- <cmd name="HelpContents" _label="Contents" _tip="Open the glabels manual"
- accel="F1" pixtype="stock" pixname="gtk-help"/>
-
- <cmd name="About" _label="About..." _tip="About glabels"
- pixtype="stock" pixname="About"/>
-
-
- <cmd name="BonoboUIDump" _label="Dump XML" _tip="Dump the UI Xml description" hidden="0"/>
-
-</commands>
-
-<menu>
-
-<submenu name="File" _label="_File">
-
- <menuitem name="FileNew" verb="" _label="_New"/>
-
- <menuitem name="FileOpen" verb="" _label="_Open..."/>
-
- <submenu name="Recents" _label="Recent _Files">
-
- </submenu>
- <separator/>
- <menuitem name="FileSave" verb="" _label="_Save"/>
-
- <menuitem name="FileSaveAs" verb="" _label="Save _As..."/>
+ <commands>
+
+ <cmd name="FileNew"
+ _label="New"
+ _tip="Create a new document"
+ pixtype="stock" pixname="gtk-new"
+ accel="*Control*N"
+ />
+
+ <cmd name="FileProperties"
+ _label="Properties"
+ _tip="Create a new document"
+ pixtype="stock" pixname="gtk-properties"
+ />
+
+ <cmd name="FileOpen"
+ _label="Open"
+ _tip="Open a file"
+ pixtype="stock" pixname="gtk-open"
+ accel="*Control*O"
+ />
+
+ <cmd name="FileSave"
+ _label="Save"
+ _tip="Save the current file"
+ pixtype="stock" pixname="gtk-save"
+ accel="*Control*S"
+ />
+
+ <cmd name="FileSaveAs"
+ _label="Save As"
+ _tip="Save the current file with a different name"
+ pixtype="stock" pixname="gtk-save-as"
+ accel="*Shift**Control*S"
+ />
+
+ <cmd name="FilePrint"
+ _label="Print"
+ _tip="Print the current file"
+ pixtype="stock" pixname="gtk-print"
+ accel="*Control*P"
+ />
+
+ <cmd name="FileClose"
+ _label="Close"
+ _tip="Close the current file"
+ pixtype="stock" pixname="gtk-close"
+ accel="*Alt*F4"
+ />
+
+ <cmd name="FileExit"
+ _label="Quit"
+ _tip="Quit the program"
+ pixtype="stock" pixname="gtk-quit"
+ accel="*Control*Q"
+ />
+
+ <cmd name="EditUndo"
+ _label="Undo"
+ _tip="Undo the last action"
+ pixtype="stock" pixname="gtk-undo"
+ accel="*Control*Z"
+ />
+
+ <cmd name="EditRedo"
+ _label="Redo"
+ _tip="Redo the undone action"
+ pixtype="stock" pixname="gtk-redo"
+ accel="*Shift**Control*Z"
+ />
+
+ <cmd name="EditCut"
+ _label="Cut"
+ _tip="Cut the selection"
+ pixtype="stock" pixname="gtk-cut"
+ accel="*Control*X"
+ />
+
+ <cmd name="EditCopy"
+ _label="Copy"
+ _tip="Copy the selection"
+ pixtype="stock" pixname="gtk-copy"
+ accel="*Control*c"
+ />
+
+ <cmd name="EditPaste"
+ _label="Paste"
+ _tip="Paste the clipboard"
+ pixtype="stock" pixname="gtk-paste"
+ accel="*Control*v"
+ />
+
+ <cmd name="EditDelete"
+ _label="Delete"
+ _tip="Delete the selected objects"
+ />
+
+ <cmd name="EditSelectAll"
+ _label="Select All"
+ _tip="Select all objects"
+ accel="*Control*A"
+ />
+
+ <cmd name="EditUnSelectAll"
+ _label="Un-select All"
+ _tip="Remove all selections"
+ />
+
+ <cmd name="ViewMainToolbar"
+ _label="_Main Toolbar"
+ _tip="Change the visibility of the main toolbar in the current window"
+ type="toggle" state="0"
+ />
+
+ <cmd name="MainToolbarSystem"
+ id="MainToolbarSystem"
+ _label="_Desktop Default"
+ _tip="Set main toolbar button style according to desktop default"
+ type="radio" group="main_buttons" state="1"
+ />
+
+ <cmd name="MainToolbarIcon"
+ id="MainToolbarIcon"
+ _label="_Icon"
+ _tip="Only show icons in the main toolbar"
+ type="radio" group="main_buttons"
+ />
+
+ <cmd name="MainToolbarIconText"
+ id="MainToolbarIconText"
+ _label="Icon and _Text"
+ _tip="Show both icons and texts in the main toolbar"
+ type="radio" group="main_buttons"
+ />
+
+ <cmd name="MainToolbarTooltips"
+ id="MainToolbarTooltips"
+ _label="Show _Tooltips"
+ _tip="Show tooltips in the main toolbar"
+ type="toggle" state="1"
+ />
+
+ <cmd name="ViewDrawingToolbar"
+ _label="_Drawing Toolbar"
+ _tip="Change the visibility of the drawing toolbar in the current window"
+ type="toggle" state="0"
+ />
+
+ <cmd name="DrawingToolbarSystem"
+ id="DrawingToolbarSystem"
+ _label="_Desktop Default"
+ _tip="Set drawing toolbar button style according to desktop default"
+ type="radio" group="drawing_buttons" state="1"
+ />
+
+ <cmd name="DrawingToolbarIcon"
+ id="DrawingToolbarIcon"
+ _label="_Icon"
+ _tip="Only show icons in the drawing toolbar"
+ type="radio" group="drawing_buttons"
+ />
+
+ <cmd name="DrawingToolbarIconText"
+ id="DrawingToolbarIconText"
+ _label="Icon and _Text"
+ _tip="Show both icons and texts in the drawing toolbar"
+ type="radio" group="drawing_buttons"
+ />
+
+ <cmd name="DrawingToolbarTooltips"
+ id="DrawingToolbarTooltips"
+ _label="Show _Tooltips"
+ _tip="Show tooltips in the drawing toolbar"
+ type="toggle" state="1"
+ />
+
+ <cmd name="ViewGrid"
+ _label="_Grid"
+ _tip="Change the visibility of the grid in the current window"
+ type="toggle" state="1"
+ />
+
+ <cmd name="ViewMarkup"
+ _label="Markup"
+ _tip="Change the visibility of markup lines in the current window"
+ type="toggle" state="1"
+ />
+
+ <cmd name="SettingsPreferences"
+ _label="Preferences"
+ _tip="Configure the application"
+ pixtype="stock" pixname="gtk-preferences"
+ />
+
+ <cmd name="ToolsArrow"
+ _tip="Select, move and modify objects"
+ pixtype="stock" pixname="gl_stock_arrow"
+ />
+
+ <cmd name="ToolsText"
+ _tip="Create text object"
+ pixtype="stock" pixname="gl_stock_text"
+ />
+
+ <cmd name="ToolsLine"
+ _tip="Create line object"
+ pixtype="stock" pixname="gl_stock_line"
+ />
+
+ <cmd name="ToolsBox"
+ _tip="Create box/rectangle object"
+ pixtype="stock" pixname="gl_stock_box"
+ />
+
+ <cmd name="ToolsEllipse"
+ _tip="Create ellipse/circle object"
+ pixtype="stock" pixname="gl_stock_ellipse"
+ />
+
+ <cmd name="ToolsImage"
+ _tip="Create image object"
+ pixtype="stock" pixname="gl_stock_image"
+ />
+
+ <cmd name="ToolsBarcode"
+ _tip="Create barcode object"
+ pixtype="stock" pixname="gl_stock_barcode"
+ />
+
+ <cmd name="ToolsZoomIn"
+ _tip="Increase magnification"
+ pixtype="stock" pixname="gtk-zoom-in"
+ />
+
+ <cmd name="ToolsZoomOut"
+ _tip="Decrease magnification"
+ pixtype="stock" pixname="gtk-zoom-out"
+ />
+
+ <cmd name="ToolsZoom1to1"
+ _tip="Restore scale to 100%"
+ pixtype="stock" pixname="gtk-zoom-100"
+ />
+
+ <cmd name="ToolsMergeProperties"
+ _tip="Edit merge properties"
+ pixtype="stock" pixname="gl_stock_merge"
+ />
+
+ <cmd name="ToolsObjectProperties"
+ _tip="Edit object properties"
+ pixtype="stock" pixname="gl_stock_properties"
+ />
+
+ <cmd name="ToolsRaiseObjects"
+ _tip="Raise object to top"
+ pixtype="stock" pixname="gl_stock_order_top"
+ />
+
+ <cmd name="ToolsLowerObjects"
+ _tip="Lower object to bottom"
+ pixtype="stock" pixname="gl_stock_order_bottom"
+ />
+
+ <cmd name="ToolsRotateLeft"
+ _tip="Rotate object 90 counter-clockwise"
+ pixtype="stock" pixname="gl_stock_rotate_left"
+ />
+
+ <cmd name="ToolsRotateRight"
+ _tip="Rotate object 90 clockwise"
+ pixtype="stock" pixname="gl_stock_rotate_right"
+ />
+
+ <cmd name="ToolsFlipHorizontal"
+ _tip="Flip object horizontally"
+ pixtype="stock" pixname="gl_stock_flip_horiz"
+ />
+
+ <cmd name="ToolsFlipVertical"
+ _tip="Flip object vertically"
+ pixtype="stock" pixname="gl_stock_flip_vert"
+ />
+
+ <cmd name="ToolsAlignLeft"
+ _tip="Align objects to left edges"
+ pixtype="stock" pixname="gl_stock_align_left"
+ />
+
+ <cmd name="ToolsAlignHCenter"
+ _tip="Align objects to horizontal centers"
+ pixtype="stock" pixname="gl_stock_align_hcenter"
+ />
+
+ <cmd name="ToolsAlignRight"
+ _tip="Align objects to right edges"
+ pixtype="stock" pixname="gl_stock_align_right"
+ />
+
+ <cmd name="ToolsAlignTop"
+ _tip="Align objects to tops"
+ pixtype="stock" pixname="gl_stock_align_top"
+ />
+
+ <cmd name="ToolsAlignVCenter"
+ _tip="Align objects to vertical centers"
+ pixtype="stock" pixname="gl_stock_align_vcenter"
+ />
+
+ <cmd name="ToolsAlignBottom"
+ _tip="Align objects to bottoms"
+ pixtype="stock" pixname="gl_stock_align_bottom"
+ />
+
+ <cmd name="ToolsCenterHorizontal"
+ _tip="Center objects to horizontal label center"
+ pixtype="stock" pixname="gl_stock_center_horiz"
+ />
+
+ <cmd name="ToolsCenterVertical"
+ _tip="Center objects to vertical label center"
+ pixtype="stock" pixname="gl_stock_center_vert"
+ />
+
+ <cmd name="PropFontName"
+ _tip="Font name"
+ />
+
+ <cmd name="PropFontSize"
+ _tip="Font size"
+ />
+
+ <cmd name="PropFontBold"
+ _tip="Bold" type="toggle"
+ />
+
+ <cmd name="PropFontItalic"
+ _tip="Italic"
+ type="toggle"
+ />
+
+ <cmd name="PropTextAlignLeft"
+ _tip="Left align"
+ type="toggle" state="0"
+ />
+
+ <cmd name="PropTextAlignCenter"
+ _tip="Center align"
+ type="toggle" state="0"
+ />
+
+ <cmd name="PropTextAlignRight"
+ _tip="Right align"
+ type="toggle" state="0"
+ />
+
+ <cmd name="PropTextColor"
+ _tip="Text color"
+ />
+
+ <cmd name="PropFillColor"
+ _tip="Fill color"
+ />
+
+ <cmd name="PropLineColor"
+ _tip="Line color"
+ />
+
+ <cmd name="PropLineWidth"
+ _tip="Line width"
+ />
+
+ <cmd name="HelpContents"
+ _label="Contents"
+ _tip="Open the glabels manual"
+ pixtype="stock" pixname="gtk-help"
+ accel="F1"
+ />
+
+ <cmd name="About"
+ _label="About..."
+ _tip="About glabels"
+ pixtype="stock" pixname="About"
+ />
+
+ <cmd name="BonoboCustomize"
+ _label="Customize"
+ _tip="Customize toolbars"
+ />
+
+ <cmd name="BonoboUIDump"
+ _label="Dump XML"
+ _tip="Dump the UI Xml description"
+ hidden="0"
+ />
+
+ </commands>
+
+
+
+ <menu>
- <separator/>
-
- <menuitem name="FilePrint" verb="" _label="_Print..."/>
- <placeholder name="FileOps_1" />
+ <submenu name="File"
+ _label="_File"
+ hidden="0"
+ >
- <placeholder name="FileOps_2" delimit="top"/>
+ <menuitem name="FileNew"
+ verb=""
+ _label="_New"
+ />
- <separator/>
+ <menuitem name="FileOpen"
+ verb=""
+ _label="_Open..."
+ />
- <menuitem name="FileProperties" verb="" _label="Proper_ties"/>
+ <submenu name="Recents"
+ _label="Recent _Files"
+ />
- <separator/>
-
- <menuitem name="FileClose" verb="" _label="_Close"/>
+ <separator />
- <menuitem name="FileExit" verb="" _label="_Quit"/>
+ <menuitem name="FileSave"
+ verb=""
+ _label="_Save"
+ />
-</submenu>
+ <menuitem name="FileSaveAs"
+ verb=""
+ _label="Save _As..."
+ />
-<submenu name="Edit" _label="_Edit">
+ <separator />
- <menuitem name="EditCut" verb="" _label="Cu_t"/>
-
- <menuitem name="EditCopy" verb="" _label="_Copy"/>
-
- <menuitem name="EditPaste" verb="" _label="_Paste"/>
-
- <menuitem name="EditDelete" verb="" _label="_Delete"/>
-
- <placeholder name="EditOps_1" />
-
- <separator/>
+ <menuitem name="FilePrint"
+ verb=""
+ _label="_Print..."
+ />
- <placeholder name="EditOps_2" />
+ <separator />
- <menuitem name="EditSelectAll" verb="" _label="Select _All"/>
+ <menuitem name="FileProperties"
+ verb=""
+ _label="Proper_ties"
+ />
- <menuitem name="EditUnSelectAll" verb="" _label="U_n-select All"/>
+ <separator />
- <placeholder name="EditOps_3" />
+ <menuitem name="FileClose"
+ verb=""
+ _label="_Close"
+ />
- <placeholder name="EditOps_4" delimit="top"/>
+ <menuitem name="FileExit"
+ verb=""
+ _label="_Quit"
+ />
- <placeholder name="EditOps_5" delimit="top"/>
+ </submenu>
- <separator/>
- <menuitem name="SettingsPreferences" verb="" _label="Pr_eferences..."/>
+ <submenu name="Edit"
+ _label="_Edit"
+ hidden="0"
+ >
-</submenu>
+ <menuitem name="EditCut"
+ verb=""
+ _label="Cu_t"
+ />
-<submenu name="View" _label="_View" hidden="0">
+ <menuitem name="EditCopy"
+ verb=""
+ _label="_Copy"
+ />
- <menuitem name="ViewMainToolbar" id="ViewMainToolbar" verb=""/>
- <menuitem name="ViewDrawingToolbar" id="ViewDrawingToolbar" verb=""/>
+ <menuitem name="EditPaste"
+ verb=""
+ _label="_Paste"
+ />
- <separator/>
+ <menuitem name="EditDelete"
+ verb=""
+ _label="_Delete"
+ />
- <submenu name="CustomizeMainToolbar" _label="Customize Main Toolbar">
-
- <menuitem name="MainToolbarSystem" verb=""/>
- <menuitem name="MainToolbarIcon" verb=""/>
- <menuitem name="MainToolbarIconText" verb=""/>
+ <separator />
- <separator/>
+ <menuitem name="EditSelectAll"
+ verb=""
+ _label="Select _All"
+ />
- <menuitem name="MainToolbarTooltips" verb=""/>
+ <menuitem name="EditUnSelectAll"
+ verb=""
+ _label="U_n-select All"
+ />
- </submenu>
+ <separator />
- <submenu name="CustomizeDrawingToolbar" _label="Customize Drawing Toolbar">
-
- <menuitem name="DrawingToolbarTooltips" verb=""/>
+ <menuitem name="SettingsPreferences"
+ verb=""
+ _label="Pr_eferences..."
+ />
- </submenu>
+ </submenu>
- <separator/>
- <menuitem name="ViewGrid" id="ViewGrid" verb="" _label="_Grid"/>
- <menuitem name="ViewMarkup" id="ViewMarkup" verb="" _label="M_arkup"/>
+ <submenu name="View"
+ _label="_View"
+ hidden="0"
+ >
- <separator/>
+ <menuitem name="ViewMainToolbar"
+ id="ViewMainToolbar"
+ verb=""
+ />
- <menuitem name="ToolsZoomIn" verb="" _label="Zoom _In"/>
- <menuitem name="ToolsZoomOut" verb="" _label="Zoom _Out"/>
- <menuitem name="ToolsZoom1to1" verb="" _label="Zoom _1:1"/>
+ <menuitem name="ViewDrawingToolbar"
+ id="ViewDrawingToolbar"
+ verb=""
+ />
- <placeholder name="ViewOps" delimit="top"/>
+ <separator />
-</submenu>
+ <submenu name="CustomizeMainToolbar"
+ _label="Customize Main Toolbar"
+ >
+ <menuitem name="MainToolbarSystem"
+ verb=""
+ />
-<submenu name="Objects" _label="_Objects" hidden="0">
+ <menuitem name="MainToolbarIcon"
+ verb=""
+ />
- <menuitem name="ToolsArrow" verb="" _label="_Select Mode"/>
-
+ <menuitem name="MainToolbarIconText"
+ verb=""
+ />
- <submenu name="CreateObjects" _label="_Create Object">
+ <separator />
- <menuitem name="ToolsText" verb="" _label="_Text"/>
- <menuitem name="ToolsBox" verb="" _label="_Box"/>
- <menuitem name="ToolsLine" verb="" _label="_Line"/>
- <menuitem name="ToolsEllipse" verb="" _label="_Ellipse"/>
- <menuitem name="ToolsImage" verb="" _label="_Image"/>
- <menuitem name="ToolsBarcode" verb="" _label="Bar_code"/>
+ <menuitem name="MainToolbarTooltips"
+ verb=""
+ />
- </submenu>
+ </submenu>
- <separator/>
+ <submenu name="CustomizeDrawingToolbar"
+ _label="Customize Drawing Toolbar"
+ >
- <submenu name="Order" _label="_Order">
- <menuitem name="ToolsRaiseObjects" verb="" _label="Bring to _Front"/>
- <menuitem name="ToolsLowerObjects" verb="" _label="Send to _Back"/>
- </submenu>
+ <menuitem name="DrawingToolbarTooltips"
+ verb=""
+ />
- <submenu name="RotateFlip" _label="_Rotate/Flip">
- <menuitem name="ToolsRotateLeft" verb="" _label="Rotate _Left"/>
- <menuitem name="ToolsRotateRight" verb="" _label="Rotate _Right"/>
- <menuitem name="ToolsFlipHorizontal" verb="" _label="Flip _Horizontally"/>
- <menuitem name="ToolsFlipVertical" verb="" _label="Flip _Vertically"/>
- </submenu>
+ </submenu>
- <submenu name="AlignHoriz" _label="Align _Horizontal">
- <menuitem name="ToolsAlignLeft" verb="" _label="_Lefts"/>
- <menuitem name="ToolsAlignHCenter" verb="" _label="_Centers"/>
- <menuitem name="ToolsAlignRight" verb="" _label="_Rights"/>
- <menuitem name="ToolsCenterHorizontal" verb="" _label="Label Ce_nter"/>
- </submenu>
+ <separator />
- <submenu name="AlignVert" _label="Align _Vertical">
- <menuitem name="ToolsAlignTop" verb="" _label="_Tops"/>
- <menuitem name="ToolsAlignVCenter" verb="" _label="_Centers"/>
- <menuitem name="ToolsAlignBottom" verb="" _label="_Bottoms"/>
- <menuitem name="ToolsCenterVertical" verb="" _label="Label Ce_nter"/>
- </submenu>
+ <menuitem name="ViewGrid"
+ id="ViewGrid"
+ verb=""
+ _label="_Grid"
+ />
- <separator/>
+ <menuitem name="ViewMarkup"
+ id="ViewMarkup"
+ verb=""
+ _label="M_arkup"
+ />
- <menuitem name="ToolsObjectProperties" verb="" _label="Object _Properties..."/>
+ <separator />
- <separator/>
+ <menuitem name="ToolsZoomIn"
+ verb=""
+ _label="Zoom _In"
+ />
- <menuitem name="ToolsMergeProperties" verb="" _label="_Merge Properties..."/>
+ <menuitem name="ToolsZoomOut"
+ verb=""
+ _label="Zoom _Out"
+ />
-</submenu>
+ <menuitem name="ToolsZoom1to1"
+ verb=""
+ _label="Zoom _1:1"
+ />
+ </submenu>
-<submenu name="Help" _label="_Help">
-
- <menuitem name="HelpContents" verb="" _label="_Contents"/>
-
- <menuitem name="About" verb="" _label="_About..."/>
-</submenu>
+ <submenu name="Objects"
+ _label="_Objects"
+ hidden="0"
+ >
-<submenu name="Debug" _label="_Debug" hidden="1">
+ <menuitem name="ToolsArrow"
+ verb=""
+ _label="_Select Mode"
+ />
- <menuitem name="BonoboUIDump" verb=""/>
- <menuitem name="BonoboCustomize" label ="Customize" verb=""/>
-</submenu>
+ <submenu name="CreateObjects"
+ _label="_Create Object"
+ >
-</menu>
+ <menuitem name="ToolsText"
+ verb=""
+ _label="_Text"
+ />
-<dockitem name="MainToolbar" _tip="Main toolbar" config="0"
- behavior = "exclusive" in_new_band="1">
-
- <toolitem name="FileNew" verb=""/>
- <toolitem name="FileOpen" verb=""/>
- <toolitem name="FileSave" verb=""/>
+ <menuitem name="ToolsBox"
+ verb=""
+ _label="_Box"
+ />
- <separator/>
+ <menuitem name="ToolsLine"
+ verb=""
+ _label="_Line"
+ />
- <toolitem name="FilePrint" verb=""/>
-
- <separator/>
+ <menuitem name="ToolsEllipse"
+ verb=""
+ _label="_Ellipse"
+ />
+
+ <menuitem name="ToolsImage"
+ verb=""
+ _label="_Image"
+ />
+
+ <menuitem name="ToolsBarcode"
+ verb=""
+ _label="Bar_code"
+ />
- <toolitem name="EditCut" verb=""/>
- <toolitem name="EditCopy" verb=""/>
- <toolitem name="EditPaste" verb=""/>
+ </submenu>
-</dockitem>
+ <separator />
+ <submenu name="Order"
+ _label="_Order"
+ >
-<dockitem name="DrawingToolbar" _tip="Drawing toolbar" config="0"
- behavior = "exclusive" in_new_band="1" band_num="2">
-
- <toolitem name="ToolsArrow" verb=""/>
+ <menuitem name="ToolsRaiseObjects"
+ verb=""
+ _label="Bring to _Front"
+ />
+
+ <menuitem name="ToolsLowerObjects"
+ verb=""
+ _label="Send to _Back"
+ />
- <separator/>
+ </submenu>
- <toolitem name="ToolsText" verb=""/>
- <toolitem name="ToolsBox" verb=""/>
- <toolitem name="ToolsLine" verb=""/>
- <toolitem name="ToolsEllipse" verb=""/>
- <toolitem name="ToolsImage" verb=""/>
- <toolitem name="ToolsBarcode" verb=""/>
+ <submenu name="RotateFlip"
+ _label="_Rotate/Flip"
+ >
+
+ <menuitem name="ToolsRotateLeft"
+ verb=""
+ _label="Rotate _Left"
+ />
+
+ <menuitem name="ToolsRotateRight"
+ verb=""
+ _label="Rotate _Right"
+ />
- <separator/>
+ <menuitem name="ToolsFlipHorizontal"
+ verb=""
+ _label="Flip _Horizontally"
+ />
- <toolitem name="ToolsZoomIn" verb=""/>
- <toolitem name="ToolsZoomOut" verb=""/>
- <toolitem name="ToolsZoom1to1" verb=""/>
+ <menuitem name="ToolsFlipVertical"
+ verb=""
+ _label="Flip _Vertically"
+ />
- <separator/>
+ </submenu>
- <toolitem name="ToolsMergeProperties" verb=""/>
+ <submenu name="AlignHoriz"
+ _label="Align _Horizontal"
+ >
-</dockitem>
+ <menuitem name="ToolsAlignLeft"
+ verb=""
+ _label="_Lefts"
+ />
-<status resize_grip="1">
- <item name="main"/>
- <control name="Zoom"/>
- <control name="Cursor"/>
-</status>
+ <menuitem name="ToolsAlignHCenter"
+ verb=""
+ _label="_Centers"
+ />
-</Root>
+ <menuitem name="ToolsAlignRight"
+ verb=""
+ _label="_Rights"
+ />
+
+ <menuitem name="ToolsCenterHorizontal"
+ verb=""
+ _label="Label Ce_nter"
+ />
+
+ </submenu>
+
+ <submenu name="AlignVert"
+ _label="Align _Vertical"
+ >
+
+ <menuitem name="ToolsAlignTop"
+ verb=""
+ _label="_Tops"
+ />
+
+ <menuitem name="ToolsAlignVCenter"
+ verb=""
+ _label="_Centers"
+ />
+
+ <menuitem name="ToolsAlignBottom"
+ verb=""
+ _label="_Bottoms"
+ />
+
+ <menuitem name="ToolsCenterVertical"
+ verb=""
+ _label="Label Ce_nter"
+ />
+
+ </submenu>
+
+ <separator />
+
+ <menuitem name="ToolsObjectProperties"
+ verb=""
+ _label="Object _Properties..."
+ />
+
+ <separator />
+
+ <menuitem name="ToolsMergeProperties"
+ verb=""
+ _label="_Merge Properties..."
+ />
+
+ </submenu>
+
+
+ <submenu name="Help"
+ _label="_Help"
+ hidden="0"
+ >
+
+ <menuitem name="HelpContents"
+ verb=""
+ _label="_Contents"
+ />
+
+ <menuitem name="About"
+ verb=""
+ _label="_About..."
+ />
+
+ </submenu>
+
+
+ <submenu name="Debug"
+ _label="_Debug"
+ hidden="1"
+ >
+
+ <menuitem name="BonoboUIDump"
+ verb=""
+ />
+
+ <menuitem name="BonoboCustomize"
+ verb=""
+ label="Customize"
+ />
+
+ </submenu>
+
+
+ </menu>
+
+
+
+
+ <dockitem name="MainToolbar"
+ _tip="Main toolbar"
+ config="0"
+ behavior="exclusive"
+ in_new_band="1"
+ >
+
+ <toolitem name="FileNew"
+ verb=""
+ />
+
+ <toolitem name="FileOpen"
+ verb=""
+ />
+
+ <toolitem name="FileSave"
+ verb=""
+ />
+
+ <separator />
+
+ <toolitem name="FilePrint"
+ verb=""
+ />
+
+ <separator />
+
+ <toolitem name="EditCut"
+ verb=""
+ />
+
+ <toolitem name="EditCopy"
+ verb=""
+ />
+
+ <toolitem name="EditPaste"
+ verb=""
+ />
+
+ </dockitem>
+
+
+
+
+ <dockitem name="DrawingToolbar"
+ _tip="Drawing toolbar"
+ config="0"
+ behavior="exclusive"
+ in_new_band="1"
+ band_num="2"
+ >
+
+ <toolitem name="ToolsArrow"
+ verb=""
+ />
+
+ <separator />
+ <toolitem name="ToolsText"
+ verb=""
+ />
+
+ <toolitem name="ToolsBox"
+ verb=""
+ />
+
+ <toolitem name="ToolsLine"
+ verb=""
+ />
+
+ <toolitem name="ToolsEllipse"
+ verb=""
+ />
+
+ <toolitem name="ToolsImage"
+ verb=""
+ />
+
+ <toolitem name="ToolsBarcode"
+ verb=""
+ />
+
+ <separator />
+
+ <toolitem name="ToolsZoomIn"
+ verb=""
+ />
+
+ <toolitem name="ToolsZoomOut"
+ verb=""
+ />
+
+ <toolitem name="ToolsZoom1to1"
+ verb=""
+ />
+
+ <separator />
+
+ <toolitem name="ToolsMergeProperties"
+ verb=""
+ />
+
+ </dockitem>
+
+
+
+
+ <dockitem name="PropertyToolbar"
+ _tip="Property toolbar"
+ config="0"
+ behavior="exclusive,never vertical"
+ in_new_band="1"
+ placement="bottom"
+ >
+
+ <control name="PropFontName"
+ verb=""
+ _tip="Font selector"
+ />
+
+ <control name="PropFontSize"
+ verb=""
+ _tip="Font size"
+ />
+
+ <separator />
+
+ <toolitem name="PropFontBold"
+ verb=""
+ _tip="Bold"
+ pixtype="stock" pixname="gtk-bold"
+ />
+
+ <toolitem name="PropFontItalic"
+ verb=""
+ _tip="Italic"
+ pixtype="stock" pixname="gtk-italic"
+ />
+
+ <separator />
+
+ <toolitem name="PropTextAlignLeft"
+ verb=""
+ _tip="Left align"
+ pixtype="stock" pixname="gtk-justify-left"
+ />
+
+ <toolitem name="PropTextAlignCenter"
+ verb=""
+ _tip="Center align"
+ pixtype="stock" pixname="gtk-justify-center"
+ />
+
+ <toolitem name="PropTextAlignRight"
+ verb=""
+ _tip="Right align"
+ pixtype="stock" pixname="gtk-justify-right"
+ />
+
+ <separator />
+
+ <control name="PropTextColor"
+ verb=""
+ _tip="Text color"
+ />
+
+ <control name="PropFillColor"
+ verb=""
+ _tip="Fill color"
+ />
+
+ <control name="PropLineColor"
+ verb=""
+ _tip="Line color"
+ />
+
+ <separator />
+
+ <control name="PropLineWidth"
+ verb=""
+ _tip="Line width"
+ />
+
+ </dockitem>
+
+
+
+
+ <status resize_grip="1">
+
+ <item name="main" />
+
+ <control name="Zoom" />
+
+ <control name="Cursor" />
+
+ </status>
+
+
+
+
+</Root>
{ "debug-ui", '\0', POPT_ARG_NONE, &gl_debug_ui, 0,
N_("Show ui debugging messages."), NULL },
+ { "debug-property-bar", '\0', POPT_ARG_NONE, &gl_debug_property_bar, 0,
+ N_("Show property_bar debugging messages."), NULL },
+
{ "debug-media-select", '\0', POPT_ARG_NONE, &gl_debug_media_select, 0,
N_("Show media select widget debugging messages."), NULL },
gdouble *w,
gdouble *h);
+static void set_line_color (glLabelObject *object,
+ guint line_color);
+
+
\f
/*****************************************************************************/
/* Boilerplate object stuff. */
parent_class = g_type_class_peek_parent (klass);
- label_object_class->copy = copy;
- label_object_class->get_size = get_size;
+ label_object_class->copy = copy;
+ label_object_class->get_size = get_size;
+ label_object_class->set_line_color = set_line_color;
object_class->finalize = gl_label_barcode_finalize;
}
gl_debug (DEBUG_LABEL, "END");
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set line color method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_line_color (glLabelObject *object,
+ guint line_color)
+{
+ glLabelBarcode *lbarcode = (glLabelBarcode *)object;
+
+ g_return_if_fail (lbarcode && GL_IS_LABEL_BARCODE (lbarcode));
+
+ if ( lbarcode->private->color != line_color ) {
+ lbarcode->private->color = line_color;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(lbarcode));
+ }
+}
+
static void copy (glLabelObject *dst_object,
glLabelObject *src_object);
+static void set_fill_color (glLabelObject *object,
+ guint fill_color);
+
+static void set_line_color (glLabelObject *object,
+ guint line_color);
+
+static void set_line_width (glLabelObject *object,
+ gdouble line_width);
+
+
\f
/*****************************************************************************/
/* Boilerplate object stuff. */
parent_class = g_type_class_peek_parent (klass);
- label_object_class->copy = copy;
+ label_object_class->copy = copy;
+ label_object_class->set_fill_color = set_fill_color;
+ label_object_class->set_line_color = set_line_color;
+ label_object_class->set_line_width = set_line_width;
object_class->finalize = gl_label_box_finalize;
}
return lbox->private->fill_color;
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set fill color method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_fill_color (glLabelObject *object,
+ guint fill_color)
+{
+ glLabelBox *lbox = (glLabelBox *)object;
+
+ g_return_if_fail (lbox && GL_IS_LABEL_BOX (lbox));
+
+ if ( lbox->private->fill_color != fill_color ) {
+ lbox->private->fill_color = fill_color;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(lbox));
+ }
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set line color method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_line_color (glLabelObject *object,
+ guint line_color)
+{
+ glLabelBox *lbox = (glLabelBox *)object;
+
+ g_return_if_fail (lbox && GL_IS_LABEL_BOX (lbox));
+
+ if ( lbox->private->line_color != line_color ) {
+ lbox->private->line_color = line_color;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(lbox));
+ }
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set line width method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_line_width (glLabelObject *object,
+ gdouble line_width)
+{
+ glLabelBox *lbox = (glLabelBox *)object;
+
+ g_return_if_fail (lbox && GL_IS_LABEL_BOX (lbox));
+
+ if ( lbox->private->line_width != line_width ) {
+ lbox->private->line_width = line_width;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(lbox));
+ }
+}
+
+
static void copy (glLabelObject *dst_object,
glLabelObject *src_object);
+static void set_fill_color (glLabelObject *object,
+ guint fill_color);
+
+static void set_line_color (glLabelObject *object,
+ guint line_color);
+
+static void set_line_width (glLabelObject *object,
+ gdouble line_width);
+
+
\f
/*****************************************************************************/
/* Boilerplate object stuff. */
parent_class = g_type_class_peek_parent (klass);
- label_object_class->copy = copy;
+ label_object_class->copy = copy;
+ label_object_class->set_fill_color = set_fill_color;
+ label_object_class->set_line_color = set_line_color;
+ label_object_class->set_line_width = set_line_width;
object_class->finalize = gl_label_ellipse_finalize;
}
return lellipse->private->fill_color;
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set fill color method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_fill_color (glLabelObject *object,
+ guint fill_color)
+{
+ glLabelEllipse *lellipse = (glLabelEllipse *)object;
+
+ g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
+
+ if ( lellipse->private->fill_color != fill_color ) {
+ lellipse->private->fill_color = fill_color;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(lellipse));
+ }
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set line color method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_line_color (glLabelObject *object,
+ guint line_color)
+{
+ glLabelEllipse *lellipse = (glLabelEllipse *)object;
+
+ g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
+
+ if ( lellipse->private->line_color != line_color ) {
+ lellipse->private->line_color = line_color;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(lellipse));
+ }
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set line width method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_line_width (glLabelObject *object,
+ gdouble line_width)
+{
+ glLabelEllipse *lellipse = (glLabelEllipse *)object;
+
+ g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
+
+ if ( lellipse->private->line_width != line_width ) {
+ lellipse->private->line_width = line_width;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(lellipse));
+ }
+}
+
+
static void copy (glLabelObject *dst_object,
glLabelObject *src_object);
+static void set_line_color (glLabelObject *object,
+ guint line_color);
+
+static void set_line_width (glLabelObject *object,
+ gdouble line_width);
+
+
\f
/*****************************************************************************/
/* Boilerplate object stuff. */
parent_class = g_type_class_peek_parent (klass);
- label_object_class->copy = copy;
+ label_object_class->copy = copy;
+ label_object_class->set_line_color = set_line_color;
+ label_object_class->set_line_width = set_line_width;
object_class->finalize = gl_label_line_finalize;
}
return lline->private->line_color;
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set line color method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_line_color (glLabelObject *object,
+ guint line_color)
+{
+ glLabelLine *lline = (glLabelLine *)object;
+
+ g_return_if_fail (lline && GL_IS_LABEL_LINE (lline));
+
+ if ( lline->private->line_color != line_color ) {
+ lline->private->line_color = line_color;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(lline));
+ }
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set line width method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_line_width (glLabelObject *object,
+ gdouble line_width)
+{
+ glLabelLine *lline = (glLabelLine *)object;
+
+ g_return_if_fail (lline && GL_IS_LABEL_LINE (lline));
+
+ if ( lline->private->line_width != line_width ) {
+ lline->private->line_width = line_width;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(lline));
+ }
+}
+
+
gl_debug (DEBUG_LABEL, "END");
}
+/*****************************************************************************/
+/* Can text properties be set for this object? */
+/*****************************************************************************/
+gboolean
+gl_label_object_can_text (glLabelObject *object)
+{
+ gl_debug (DEBUG_LABEL, "");
+
+ g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), FALSE);
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_font_family != NULL ) {
+
+ return TRUE;
+
+ } else {
+
+ return FALSE;
+
+ }
+
+}
+
+/*****************************************************************************/
+/* Set font family for all text contained in object. */
+/*****************************************************************************/
+void
+gl_label_object_set_font_family (glLabelObject *object,
+ const gchar *font_family)
+{
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_font_family != NULL ) {
+
+ /* We have an object specific method, use it */
+ GL_LABEL_OBJECT_GET_CLASS(object)->set_font_family (object, font_family);
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/****************************************************************************/
+/* Set font size for all text contained in object. */
+/****************************************************************************/
+void
+gl_label_object_set_font_size (glLabelObject *object,
+ gdouble font_size)
+{
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_font_size != NULL ) {
+
+ /* We have an object specific method, use it */
+ GL_LABEL_OBJECT_GET_CLASS(object)->set_font_size (object, font_size);
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/****************************************************************************/
+/* Set font weight for all text contained in object. */
+/****************************************************************************/
+void
+gl_label_object_set_font_weight (glLabelObject *object,
+ GnomeFontWeight font_weight)
+{
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_font_weight != NULL ) {
+
+ /* We have an object specific method, use it */
+ GL_LABEL_OBJECT_GET_CLASS(object)->set_font_weight (object, font_weight);
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/****************************************************************************/
+/* Set font italic flag for all text contained in object. */
+/****************************************************************************/
+void
+gl_label_object_set_font_italic_flag (glLabelObject *object,
+ GnomeFontWeight font_italic_flag)
+{
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_font_italic_flag != NULL ) {
+
+ /* We have an object specific method, use it */
+ GL_LABEL_OBJECT_GET_CLASS(object)->set_font_italic_flag (object,
+ font_italic_flag);
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/****************************************************************************/
+/* Set text alignment for all text contained in object. */
+/****************************************************************************/
+void
+gl_label_object_set_text_alignment (glLabelObject *object,
+ GtkJustification text_alignment)
+{
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_text_alignment != NULL ) {
+
+ /* We have an object specific method, use it */
+ GL_LABEL_OBJECT_GET_CLASS(object)->set_text_alignment (object,
+ text_alignment);
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/****************************************************************************/
+/* Set text color for all text contained in object. */
+/****************************************************************************/
+void
+gl_label_object_set_text_color (glLabelObject *object,
+ guint text_color)
+{
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_text_color != NULL ) {
+
+ /* We have an object specific method, use it */
+ GL_LABEL_OBJECT_GET_CLASS(object)->set_text_color (object, text_color);
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/*****************************************************************************/
+/* Can fill properties be set for this object? */
+/*****************************************************************************/
+gboolean
+gl_label_object_can_fill (glLabelObject *object)
+{
+ gl_debug (DEBUG_LABEL, "");
+
+ g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), FALSE);
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_fill_color != NULL ) {
+
+ return TRUE;
+
+ } else {
+
+ return FALSE;
+
+ }
+
+}
+
+/****************************************************************************/
+/* Set fill color for object. */
+/****************************************************************************/
+void
+gl_label_object_set_fill_color (glLabelObject *object,
+ guint fill_color)
+{
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_fill_color != NULL ) {
+
+ /* We have an object specific method, use it */
+ GL_LABEL_OBJECT_GET_CLASS(object)->set_fill_color (object, fill_color);
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/*****************************************************************************/
+/* Can line color property be set for this object? */
+/*****************************************************************************/
+gboolean
+gl_label_object_can_line_color (glLabelObject *object)
+{
+ gl_debug (DEBUG_LABEL, "");
+
+ g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), FALSE);
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_line_color != NULL ) {
+
+ return TRUE;
+
+ } else {
+
+ return FALSE;
+
+ }
+
+}
+
+/****************************************************************************/
+/* Set line color for object. */
+/****************************************************************************/
+void
+gl_label_object_set_line_color (glLabelObject *object,
+ guint line_color)
+{
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_line_color != NULL ) {
+
+ /* We have an object specific method, use it */
+ GL_LABEL_OBJECT_GET_CLASS(object)->set_line_color (object, line_color);
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/*****************************************************************************/
+/* Can line width property be set for this object? */
+/*****************************************************************************/
+gboolean
+gl_label_object_can_line_width (glLabelObject *object)
+{
+ gl_debug (DEBUG_LABEL, "");
+
+ g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), FALSE);
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_line_width != NULL ) {
+
+ return TRUE;
+
+ } else {
+
+ return FALSE;
+
+ }
+
+}
+
+/****************************************************************************/
+/* Set line width for object. */
+/****************************************************************************/
+void
+gl_label_object_set_line_width (glLabelObject *object,
+ gdouble line_width)
+{
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
+
+ if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_line_width != NULL ) {
+
+ /* We have an object specific method, use it */
+ GL_LABEL_OBJECT_GET_CLASS(object)->set_line_width (object, line_width);
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
/****************************************************************************/
/* Flip object horizontally. */
/****************************************************************************/
#define __LABEL_OBJECT_H__
#include <glib-object.h>
-
+#include <gtk/gtkenums.h>
+#include <libgnomeprint/gnome-font.h>
G_BEGIN_DECLS
* Methods
*/
- void (*set_size) (glLabelObject *object,
- gdouble w,
- gdouble h);
+ void (*set_size) (glLabelObject *object,
+ gdouble w,
+ gdouble h);
+
+ void (*get_size) (glLabelObject *object,
+ gdouble *w,
+ gdouble *h);
+
+ void (*set_font_family) (glLabelObject *object,
+ const gchar *font_family);
+
+ void (*set_font_size) (glLabelObject *object,
+ gdouble font_size);
+
+ void (*set_font_weight) (glLabelObject *object,
+ GnomeFontWeight font_weight);
+
+ void (*set_font_italic_flag) (glLabelObject *object,
+ gboolean font_italic_flag);
+
+ void (*set_text_alignment) (glLabelObject *object,
+ GtkJustification text_alignment);
- void (*get_size) (glLabelObject *object,
- gdouble *w,
- gdouble *h);
+ void (*set_text_color) (glLabelObject *object,
+ guint text_color);
- void (*copy) (glLabelObject *dst_object,
- glLabelObject *src_object);
+ void (*set_fill_color) (glLabelObject *object,
+ guint fill_color);
+
+ void (*set_line_color) (glLabelObject *object,
+ guint line_color);
+
+ void (*set_line_width) (glLabelObject *object,
+ gdouble line_width);
+
+ void (*copy) (glLabelObject *dst_object,
+ glLabelObject *src_object);
/*
* Signals
gdouble *x2,
gdouble *y2);
+gboolean gl_label_object_can_text (glLabelObject *object);
+
+void gl_label_object_set_font_family (glLabelObject *object,
+ const gchar *font_family);
+
+void gl_label_object_set_font_size (glLabelObject *object,
+ gdouble font_size);
+
+void gl_label_object_set_font_weight (glLabelObject *object,
+ GnomeFontWeight font_weight);
+
+void gl_label_object_set_font_italic_flag (glLabelObject *object,
+ GnomeFontWeight font_italic_flag);
+
+void gl_label_object_set_text_alignment (glLabelObject *object,
+ GtkJustification text_alignment);
+
+void gl_label_object_set_text_color (glLabelObject *object,
+ guint text_color);
+
+
+gboolean gl_label_object_can_fill (glLabelObject *object);
+
+void gl_label_object_set_fill_color (glLabelObject *object,
+ guint fill_color);
+
+
+gboolean gl_label_object_can_line_color (glLabelObject *object);
+
+void gl_label_object_set_line_color (glLabelObject *object,
+ guint line_color);
+
+gboolean gl_label_object_can_line_width (glLabelObject *object);
+
+void gl_label_object_set_line_width (glLabelObject *object,
+ gdouble line_width);
+
void gl_label_object_raise_to_top (glLabelObject *object);
gdouble *w,
gdouble *h);
+static void set_font_family (glLabelObject *object,
+ const gchar *font_family);
+
+static void set_font_size (glLabelObject *object,
+ gdouble font_size);
+
+static void set_font_weight (glLabelObject *object,
+ GnomeFontWeight font_weight);
+
+static void set_font_italic_flag (glLabelObject *object,
+ gboolean font_italic_flag);
+
+static void set_text_alignment (glLabelObject *object,
+ GtkJustification text_alignment);
+
+static void set_text_color (glLabelObject *object,
+ guint text_color);
+
\f
/*****************************************************************************/
/* Boilerplate object stuff. */
parent_class = g_type_class_peek_parent (klass);
- label_object_class->copy = copy;
- label_object_class->get_size = get_size;
+ label_object_class->copy = copy;
+
+ label_object_class->get_size = get_size;
+
+ label_object_class->set_font_family = set_font_family;
+ label_object_class->set_font_size = set_font_size;
+ label_object_class->set_font_weight = set_font_weight;
+ label_object_class->set_font_italic_flag = set_font_italic_flag;
+ label_object_class->set_text_alignment = set_text_alignment;
+ label_object_class->set_text_color = set_text_color;
object_class->finalize = gl_label_text_finalize;
}
g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
- /* Make sure we have a valid font family. if not privide a good default. */
+ /* Make sure we have a valid font family. if not provide a good default. */
family_names = gnome_font_family_list ();
if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) {
good_font_family = g_strdup (font_family);
gl_debug (DEBUG_LABEL, "END");
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. set font family method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_font_family (glLabelObject *object,
+ const gchar *font_family)
+{
+ glLabelText *ltext = (glLabelText *)object;
+ GList *family_names;
+ gchar *good_font_family;
+
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
+ g_return_if_fail (font_family);
+
+ family_names = gnome_font_family_list ();
+ if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) {
+ good_font_family = g_strdup (font_family);
+ } else {
+ if (family_names != NULL) {
+ good_font_family = g_strdup (family_names->data); /* 1st entry */
+ } else {
+ good_font_family = g_strdup (font_family);
+ }
+ }
+ gnome_font_family_list_free (family_names);
+
+ if (ltext->private->font_family) {
+ if (g_strcasecmp (ltext->private->font_family, good_font_family) == 0) {
+ gl_debug (DEBUG_LABEL, "END (no change)");
+ return;
+ }
+ g_free (ltext->private->font_family);
+ }
+ ltext->private->font_family = g_strdup (good_font_family);
+ g_free (good_font_family);
+
+ gl_debug (DEBUG_LABEL, "new font family = %s", ltext->private->font_family);
+
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(ltext));
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. set font size method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_font_size (glLabelObject *object,
+ gdouble font_size)
+{
+ glLabelText *ltext = (glLabelText *)object;
+
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
+
+ if (ltext->private->font_size != font_size) {
+
+ ltext->private->font_size = font_size;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(ltext));
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. set font weight method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_font_weight (glLabelObject *object,
+ GnomeFontWeight font_weight)
+{
+ glLabelText *ltext = (glLabelText *)object;
+
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
+
+ if (ltext->private->font_weight != font_weight) {
+
+ ltext->private->font_weight = font_weight;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(ltext));
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. set font italic flag method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_font_italic_flag (glLabelObject *object,
+ gboolean font_italic_flag)
+{
+ glLabelText *ltext = (glLabelText *)object;
+
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
+
+ if (ltext->private->font_italic_flag != font_italic_flag) {
+
+ ltext->private->font_italic_flag = font_italic_flag;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(ltext));
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. set text alignment method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_text_alignment (glLabelObject *object,
+ GtkJustification text_alignment)
+{
+ glLabelText *ltext = (glLabelText *)object;
+
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
+
+ if (ltext->private->just != text_alignment) {
+
+ ltext->private->just = text_alignment;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(ltext));
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. set text color method. */
+/*---------------------------------------------------------------------------*/
+static void
+set_text_color (glLabelObject *object,
+ guint text_color)
+{
+ glLabelText *ltext = (glLabelText *)object;
+
+ gl_debug (DEBUG_LABEL, "START");
+
+ g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
+
+ if (ltext->private->color != text_color) {
+
+ ltext->private->color = text_color;
+ gl_label_object_emit_changed (GL_LABEL_OBJECT(ltext));
+
+ }
+
+ gl_debug (DEBUG_LABEL, "END");
+}
+
--- /dev/null
+INCLUDES = \
+ $(GLABELS_CFLAGS) \
+ -DG_DISABLE_DEPRECATED \
+ -DGDK_DISABLE_DEPRECATED \
+ -DGTK_DISABLE_DEPRECATED \
+ -DGDK_PIXBUF_DISABLE_DEPRECATED \
+ -DGNOME_DISABLE_DEPRECATED
+
+noinst_LTLIBRARIES = libmygal.la
+
+libmygal_la_SOURCES = \
+ widget-color-combo.c \
+ widget-color-combo.h \
+ e-util.h \
+ e-colors.c \
+ e-colors.h \
+ gtk-combo-box.c \
+ gtk-combo-box.h \
+ color-palette.c \
+ color-palette.h \
+ color-group.c \
+ color-group.h \
+ e-marshal.c \
+ e-marshal.h
+
+marshal_sources = \
+ e-marshal.c \
+ e-marshal.h
+
+$(libmygal_la_OBJECTS) : $(marshal_sources)
+
+e-marshal.h: e-marshal.list $(GLIB_GENMARSHAL)
+ $(GLIB_GENMARSHAL) $< --header --prefix=e_marshal > $@
+e-marshal.c: e-marshal.list $(GLIB_GENMARSHAL)
+ $(GLIB_GENMARSHAL) $< --body --prefix=e_marshal > $@
+
+EXTRA_DIST = e-marshal.list
+CLEANFILES = $(marshal_sources)
+
+DONT_DIST_SOURCE = $(marshal_sources)
+
+dist-hook:
+ for file in $(DONT_DIST_SOURCE) ; do \
+ rm -f $(distdir)/$$file ; \
+ done
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * color-group.c - Utility to keep a shered memory of custom colors
+ * between arbitrary widgets.
+ * Copyright 2000, Michael Levy
+ * Copyright 2001, Almer S. Tigelaar
+ *
+ * Authors:
+ * Michael Levy (mlevy@genoscope.cns.fr)
+ * Revised and polished by:
+ * Almer S. Tigelaar <almer@gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "color-group.h"
+#include <glib-object.h>
+#include <gdk/gdkcolor.h>
+#include "e-util.h"
+#include <string.h>
+
+#define PARENT_TYPE G_TYPE_OBJECT
+
+enum {
+ CUSTOM_COLOR_ADD,
+ LAST_SIGNAL
+};
+
+static GObjectClass *parent_class;
+
+static GQuark color_group_signals [LAST_SIGNAL] = { 0 };
+
+static void color_group_finalize (GObject *obj);
+
+static void
+color_group_class_init (ColorGroupClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = (GObjectClass*) klass;
+
+ object_class->finalize = &color_group_finalize;
+ parent_class = g_type_class_peek (PARENT_TYPE);
+
+ color_group_signals [CUSTOM_COLOR_ADD] =
+ g_signal_new ("custom_color_add",
+ COLOR_GROUP_TYPE,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ColorGroupClass, custom_color_add),
+ (GSignalAccumulator) NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1, G_TYPE_POINTER);
+}
+
+static void
+color_group_init (ColorGroup *cg)
+{
+ cg->name = NULL;
+ cg->history = NULL;
+ cg->history_size = 0;
+}
+
+E_MAKE_TYPE(color_group,
+ "ColorGroup",
+ ColorGroup,
+ color_group_class_init,
+ color_group_init,
+ PARENT_TYPE)
+
+
+/* Hash table used to ensure unicity in newly created names*/
+static GHashTable *group_names = NULL;
+
+static guint
+cg_hash (gconstpointer key)
+{
+ /* Do NOT use smart type checking it will not work for the tmp_key */
+ return g_str_hash (((ColorGroup *)key)->name);
+}
+
+static gint
+cg_cmp (gconstpointer a, gconstpointer b)
+{
+ /* Do NOT use smart type checking it will not work for the tmp_key */
+ ColorGroup const *cg_a = (ColorGroup *)a;
+ ColorGroup const *cg_b = (ColorGroup *)b;
+ if (cg_a == cg_b)
+ return TRUE;
+ if (cg_a->context != cg_b->context)
+ return FALSE;
+ return g_str_equal (cg_a->name, cg_b->name);
+}
+
+static void
+initialize_group_names (void)
+{
+ g_assert (group_names == NULL);
+ group_names = g_hash_table_new (cg_hash, cg_cmp);
+}
+
+/**
+ * color_group_get :
+ * @name :
+ * @context :
+ *
+ * Look up the name/context specific color-group. Return NULL if it is not found.
+ * No reference is added if it is found.
+ */
+ColorGroup *
+color_group_get (const gchar * name, gpointer context)
+{
+ ColorGroup tmp_key;
+ gpointer res;
+
+ g_assert(group_names);
+
+ g_return_val_if_fail(name != NULL, NULL);
+
+ tmp_key.name = (char *)name;
+ tmp_key.context = context;
+ res = g_hash_table_lookup (group_names, &tmp_key);
+
+ if (res != NULL)
+ return COLOR_GROUP (res);
+ else
+ return NULL;
+}
+
+static gchar *
+create_unique_name (gpointer context)
+{
+ const gchar *prefix = "__cg_autogen_name__";
+ static gint latest_suff = 0;
+ gchar *new_name;
+
+ for(;;latest_suff++) {
+ new_name = g_strdup_printf("%s%i", prefix, latest_suff);
+ if (color_group_get (new_name, context) == NULL)
+ return new_name;
+ else
+ g_free(new_name);
+ }
+ g_assert_not_reached();
+}
+
+static void
+color_group_finalize (GObject *obj)
+{
+ ColorGroup *cg;
+
+ g_return_if_fail(obj != NULL);
+ g_return_if_fail(IS_COLOR_GROUP(obj));
+ g_assert(group_names != NULL);
+
+ cg = COLOR_GROUP (obj);
+
+ /* make this name available */
+ if (cg->name) {
+ g_hash_table_remove (group_names, cg);
+ g_free (cg->name);
+ cg->name = NULL;
+ }
+
+ if (cg->history) {
+ /* Free the whole colour history */
+ while ((int) cg->history->len > 0)
+ gdk_color_free ((GdkColor *)
+ g_ptr_array_remove_index (cg->history, 0));
+ g_ptr_array_free (cg->history, TRUE);
+ cg->history = NULL;
+ }
+
+ if (parent_class->finalize)
+ (parent_class->finalize) (obj);
+}
+
+/*
+ * color_group_get_history_size:
+ * Get the size of the custom color history
+ */
+gint
+color_group_get_history_size (ColorGroup *cg)
+{
+ g_return_val_if_fail (cg != NULL, 0);
+
+ return cg->history_size;
+}
+
+/*
+ * Change the size of the custom color history.
+ */
+void
+color_group_set_history_size (ColorGroup *cg, gint size)
+{
+ g_return_if_fail(cg != NULL);
+ g_return_if_fail(size >= 0);
+
+ /* Remove excess elements (begin with kicking out the oldest) */
+ while ((int) cg->history->len > size)
+ gdk_color_free ((GdkColor *) g_ptr_array_remove_index (cg->history, 0));
+}
+
+/*
+ * color_group_fetch :
+ * @name :
+ * @context :
+ *
+ * if name is NULL or a name not currently in use by another group
+ * then a new group is created and returned. If name was NULL
+ * then the new group is given a unique name prefixed by "__cg_autogen_name__"
+ * (thereby insuring namespace separation).
+ * If name was already used by a group then the reference count is
+ * incremented and a pointer to the group is returned.
+ */
+ColorGroup *
+color_group_fetch (const gchar *name, gpointer context)
+{
+ ColorGroup *cg;
+ gchar *new_name;
+
+ if (group_names == NULL)
+ initialize_group_names();
+
+ if (name == NULL)
+ new_name = create_unique_name (context);
+ else
+ new_name = g_strdup (name);
+
+ cg = color_group_get (new_name, context);
+ if (cg != NULL) {
+ g_free (new_name);
+ g_object_ref (G_OBJECT (cg));
+ return cg;
+ }
+
+ /* Take care of creating the new object */
+ cg = g_object_new (color_group_get_type (), NULL);
+ g_return_val_if_fail(cg != NULL, NULL);
+
+ cg->name = new_name;
+ cg->context = context;
+
+ /* Create history */
+ cg->history = g_ptr_array_new ();
+
+ /* FIXME: Why not 8? We never use more then 8 on the palette,
+ * maybe we can't free colors while they are still on the palette and
+ * need to be sure they are not on it when we free them and thus we
+ * make the upper limit twice the size of the number of displayed items
+ * (2 * 8) ?
+ */
+ cg->history_size = 16;
+
+ /* lastly register this name */
+ g_hash_table_insert (group_names, cg, cg);
+
+ return cg;
+}
+
+/*
+ * color_group_get_custom_colors:
+ * Retrieve all custom colors currently in the history using a callback
+ * mechanism. The custom colors will be passed from the oldest to the newest.
+ */
+void
+color_group_get_custom_colors (ColorGroup *cg, CbCustomColors callback, gpointer user_data)
+{
+ int i;
+
+ g_return_if_fail (cg != NULL);
+
+ /* Invoke the callback for our full history */
+ for (i = 0; i < (int) cg->history->len; i++) {
+ GdkColor const * const color = g_ptr_array_index (cg->history, i);
+
+ callback (color, user_data);
+ }
+}
+
+/*
+ * color_group_add_color:
+ * Changes the colors. The color to be set should always be a custom
+ * color! It has no use adding a color which is already in the default
+ * palette.
+ */
+void
+color_group_add_color (ColorGroup *cg, GdkColor const * const color)
+{
+ int i;
+
+ g_return_if_fail(cg != NULL);
+ g_return_if_fail(color != NULL); /* Can't be NULL */
+
+ /* Let's be smart and see if it's already in our history, no need to add it again*/
+ for (i = 0; i < (int) cg->history->len; i++) {
+ GdkColor *current = g_ptr_array_index (cg->history, i);
+
+ if (gdk_color_equal (color, current))
+ return;
+ }
+
+ /*
+ * We make our own private copy of the color passed and put
+ * it in the history, this is freed later.
+ */
+ if (cg->history_size > 0)
+ g_ptr_array_add (cg->history, gdk_color_copy (color));
+
+ /* Shift out the oldest item if we grow beyond our set size */
+ if ((int) cg->history->len > cg->history_size)
+ gdk_color_free ((GdkColor *) g_ptr_array_remove_index (cg->history, 0));
+
+ /* Tell color-palette's that use this group that
+ * a new custom color was added.
+ */
+ g_signal_emit (G_OBJECT(cg),
+ color_group_signals [CUSTOM_COLOR_ADD],
+ 0,
+ color);
+}
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * color-group.h - Utility to keep a shered memory of custom colors
+ * between arbitrary widgets.
+ * Copyright 2000, Michael Levy
+ * Copyright 2001, Almer S. Tigelaar
+ *
+ * Authors:
+ * Michael Levy (mlevy@genoscope.cns.fr)
+ * Revised and polished by:
+ * Almer S. Tigelaar <almer@gnome.org>
+ *
+ * Modified for gLabels by:
+ * Jim Evins <evins@snaught.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef GNOME_APP_LIB__COLOR_GROUP_H
+#define GNOME_APP_LIB__COLOR_GROUP_H
+
+#include <glib-object.h>
+#include <glib.h>
+#include <gdk/gdktypes.h>
+
+G_BEGIN_DECLS
+
+typedef gboolean (* CbCustomColors) (GdkColor const * const color, gpointer data);
+
+typedef struct _ColorGroup {
+ GObject parent;
+
+ gchar *name;
+ gpointer context;
+
+ GPtrArray *history; /* The custom color history */
+ gint history_size; /* length of color_history */
+} ColorGroup;
+
+typedef struct {
+ GObjectClass parent_class;
+
+ /* Signals emited by this object */
+ void (*custom_color_add) (ColorGroup *color_group, GdkColor const * const color);
+} ColorGroupClass;
+
+#define COLOR_GROUP_TYPE (color_group_get_type ())
+#define COLOR_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COLOR_GROUP_TYPE, ColorGroup))
+#define COLOR_GROUP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST (k), COLOR_GROUP_TYPE)
+#define IS_COLOR_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COLOR_GROUP_TYPE))
+
+GType color_group_get_type (void);
+ColorGroup *color_group_fetch (const gchar *name, gpointer context);
+ColorGroup *color_group_get (const gchar *name, gpointer context);
+
+void color_group_set_history_size (ColorGroup *cg, gint size);
+gint color_group_get_history_size (ColorGroup *cg);
+
+void color_group_get_custom_colors (ColorGroup *cg, CbCustomColors callback,
+ gpointer user_data);
+void color_group_add_color (ColorGroup *cg, GdkColor const * const color);
+
+G_END_DECLS
+
+#endif /* GNOME_APP_LIB__COLOR_GROUP_H */
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * color-palette.c - A color selector palette
+ * Copyright 2000, 2001, Ximian, Inc.
+ *
+ * Authors:
+ * This code was extracted from widget-color-combo.c
+ * written by Miguel de Icaza (miguel@kernel.org) and
+ * Dom Lachowicz (dominicl@seas.upenn.edu). The extracted
+ * code was re-packaged into a separate object by
+ * Michael Levy (mlevy@genoscope.cns.fr)
+ * And later revised and polished by
+ * Almer S. Tigelaar (almer@gnome.org)
+ *
+ * Modified for gLabels by:
+ * Jim Evins <evins@snaught.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gnome.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtktable.h>
+#include <libgnomecanvas/gnome-canvas.h>
+#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
+#include <gdk/gdkcolor.h>
+#include "e-util.h"
+#include "color-group.h"
+#include "color-palette.h"
+#include "e-colors.h"
+
+#define COLOR_PREVIEW_WIDTH 15
+#define COLOR_PREVIEW_HEIGHT 15
+
+enum {
+ COLOR_CHANGED,
+ LAST_SIGNAL
+};
+
+struct _ColorNamePair {
+ char *color; /* rgb color or otherwise - eg. "#FFFFFF" */
+ char *name; /* english name - eg. "white" */
+};
+
+static guint color_palette_signals [LAST_SIGNAL] = { 0, };
+
+#define PARENT_TYPE GTK_TYPE_VBOX
+static GObjectClass *color_palette_parent_class;
+
+#define make_color(P,COL) (((COL) != NULL) ? (COL) : ((P) ? ((P)->default_color) : NULL))
+
+static void
+color_palette_destroy (GtkObject *object)
+{
+ ColorPalette *P = COLOR_PALETTE (object);
+ GtkObjectClass *klass = (GtkObjectClass *)color_palette_parent_class;
+
+ if (P->tool_tip) {
+ g_object_unref (P->tool_tip);
+ P->tool_tip = NULL;
+ }
+
+ if (P->current_color) {
+ gdk_color_free (P->current_color);
+ P->current_color = NULL;
+ }
+
+ color_palette_set_group (P, NULL);
+
+ memset (P->items, 0, P->total * sizeof (GnomeCanvasItem *));
+
+ if (klass->destroy)
+ klass->destroy (object);
+}
+
+static void
+color_palette_finalize (GObject *object)
+{
+ ColorPalette *P = COLOR_PALETTE (object);
+
+ g_free (P->items);
+
+ (*color_palette_parent_class->finalize) (object);
+}
+
+static void
+color_palette_class_init (GObjectClass *object_class)
+{
+ object_class->finalize = color_palette_finalize;
+ ((GtkObjectClass *)object_class)->destroy = color_palette_destroy;
+
+ color_palette_parent_class = g_type_class_peek_parent (object_class);
+
+ color_palette_signals [COLOR_CHANGED] =
+ g_signal_new ("color_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ColorPaletteClass, color_changed),
+ NULL, NULL,
+ e_marshal_NONE__POINTER_BOOLEAN_BOOLEAN_BOOLEAN,
+ G_TYPE_NONE, 4, G_TYPE_POINTER,
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
+}
+
+E_MAKE_TYPE (color_palette,
+ "ColorPalette",
+ ColorPalette,
+ color_palette_class_init,
+ NULL,
+ PARENT_TYPE)
+
+static void
+emit_color_changed (ColorPalette *P, GdkColor *color,
+ gboolean custom, gboolean by_user, gboolean is_default)
+{
+ GdkColor *new = make_color (P, color);
+
+ if (new != NULL)
+ new = gdk_color_copy (new);
+ if (P->current_color)
+ gdk_color_free (P->current_color);
+ P->current_color = new;
+ P->current_is_default = is_default;
+
+ /* Only add custom colors to the group */
+ if (custom && color)
+ color_group_add_color (P->color_group, color);
+
+ g_signal_emit (P, color_palette_signals [COLOR_CHANGED], 0,
+ color, custom, by_user, is_default);
+}
+
+
+/*
+ * Add the new custom color as the first custom color in the custom color rows
+ * and shift all of the others 'one step down'
+ *
+ * Also take care of setting up the GnomeColorPicker 'display'
+ */
+static void
+color_palette_change_custom_color (ColorPalette *P, GdkColor const * const new)
+{
+ int index;
+ GnomeCanvasItem *item;
+ GnomeCanvasItem *next_item;
+
+ g_return_if_fail (P != NULL);
+ g_return_if_fail (new != NULL);
+ g_return_if_fail (P->picker);
+
+ /* make sure there is room */
+ if (P->custom_color_pos == -1)
+ return;
+
+ for (index = P->custom_color_pos; index < P->total - 1; index++) {
+ GdkColor *color;
+ GdkColor *outline;
+ item = P->items[index];
+ next_item = P->items[index + 1];
+
+ g_object_get (G_OBJECT (next_item),
+ "fill_color_gdk", &color,
+ "outline_color_gdk", &outline,
+ NULL);
+ gnome_canvas_item_set (item,
+ "fill_color_gdk", color,
+ "outline_color_gdk", outline,
+ NULL);
+ gdk_color_free (color);
+ gdk_color_free (outline);
+ }
+ item = P->items[index];
+ gnome_canvas_item_set (item,
+ "fill_color_gdk", new,
+ "outline_color_gdk", new,
+ NULL);
+ gnome_color_picker_set_i16 (P->picker,
+ new->red,
+ new->green,
+ new->blue,
+ 0);
+}
+
+/*
+ * The custom color box was clicked. Find out its value and emit it
+ * And add it to the custom color row
+ */
+static void
+cust_color_set (GtkWidget *color_picker, guint r, guint g, guint b, guint a,
+ ColorPalette *P)
+{
+ GdkColor c_color;
+
+ c_color.red = (gushort)r;
+ c_color.green = (gushort)g;
+ c_color.blue = (gushort)b;
+
+ e_color_alloc_gdk (NULL, &c_color);
+ emit_color_changed (P, &c_color, TRUE, TRUE, FALSE);
+}
+
+static void
+cb_default_clicked (GtkWidget *button, ColorPalette *P)
+{
+ emit_color_changed (P, P->default_color, FALSE, TRUE, TRUE);
+}
+
+/*
+ * Something in our table was clicked. Find out what and emit it
+ */
+static void
+color_clicked (GtkWidget *button, ColorPalette *P)
+{
+ int index;
+ GnomeCanvasItem *item;
+ GdkColor *gdk_color;
+
+ index = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (button)));
+ item = P->items[index];
+
+ g_object_get (item,
+ "fill_color_gdk", &gdk_color,
+ NULL);
+
+ emit_color_changed (P, gdk_color, FALSE, TRUE, FALSE);
+
+ gdk_color_free (gdk_color);
+}
+
+/*
+ * The color group sent the 'custom_color_add' signal
+ */
+static void
+cb_group_custom_color_add (GtkObject *cg, GdkColor *color, ColorPalette *P)
+{
+ GdkColor *new;
+
+ new = make_color (P, color);
+ color_palette_change_custom_color (P, new);
+}
+
+/*
+ * Find out if a color is in the default palette (not in the custom colors!)
+ *
+ * Utility function
+ */
+static gboolean
+color_in_palette (ColorNamePair *set, GdkColor *color)
+{
+ int i;
+
+ g_return_val_if_fail (set != NULL, FALSE);
+
+ if (color == NULL)
+ return TRUE;
+
+ /* Iterator over all the colors and try to find
+ * if we can find @color
+ */
+ for (i = 0; set[i].color != NULL; i++) {
+ GdkColor current;
+
+ gdk_color_parse (set[i].color, ¤t);
+
+ if (gdk_color_equal (color, ¤t))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ * Create the individual color buttons
+ *
+ * Utility function
+ */
+static GnomeCanvasItem *
+color_palette_button_new(ColorPalette *P, GtkTable* table,
+ GtkTooltips *tool_tip, ColorNamePair* color_name,
+ gint col, gint row, int data)
+{
+ GtkWidget *button;
+ GtkWidget *canvas;
+ GnomeCanvasItem *item;
+
+ button = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+
+ canvas = gnome_canvas_new ();
+
+ gtk_widget_set_usize (canvas, COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT);
+ gtk_container_add (GTK_CONTAINER (button), canvas);
+
+ item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (gnome_canvas_root
+ (GNOME_CANVAS (canvas))),
+ gnome_canvas_rect_get_type (),
+ "x1", 0.0,
+ "y1", 0.0,
+ "x2", (double) COLOR_PREVIEW_WIDTH,
+ "y2", (double) COLOR_PREVIEW_HEIGHT,
+ "fill_color", color_name->color,
+ NULL);
+
+ gtk_tooltips_set_tip (tool_tip, button, _(color_name->name),
+ "Private+Unused");
+
+ gtk_table_attach (table, button,
+ col, col+1, row, row+1, GTK_FILL, GTK_FILL, 1, 1);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (color_clicked), P);
+ gtk_object_set_user_data (GTK_OBJECT (button),
+ GINT_TO_POINTER (data));
+ return item;
+}
+
+static void
+cb_custom_colors (GdkColor const * const color, gpointer data)
+{
+ ColorPalette *P = data;
+
+ if (color)
+ color_palette_change_custom_color (P, color);
+}
+
+/*
+ * gets history information from the group
+ */
+static void
+custom_color_history_setup(ColorPalette *P)
+{
+ g_return_if_fail (P != NULL);
+ g_return_if_fail (P->color_group != NULL);
+
+ /* Sync our own palette with all the custom colors in the group */
+ color_group_get_custom_colors (P->color_group, (CbCustomColors) cb_custom_colors, P);
+}
+
+/*
+ * Creates the color table
+ */
+static GtkWidget *
+color_palette_setup (ColorPalette *P,
+ char const * const no_color_label,
+ int ncols, int nrows,
+ ColorNamePair *color_names)
+{
+ GtkWidget *default_button;
+ GtkWidget *cust_label;
+ GtkWidget *table;
+ GtkTooltips *tool_tip;
+ int total, row, col;
+
+ table = gtk_table_new (ncols, nrows, FALSE);
+
+ if (no_color_label != NULL) {
+ default_button = gtk_button_new_with_label (no_color_label);
+
+ gtk_table_attach (GTK_TABLE (table), default_button,
+ 0, ncols, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
+ g_signal_connect (default_button, "clicked",
+ G_CALLBACK (cb_default_clicked), P);
+ }
+
+ P->tool_tip = tool_tip = gtk_tooltips_new ();
+ g_object_ref (P->tool_tip);
+ gtk_object_sink (GTK_OBJECT (P->tool_tip));
+
+ P->custom_color_pos = -1;
+ total = 0;
+
+ for (row = 0; row < nrows; row++) {
+ for (col = 0; col < ncols; col++) {
+ int pos;
+
+ pos = row * ncols + col;
+ /*
+ * If we are done with all of the colors in color_names
+ */
+ if (color_names [pos].color == NULL) {
+ /* This is the default custom color */
+ ColorNamePair color_name = {"#000", N_("custom")};
+ row++;
+ if (col == 0 || row < nrows) {
+ /* Add a full row for custom colors */
+ for (col = 0; col < ncols; col++) {
+ /* Have we set custom pos yet ? */
+ if (P->custom_color_pos == -1) {
+ P->custom_color_pos = total;
+ }
+ P->items[total] =
+ color_palette_button_new(
+ P,
+ GTK_TABLE (table),
+ GTK_TOOLTIPS (tool_tip),
+ &(color_name),
+ col,
+ row + 1,
+ total);
+ total++;
+ }
+ }
+ /* Break out of two for-loops. */
+ row = nrows;
+ break;
+ }
+
+ P->items[total] =
+ color_palette_button_new (
+ P,
+ GTK_TABLE (table),
+ GTK_TOOLTIPS (tool_tip),
+ &(color_names [pos]),
+ col,
+ row + 1,
+ total);
+ total++;
+ }
+ }
+ P->total = total;
+
+
+ /* "Custom" color - we'll pop up a GnomeColorPicker */
+ cust_label = gtk_label_new (_("Custom Color:"));
+ gtk_table_attach (GTK_TABLE (table), cust_label, 0, ncols - 3 ,
+ row + 1, row + 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
+ /*
+ Keep a poier to the picker so that we can update it's color
+ to keep it in synch with that of other members of the group
+ */
+ P->picker = GNOME_COLOR_PICKER (gnome_color_picker_new ());
+ gnome_color_picker_set_title (P->picker, _("Choose Custom Color"));
+ gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (P->picker), ncols - 3, ncols,
+ row + 1, row + 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
+ g_signal_connect (P->picker, "color_set",
+ G_CALLBACK (cust_color_set), P);
+ return table;
+}
+
+void
+color_palette_set_color_to_default (ColorPalette *P)
+{
+ g_return_if_fail (P != NULL);
+ g_return_if_fail (IS_COLOR_GROUP (P->color_group));
+
+ emit_color_changed (P, P->default_color, FALSE, TRUE, TRUE);
+}
+
+void
+color_palette_set_current_color (ColorPalette *P, GdkColor *color)
+{
+ g_return_if_fail (P != NULL);
+ g_return_if_fail (IS_COLOR_GROUP (P->color_group));
+
+ if (color)
+ emit_color_changed
+ (P, color, color_in_palette (P->default_set, color),
+ FALSE, FALSE);
+ else
+ color_palette_set_color_to_default (P);
+}
+
+GdkColor *
+color_palette_get_current_color (ColorPalette *P, gboolean *is_default)
+{
+ g_return_val_if_fail (P != NULL, NULL);
+ g_return_val_if_fail (IS_COLOR_GROUP (P->color_group), NULL);
+
+ if (is_default != NULL)
+ *is_default = P->current_is_default;
+
+ return P->current_color ? gdk_color_copy (P->current_color) : NULL;
+}
+
+GtkWidget *
+color_palette_get_color_picker (ColorPalette *P)
+{
+ g_return_val_if_fail (IS_COLOR_PALETTE (P), NULL);
+
+ return GTK_WIDGET (P->picker);
+}
+
+
+/*
+ * Where the actual construction goes on
+ */
+static void
+color_palette_construct (ColorPalette *P,
+ char const * const no_color_label,
+ int ncols, int nrows)
+{
+ GtkWidget * table;
+ g_return_if_fail (P != NULL);
+ g_return_if_fail (IS_COLOR_PALETTE (P));
+
+ P->items = g_malloc (sizeof (GnomeCanvasItem *) * ncols * nrows);
+
+ /*
+ * Our table selector
+ */
+ table = color_palette_setup (P, no_color_label, ncols,
+ nrows, P->default_set);
+ gtk_container_add (GTK_CONTAINER(P), table);
+}
+
+/*
+ * More verbose constructor. Allows for specifying the rows, columns, and
+ * Colors this palette will contain
+ *
+ * Note that if after placing all of the color_names there remains an entire
+ * row available then a row of custum colors (initialized to black) is added
+ *
+ */
+static GtkWidget*
+color_palette_new_with_vals (char const * const no_color_label,
+ int ncols, int nrows, ColorNamePair *color_names,
+ GdkColor *default_color,
+ ColorGroup *cg)
+{
+ ColorPalette *P;
+
+ g_return_val_if_fail (color_names != NULL, NULL);
+
+ P = g_object_new (COLOR_PALETTE_TYPE, NULL);
+
+ P->default_set = color_names;
+ P->default_color = default_color;
+ P->current_color = default_color ? gdk_color_copy (default_color) : NULL;
+ P->current_is_default = TRUE;
+ color_palette_set_group (P, cg);
+
+ color_palette_construct (P, no_color_label, ncols, nrows);
+ custom_color_history_setup(P);
+
+ return GTK_WIDGET (P);
+}
+
+/**
+ * color_palette_set_group : absorbs the reference to the group
+ */
+void
+color_palette_set_group (ColorPalette *P, ColorGroup *cg)
+{
+ if (P->color_group == cg)
+ return;
+
+ if (P->color_group) {
+ g_signal_handlers_disconnect_by_func (
+ G_OBJECT (P->color_group),
+ G_CALLBACK (cb_group_custom_color_add),
+ P);
+ g_object_unref (G_OBJECT (P->color_group));
+ P->color_group = NULL;
+ }
+ if (cg != NULL) {
+ P->color_group = COLOR_GROUP (cg);
+ g_signal_connect (G_OBJECT (cg), "custom_color_add",
+ G_CALLBACK (cb_group_custom_color_add),
+ P);
+
+ }
+}
+
+static ColorNamePair default_color_set [] = {
+ {"#000000", N_("black")},
+ {"#993300", N_("light brown")},
+ {"#333300", N_("brown gold")},
+ {"#003300", N_("dark green #2")},
+ {"#003366", N_("navy")},
+ {"#000080", N_("dark blue")},
+ {"#333399", N_("purple #2")},
+ {"#333333", N_("very dark gray")},
+
+
+ {"#800000", N_("dark red")},
+ {"#FF6600", N_("red-orange")},
+ {"#808000", N_("gold")},
+ {"#008000", N_("dark green")},
+ {"#008080", N_("dull blue")},
+ {"#0000FF", N_("blue")},
+ {"#666699", N_("dull purple")},
+ {"#808080", N_("dark grey")},
+
+
+ {"#FF0000", N_("red")},
+ {"#FF9900", N_("orange")},
+ {"#99CC00", N_("lime")},
+ {"#339966", N_("dull green")},
+ {"#33CCCC",N_("dull blue #2")},
+ {"#3366FF", N_("sky blue #2")},
+ {"#800080", N_("purple")},
+ {"#969696", N_("gray")},
+
+
+ {"#FF00FF", N_("magenta")},
+ {"#FFCC00", N_("bright orange")},
+ {"#FFFF00", N_("yellow")},
+ {"#00FF00", N_("green")},
+ {"#00FFFF", N_("cyan")},
+ {"#00CCFF", N_("bright blue")},
+ {"#993366", N_("red purple")},
+ {"#C0C0C0", N_("light grey")},
+
+
+ {"#FF99CC", N_("pink")},
+ {"#FFCC99", N_("light orange")},
+ {"#FFFF99", N_("light yellow")},
+ {"#CCFFCC", N_("light green")},
+ {"#CCFFFF", N_("light cyan")},
+ {"#99CCFF", N_("light blue")},
+ {"#CC99FF", N_("light purple")},
+ {"#FFFFFF", N_("white")},
+
+ /* Disable these for now, they are mostly repeats */
+ {NULL, NULL},
+
+ {"#9999FF", N_("purplish blue")},
+ {"#993366", N_("red purple")},
+ {"#FFFFCC", N_("light yellow")},
+ {"#CCFFFF", N_("light blue")},
+ {"#660066", N_("dark purple")},
+ {"#FF8080", N_("pink")},
+ {"#0066CC", N_("sky blue")},
+ {"#CCCCFF", N_("light purple")},
+
+ {"#000080", N_("dark blue")},
+ {"#FF00FF", N_("magenta")},
+ {"#FFFF00", N_("yellow")},
+ {"#00FFFF", N_("cyan")},
+ {"#800080", N_("purple")},
+ {"#800000", N_("dark red")},
+ {"#008080", N_("dull blue")},
+ {"#0000FF", N_("blue")},
+
+ {NULL, NULL}
+};
+
+
+
+/*
+ * Default constructor. Pass an optional label for
+ * the no/auto color button.
+ *
+ */
+GtkWidget*
+color_palette_new (const char *no_color_label,
+ GdkColor *default_color, ColorGroup *color_group)
+{
+ /* specify 6 rows to allow for a row of custom colors */
+ return color_palette_new_with_vals (no_color_label,
+ 8, 6,
+ default_color_set, default_color,
+ color_group);
+}
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * color-palette.h - A color selector palette
+ * Copyright 2000, 2001, Ximian, Inc.
+ *
+ * Authors:
+ * This code was extracted from widget-color-combo.c
+ * written by Miguel de Icaza (miguel@kernel.org) and
+ * Dom Lachowicz (dominicl@seas.upenn.edu). The extracted
+ * code was re-packaged into a separate object by
+ * Michael Levy (mlevy@genoscope.cns.fr)
+ * And later revised and polished by
+ * Almer S. Tigelaar (almer@gnome.org)
+ *
+ * Modified for gLabels by:
+ * Jim Evins <evins@snaught.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef GNUMERIC_COLOR_PALETTE_H
+#define GNUMERIC_COLOR_PALETTE_H
+
+#include <gtk/gtktooltips.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtkwidget.h>
+#include <libgnomecanvas/gnome-canvas.h>
+#include <libgnomeui/gnome-color-picker.h>
+#include "color-group.h"
+
+G_BEGIN_DECLS
+
+typedef struct _ColorNamePair ColorNamePair;
+
+typedef struct _ColorPalette {
+ GtkVBox vbox;
+ GtkTooltips *tool_tip;
+ GnomeColorPicker *picker;
+ /*
+ * Array of colors
+ */
+ GnomeCanvasItem **items;
+ /* The (potentially NULL) default color */
+ GdkColor *default_color;
+
+ /* The current color */
+ GdkColor *current_color;
+ gboolean current_is_default;
+
+ /*
+ * Position of the last possible position
+ * for custom colors in **items
+ * (i.e. custom colors go from items[custom_color_pos]
+ * to items[total - 1])
+ *
+ * If custom_color_pos == -1, there is no room for custom colors
+ */
+ int custom_color_pos;
+ /*
+ * Number of default colors in **items
+ */
+ int total;
+
+ /* The table with our default color names */
+ ColorNamePair *default_set;
+
+ /* The color group to which we belong */
+ ColorGroup *color_group;
+} ColorPalette;
+
+typedef struct {
+ GtkVBoxClass parent_class;
+
+ /* Signals emited by this widget */
+ void (* color_changed) (ColorPalette *color_palette, GdkColor *color,
+ gboolean custom, gboolean by_user, gboolean is_default);
+} ColorPaletteClass;
+
+#define COLOR_PALETTE_TYPE (color_palette_get_type ())
+#define COLOR_PALETTE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), COLOR_PALETTE_TYPE, ColorPalette))
+#define COLOR_PALETTE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST(k), COLOR_PALETTE_TYPE)
+#define IS_COLOR_PALETTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), COLOR_PALETTE_TYPE))
+
+GtkType color_palette_get_type (void);
+
+GtkWidget *color_palette_new (const char *no_color_label,
+ GdkColor *default_color,
+ ColorGroup *color_group);
+void color_palette_set_group (ColorPalette *P,
+ ColorGroup *cg);
+
+void color_palette_set_current_color (ColorPalette *P, GdkColor *color);
+void color_palette_set_color_to_default (ColorPalette *P);
+GdkColor *color_palette_get_current_color (ColorPalette *P, gboolean *is_default);
+GtkWidget *color_palette_get_color_picker (ColorPalette *P);
+
+G_END_DECLS
+
+#endif /* GNUMERIC_PALETTE_H */
+
+
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-colors.c - General color allocation utilities
+ * Copyright 2000, 2001, Ximian, Inc.
+ *
+ * Authors:
+ * Miguel de Icaza (miguel@kernel.org)
+ *
+ * Modified for gLabels by:
+ * Jim Evins <evins@snaught.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+/* We keep our own color context, as the color allocation might take
+ * place before things are realized.
+ */
+
+#include <config.h>
+#include <gtk/gtkwidget.h>
+#include "e-colors.h"
+
+GdkColor e_white, e_dark_gray, e_black;
+
+gulong
+e_color_alloc (gushort red, gushort green, gushort blue)
+{
+ e_color_init ();
+
+ red >>= 8;
+ green >>= 8;
+ blue >>= 8;
+ return gdk_rgb_xpixel_from_rgb (
+ ((red & 0xff) << 16) | ((green & 0xff) << 8) |
+ (blue & 0xff));
+}
+
+void
+e_color_alloc_gdk (GtkWidget *widget, GdkColor *c)
+{
+ GdkColormap *map;
+
+ e_color_init ();
+
+ if (widget)
+ map = gtk_widget_get_colormap (widget);
+ else /* FIXME: multi depth broken ? */
+ map = gtk_widget_get_default_colormap ();
+
+ gdk_rgb_find_color (map, c);
+}
+
+void
+e_color_alloc_name (GtkWidget *widget, const char *name, GdkColor *c)
+{
+ GdkColormap *map;
+
+ e_color_init ();
+
+ gdk_color_parse (name, c);
+
+ if (widget)
+ map = gtk_widget_get_colormap (widget);
+ else /* FIXME: multi depth broken ? */
+ map = gtk_widget_get_default_colormap ();
+
+ gdk_rgb_find_color (map, c);
+}
+
+void
+e_color_init (void)
+{
+ static gboolean e_color_inited = FALSE;
+
+ /* It's surprisingly easy to end up calling this twice. Survive. */
+ if (e_color_inited)
+ return;
+
+ e_color_inited = TRUE;
+
+ /* Allocate the default colors */
+ e_white.red = 65535;
+ e_white.green = 65535;
+ e_white.blue = 65535;
+ e_color_alloc_gdk (NULL, &e_white);
+
+ e_black.red = 0;
+ e_black.green = 0;
+ e_black.blue = 0;
+ e_color_alloc_gdk (NULL, &e_black);
+
+ e_color_alloc_name (NULL, "gray20", &e_dark_gray);
+}
+
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-colors.h
+ * Copyright 2000, 2001, Ximian, Inc.
+ *
+ * Authors:
+ * Miguel de Icaza (miguel@kernel.org)
+ *
+ * Modified for gLabels by:
+ * Jim Evins <evins@snaught.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef GNOME_APP_LIBS_COLOR_H
+#define GNOME_APP_LIBS_COLOR_H
+
+#include <glib.h>
+#include <gdk/gdk.h>
+#include <gtk/gtkwidget.h>
+
+G_BEGIN_DECLS
+
+void e_color_init (void);
+
+/* Return the pixel value for the given red, green and blue */
+gulong e_color_alloc (gushort red, gushort green, gushort blue);
+void e_color_alloc_name (GtkWidget *widget, const char *name, GdkColor *color);
+void e_color_alloc_gdk (GtkWidget *widget, GdkColor *color);
+
+extern GdkColor e_white, e_dark_gray, e_black;
+
+G_END_DECLS
+
+#endif /* GNOME_APP_LIBS_COLOR_H */
--- /dev/null
+BOOLEAN:INT,INT,OBJECT,INT,INT,UINT
+BOOLEAN:INT,POINTER,INT,OBJECT,INT,INT,UINT
+BOOLEAN:NONE
+BOOLEAN:OBJECT
+BOOLEAN:OBJECT,DOUBLE,DOUBLE,BOOLEAN
+BOOLEAN:POINTER,POINTER,INT,INT,INT
+BOOLEAN:POINTER,POINTER,POINTER,INT,INT,INT
+BOOLEAN:STRING,INT
+DOUBLE:OBJECT,DOUBLE,DOUBLE,BOOLEAN
+INT:BOXED
+INT:INT
+INT:INT,INT,BOXED
+INT:INT,POINTER,INT,BOXED
+INT:OBJECT,BOXED
+INT:POINTER
+NONE:BOXED
+NONE:BOXED,INT
+NONE:BOXED,INT,INT
+NONE:DOUBLE
+NONE:INT
+NONE:INT,INT
+NONE:INT,INT,BOXED
+NONE:INT,INT,OBJECT
+NONE:INT,INT,OBJECT,BOXED,UINT,UINT
+NONE:INT,INT,OBJECT,INT,INT,BOXED,UINT,UINT
+NONE:INT,INT,OBJECT,POINTER,UINT,UINT
+NONE:INT,INT,OBJECT,UINT
+NONE:INT,INT,STRING,STRING
+NONE:INT,INT,STRING,STRING,POINTER
+NONE:INT,POINTER
+NONE:INT,POINTER,INT,BOXED
+NONE:INT,POINTER,INT,OBJECT
+NONE:INT,POINTER,INT,OBJECT,BOXED,UINT,UINT
+NONE:INT,POINTER,INT,OBJECT,INT,INT,BOXED,UINT,UINT
+NONE:INT,POINTER,INT,OBJECT,UINT
+NONE:INT,STRING
+NONE:NONE
+NONE:OBJECT
+NONE:OBJECT,OBJECT
+NONE:OBJECT,DOUBLE,DOUBLE,BOOLEAN
+NONE:POINTER
+NONE:POINTER,BOOLEAN
+NONE:POINTER,BOOLEAN,BOOLEAN,BOOLEAN
+NONE:POINTER,INT
+NONE:POINTER,INT,INT
+NONE:POINTER,INT,INT,INT
+NONE:POINTER,INT,OBJECT
+NONE:POINTER,POINTER
+NONE:POINTER,POINTER,INT
+OBJECT:OBJECT,DOUBLE,DOUBLE,BOOLEAN
+POINTER:NONE
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-util.h
+ * Copyright 2000, 2001, Ximian, Inc.
+ *
+ * Authors:
+ * Chris Lahey <clahey@ximian.com>
+ *
+ * Modified for gLabels by:
+ * Jim Evins <evins@snaught.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _E_UTIL_H_
+#define _E_UTIL_H_
+
+#include <sys/types.h>
+#include <glib-object.h>
+#include <limits.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#include "e-marshal.h"
+
+#define E_MAKE_TYPE(l,str,t,ci,i,parent) \
+GType l##_get_type(void)\
+{\
+ static GType type = 0; \
+ if (!type){ \
+ static GTypeInfo const object_info = { \
+ sizeof (t##Class), \
+ \
+ (GBaseInitFunc) NULL, \
+ (GBaseFinalizeFunc) NULL, \
+ \
+ (GClassInitFunc) ci, \
+ (GClassFinalizeFunc) NULL, \
+ NULL, /* class_data */ \
+ \
+ sizeof (t), \
+ 0, /* n_preallocs */ \
+ (GInstanceInitFunc) i, \
+ }; \
+ type = g_type_register_static (parent, str, &object_info, 0); \
+ } \
+ return type; \
+}
+
+
+#define E_MAKE_X_TYPE(l,str,t,ci,i,parent,poa_init,offset) \
+GtkType l##_get_type(void) \
+{ \
+ static GtkType type = 0; \
+ if (!type){ \
+ GTypeInfo info = { \
+ sizeof (t##Class), \
+ \
+ (GBaseInitFunc) NULL, \
+ (GBaseFinalizeFunc) NULL, \
+ \
+ (GClassInitFunc) ci, \
+ (GClassFinalizeFunc) NULL, \
+ \
+ NULL, /* class_data */ \
+ \
+ sizeof (t), \
+ 0, /* n_preallocs */ \
+ (GInstanceInitFunc) i, \
+ }; \
+ type = bonobo_x_type_unique ( \
+ parent, poa_init, NULL, \
+ offset, &info, str); \
+ } \
+ return type; \
+}
+
+#define GET_STRING_ARRAY_FROM_ELLIPSIS(labels, first_string) \
+ { \
+ va_list args; \
+ int i; \
+ char *s; \
+ \
+ va_start (args, (first_string)); \
+ \
+ i = 0; \
+ for (s = (first_string); s; s = va_arg (args, char *)) \
+ i++; \
+ va_end (args); \
+ \
+ (labels) = g_new (char *, i + 1); \
+ \
+ va_start (args, (first_string)); \
+ i = 0; \
+ for (s = (first_string); s; s = va_arg (args, char *)) \
+ (labels)[i++] = s; \
+ \
+ va_end (args); \
+ (labels)[i] = NULL; \
+ }
+
+
+#define GET_DUPLICATED_STRING_ARRAY_FROM_ELLIPSIS(labels, first_string) \
+ { \
+ int i; \
+ GET_STRING_ARRAY_FROM_ELLIPSIS ((labels), (first_string)); \
+ for (i = 0; labels[i]; i++) \
+ labels[i] = g_strdup (labels[i]); \
+ }
+
+
+#if 0
+# define E_OBJECT_CLASS_ADD_SIGNALS(oc,sigs,last) \
+ gtk_object_class_add_signals (oc, sigs, last)
+# define E_OBJECT_CLASS_TYPE(oc) (oc)->type
+#else
+# define E_OBJECT_CLASS_ADD_SIGNALS(oc,sigs,last)
+# define E_OBJECT_CLASS_TYPE(oc) G_TYPE_FROM_CLASS (oc)
+#endif
+
+
+typedef enum {
+ E_FOCUS_NONE,
+ E_FOCUS_CURRENT,
+ E_FOCUS_START,
+ E_FOCUS_END
+} EFocus;
+int g_str_compare (const void *x,
+ const void *y);
+int g_collate_compare (const void *x,
+ const void *y);
+int g_int_compare (const void *x,
+ const void *y);
+char *e_strdup_strip (const char *string);
+void e_free_object_list (GList *list);
+void e_free_object_slist (GSList *list);
+void e_free_string_list (GList *list);
+void e_free_string_slist (GSList *list);
+char *e_read_file (const char *filename);
+int e_write_file (const char *filename,
+ const char *data,
+ int flags);
+int e_write_file_mkstemp (char *filename,
+ const char *data);
+int e_mkdir_hier (const char *path,
+ mode_t mode);
+
+gchar **e_strsplit (const gchar *string,
+ const gchar *delimiter,
+ gint max_tokens);
+gchar *e_strstrcase (const gchar *haystack,
+ const gchar *needle);
+/* This only makes a filename safe for usage as a filename. It still may have shell meta-characters in it. */
+void e_filename_make_safe (gchar *string);
+gchar *e_format_number (gint number);
+gchar *e_format_number_float (gfloat number);
+gboolean e_create_directory (gchar *directory);
+gchar **e_strdupv (const gchar **str_array);
+
+
+typedef int (*ESortCompareFunc) (const void *first,
+ const void *second,
+ gpointer closure);
+void e_sort (void *base,
+ size_t nmemb,
+ size_t size,
+ ESortCompareFunc compare,
+ gpointer closure);
+void e_bsearch (const void *key,
+ const void *base,
+ size_t nmemb,
+ size_t size,
+ ESortCompareFunc compare,
+ gpointer closure,
+ size_t *start,
+ size_t *end);
+size_t e_strftime_fix_am_pm (char *s,
+ size_t max,
+ const char *fmt,
+ const struct tm *tm);
+
+size_t e_strftime (char *s,
+ size_t max,
+ const char *fmt,
+ const struct tm *tm);
+
+size_t e_utf8_strftime_fix_am_pm (char *s,
+ size_t max,
+ const char *fmt,
+ const struct tm *tm);
+
+size_t e_utf8_strftime (char *s,
+ size_t max,
+ const char *fmt,
+ const struct tm *tm);
+
+/* String to/from double conversion functions */
+gdouble e_flexible_strtod (const gchar *nptr,
+ gchar **endptr);
+
+/* 29 bytes should enough for all possible values that
+ * g_ascii_dtostr can produce with the %.17g format.
+ * Then add 10 for good measure */
+#define E_ASCII_DTOSTR_BUF_SIZE (DBL_DIG + 12 + 10)
+gchar *e_ascii_dtostr (gchar *buffer,
+ gint buf_len,
+ const gchar *format,
+ gdouble d);
+
+/* Alternating char * and int arguments with a NULL char * to end.
+ Less than 0 for the int means copy the whole string. */
+gchar *e_strdup_append_strings (gchar *first_string,
+ ...);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _E_UTIL_H_ */
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * gtk-combo-box.c - a customizable combobox
+ * Copyright 2000, 2001, Ximian, Inc.
+ *
+ * Authors:
+ * Miguel de Icaza (miguel@gnu.org)
+ * Adrian E Feiguin (feiguin@ifir.edu.ar)
+ * Paolo Molnaro (lupus@debian.org).
+ * Jon K Hellan (hellan@acm.org)
+ *
+ * Modified for gLabels by:
+ * Jim Evins <evins@snaught.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtktogglebutton.h>
+#include <gtk/gtkarrow.h>
+#include <gtk/gtkeventbox.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtkwindow.h>
+#include <gtk/gtkframe.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtktearoffmenuitem.h>
+#include <gdk/gdkkeysyms.h>
+#include "gtk-combo-box.h"
+#include "e-util.h"
+
+#define PARENT_TYPE GTK_TYPE_HBOX
+static GObjectClass *gtk_combo_box_parent_class;
+
+static int gtk_combo_toggle_pressed (GtkToggleButton *tbutton,
+ GtkComboBox *combo_box);
+static void gtk_combo_popup_tear_off (GtkComboBox *combo,
+ gboolean set_position);
+static void gtk_combo_set_tearoff_state (GtkComboBox *combo,
+ gboolean torn_off);
+static void gtk_combo_popup_reparent (GtkWidget *popup, GtkWidget *new_parent,
+ gboolean unrealize);
+static gboolean cb_popup_delete (GtkWidget *w, GdkEventAny *event,
+ GtkComboBox *combo);
+static void gtk_combo_tearoff_bg_copy (GtkComboBox *combo);
+
+enum {
+ POP_DOWN_WIDGET,
+ POP_DOWN_DONE,
+ PRE_POP_DOWN,
+ POST_POP_HIDE,
+ LAST_SIGNAL
+};
+
+static guint gtk_combo_box_signals [LAST_SIGNAL] = { 0, };
+
+struct _GtkComboBoxPrivate {
+ GtkWidget *pop_down_widget;
+ GtkWidget *display_widget;
+
+ /*
+ * Internal widgets used to implement the ComboBox
+ */
+ GtkWidget *frame;
+ GtkWidget *arrow_button;
+
+ GtkWidget *toplevel; /* Popup's toplevel when not torn off */
+ GtkWidget *tearoff_window; /* Popup's toplevel when torn off */
+ guint torn_off;
+
+ GtkWidget *tearable; /* The tearoff "button" */
+ GtkWidget *popup; /* Popup */
+
+ /*
+ * Closure for invoking the callbacks above
+ */
+ void *closure;
+};
+
+static void
+gtk_combo_box_finalize (GObject *object)
+{
+ GtkComboBox *combo_box = GTK_COMBO_BOX (object);
+
+ g_free (combo_box->priv);
+
+ gtk_combo_box_parent_class->finalize (object);
+}
+
+static void
+gtk_combo_box_destroy (GtkObject *object)
+{
+ GtkObjectClass *klass = (GtkObjectClass *)gtk_combo_box_parent_class;
+ GtkComboBox *combo_box = GTK_COMBO_BOX (object);
+
+ if (combo_box->priv->toplevel) {
+ gtk_object_destroy (GTK_OBJECT (combo_box->priv->toplevel));
+ combo_box->priv->toplevel = NULL;
+ }
+
+ if (combo_box->priv->tearoff_window) {
+ gtk_object_destroy (GTK_OBJECT (combo_box->priv->tearoff_window));
+ combo_box->priv->tearoff_window = NULL;
+ }
+
+ if (klass->destroy)
+ klass->destroy (object);
+}
+
+static gboolean
+gtk_combo_box_mnemonic_activate (GtkWidget *w, gboolean group_cycling)
+{
+ GtkComboBox *combo_box = GTK_COMBO_BOX (w);
+ gtk_toggle_button_set_active (
+ GTK_TOGGLE_BUTTON (combo_box->priv->arrow_button), TRUE);
+ return TRUE;
+}
+
+static void
+gtk_combo_box_class_init (GObjectClass *object_class)
+{
+ GtkWidgetClass *widget_class = (GtkWidgetClass *)object_class;
+ gtk_combo_box_parent_class = g_type_class_peek_parent (object_class);
+
+ object_class->finalize = gtk_combo_box_finalize;
+ widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
+ ((GtkObjectClass *)object_class)->destroy = gtk_combo_box_destroy;
+
+ gtk_combo_box_signals [POP_DOWN_WIDGET] = g_signal_new (
+ "pop_down_widget",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkComboBoxClass, pop_down_widget),
+ NULL, NULL,
+ e_marshal_POINTER__NONE,
+ G_TYPE_POINTER, 0, G_TYPE_NONE);
+
+ gtk_combo_box_signals [POP_DOWN_DONE] = g_signal_new (
+ "pop_down_done",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkComboBoxClass, pop_down_done),
+ NULL, NULL,
+ e_marshal_BOOLEAN__OBJECT,
+ G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT);
+
+ gtk_combo_box_signals [PRE_POP_DOWN] = g_signal_new (
+ "pre_pop_down",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkComboBoxClass, pre_pop_down),
+ NULL, NULL,
+ e_marshal_NONE__NONE,
+ G_TYPE_NONE, 0);
+
+ gtk_combo_box_signals [POST_POP_HIDE] = g_signal_new (
+ "post_pop_hide",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkComboBoxClass, post_pop_hide),
+ NULL, NULL,
+ e_marshal_NONE__NONE,
+ G_TYPE_NONE, 0);
+}
+
+static void
+deactivate_arrow (GtkComboBox *combo_box)
+{
+ GtkToggleButton *arrow;
+
+ arrow = GTK_TOGGLE_BUTTON (combo_box->priv->arrow_button);
+ g_signal_handlers_block_matched (arrow,
+ G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL,
+ gtk_combo_toggle_pressed, combo_box);
+
+ gtk_toggle_button_set_active (arrow, FALSE);
+
+ g_signal_handlers_unblock_matched (arrow,
+ G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL,
+ gtk_combo_toggle_pressed, combo_box);
+}
+
+/**
+ * gtk_combo_box_popup_hide_unconditional
+ * @combo_box: Combo box
+ *
+ * Hide popup, whether or not it is torn off.
+ */
+static void
+gtk_combo_box_popup_hide_unconditional (GtkComboBox *combo_box)
+{
+ gboolean popup_info_destroyed = FALSE;
+
+ g_return_if_fail (combo_box != NULL);
+ g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+
+ gtk_widget_hide (combo_box->priv->toplevel);
+ gtk_widget_hide (combo_box->priv->popup);
+ if (combo_box->priv->torn_off) {
+ GTK_TEAROFF_MENU_ITEM (combo_box->priv->tearable)->torn_off
+ = FALSE;
+ gtk_combo_set_tearoff_state (combo_box, FALSE);
+ }
+
+ gtk_grab_remove (combo_box->priv->toplevel);
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
+
+ g_object_ref (combo_box->priv->pop_down_widget);
+ g_signal_emit (combo_box,
+ gtk_combo_box_signals [POP_DOWN_DONE], 0,
+ combo_box->priv->pop_down_widget, &popup_info_destroyed);
+
+ if (popup_info_destroyed){
+ gtk_container_remove (
+ GTK_CONTAINER (combo_box->priv->frame),
+ combo_box->priv->pop_down_widget);
+ combo_box->priv->pop_down_widget = NULL;
+ }
+ g_object_unref (combo_box->priv->pop_down_widget);
+ deactivate_arrow (combo_box);
+
+ g_signal_emit (combo_box, gtk_combo_box_signals [POST_POP_HIDE], 0);
+}
+
+/**
+ * gtk_combo_box_popup_hide:
+ * @combo_box: Combo box
+ *
+ * Hide popup, but not when it is torn off.
+ * This is the external interface - for subclasses and apps which expect a
+ * regular combo which doesn't do tearoffs.
+ */
+void
+gtk_combo_box_popup_hide (GtkComboBox *combo_box)
+{
+ if (!combo_box->priv->torn_off)
+ gtk_combo_box_popup_hide_unconditional (combo_box);
+ else if (GTK_WIDGET_VISIBLE (combo_box->priv->toplevel)) {
+ /* Both popup and tearoff window present. Get rid of just
+ the popup shell. */
+ gtk_combo_popup_tear_off (combo_box, FALSE);
+ deactivate_arrow (combo_box);
+ }
+}
+
+/*
+ * Find best location for displaying
+ */
+void
+gtk_combo_box_get_pos (GtkComboBox *combo_box, int *x, int *y)
+{
+ GtkWidget *wcombo = GTK_WIDGET (combo_box);
+ int ph, pw;
+
+ gdk_window_get_origin (wcombo->window, x, y);
+ *y += wcombo->allocation.height + wcombo->allocation.y;
+ *x += wcombo->allocation.x;
+
+ ph = combo_box->priv->popup->allocation.height;
+ pw = combo_box->priv->popup->allocation.width;
+
+ if ((*y + ph) > gdk_screen_height ())
+ *y = gdk_screen_height () - ph;
+
+ if ((*x + pw) > gdk_screen_width ())
+ *x = gdk_screen_width () - pw;
+}
+
+static void
+gtk_combo_box_popup_display (GtkComboBox *combo_box)
+{
+ int x, y;
+
+ g_return_if_fail (combo_box != NULL);
+ g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+
+ /*
+ * If we have no widget to display on the popdown,
+ * create it
+ */
+ if (!combo_box->priv->pop_down_widget){
+ GtkWidget *pw = NULL;
+
+ g_signal_emit (combo_box,
+ gtk_combo_box_signals [POP_DOWN_WIDGET], 0, &pw);
+ g_assert (pw != NULL);
+ combo_box->priv->pop_down_widget = pw;
+ gtk_container_add (GTK_CONTAINER (combo_box->priv->frame), pw);
+ }
+
+ g_signal_emit (combo_box, gtk_combo_box_signals [PRE_POP_DOWN], 0);
+
+ if (combo_box->priv->torn_off) {
+ /* To give the illusion that tearoff still displays the
+ * popup, we copy the image in the popup window to the
+ * background. Thus, it won't be blank after reparenting */
+ gtk_combo_tearoff_bg_copy (combo_box);
+
+ /* We force an unrealize here so that we don't trigger
+ * redrawing/ clearing code - we just want to reveal our
+ * backing pixmap.
+ */
+ gtk_combo_popup_reparent (combo_box->priv->popup,
+ combo_box->priv->toplevel, TRUE);
+ }
+
+ gtk_combo_box_get_pos (combo_box, &x, &y);
+
+ gtk_widget_set_uposition (combo_box->priv->toplevel, x, y);
+ gtk_widget_realize (combo_box->priv->popup);
+ gtk_widget_show (combo_box->priv->popup);
+ gtk_widget_realize (combo_box->priv->toplevel);
+ gtk_widget_show (combo_box->priv->toplevel);
+
+ gtk_grab_add (combo_box->priv->toplevel);
+ gdk_pointer_grab (combo_box->priv->toplevel->window, TRUE,
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK,
+ NULL, NULL, GDK_CURRENT_TIME);
+}
+
+static int
+gtk_combo_toggle_pressed (GtkToggleButton *tbutton, GtkComboBox *combo_box)
+{
+ if (tbutton->active)
+ gtk_combo_box_popup_display (combo_box);
+ else
+ gtk_combo_box_popup_hide_unconditional (combo_box);
+
+ return TRUE;
+}
+
+static gint
+gtk_combo_box_button_press (GtkWidget *widget, GdkEventButton *event, GtkComboBox *combo_box)
+{
+ GtkWidget *child;
+
+ child = gtk_get_event_widget ((GdkEvent *) event);
+ if (child != widget){
+ while (child){
+ if (child == widget)
+ return FALSE;
+ child = child->parent;
+ }
+ }
+
+ gtk_combo_box_popup_hide (combo_box);
+ return TRUE;
+}
+
+/**
+ * gtk_combo_box_key_press
+ * @widget: Widget
+ * @event: Event
+ * @combo_box: Combo box
+ *
+ * Key press handler which dismisses popup on escape.
+ * Popup is dismissed whether or not popup is torn off.
+ */
+static gint
+gtk_combo_box_key_press (GtkWidget *widget, GdkEventKey *event,
+ GtkComboBox *combo_box)
+{
+ if (event->keyval == GDK_Escape) {
+ gtk_combo_box_popup_hide_unconditional (combo_box);
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+static void
+cb_state_change (GtkWidget *widget, GtkStateType old_state, GtkComboBox *combo_box)
+{
+ GtkStateType const new_state = GTK_WIDGET_STATE(widget);
+ gtk_widget_set_state (combo_box->priv->display_widget, new_state);
+}
+
+static void
+gtk_combo_box_init (GtkComboBox *combo_box)
+{
+ GtkWidget *arrow;
+ GdkCursor *cursor;
+
+ combo_box->priv = g_new0 (GtkComboBoxPrivate, 1);
+
+ /*
+ * Create the arrow
+ */
+ combo_box->priv->arrow_button = gtk_toggle_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (combo_box->priv->arrow_button), GTK_RELIEF_NONE);
+ GTK_WIDGET_UNSET_FLAGS (combo_box->priv->arrow_button, GTK_CAN_FOCUS);
+
+ arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN);
+ gtk_container_add (GTK_CONTAINER (combo_box->priv->arrow_button), arrow);
+ gtk_box_pack_end (GTK_BOX (combo_box), combo_box->priv->arrow_button, FALSE, FALSE, 0);
+ g_signal_connect (combo_box->priv->arrow_button, "toggled",
+ G_CALLBACK (gtk_combo_toggle_pressed), combo_box);
+ gtk_widget_show_all (combo_box->priv->arrow_button);
+
+ /*
+ * prelight the display widget when mousing over the arrow.
+ */
+ g_signal_connect (combo_box->priv->arrow_button, "state-changed",
+ G_CALLBACK (cb_state_change), combo_box);
+
+ /*
+ * The pop-down container
+ */
+
+ combo_box->priv->toplevel = gtk_window_new (GTK_WINDOW_POPUP);
+ gtk_widget_ref (combo_box->priv->toplevel);
+ gtk_object_sink (GTK_OBJECT (combo_box->priv->toplevel));
+ gtk_window_set_policy (GTK_WINDOW (combo_box->priv->toplevel),
+ FALSE, TRUE, FALSE);
+
+ combo_box->priv->popup = gtk_event_box_new ();
+ gtk_container_add (GTK_CONTAINER (combo_box->priv->toplevel),
+ combo_box->priv->popup);
+ gtk_widget_show (combo_box->priv->popup);
+
+ gtk_widget_realize (combo_box->priv->popup);
+ cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW);
+ gdk_window_set_cursor (combo_box->priv->popup->window, cursor);
+ gdk_cursor_unref (cursor);
+
+ combo_box->priv->torn_off = FALSE;
+ combo_box->priv->tearoff_window = NULL;
+
+ combo_box->priv->frame = gtk_frame_new (NULL);
+ gtk_container_add (GTK_CONTAINER (combo_box->priv->popup),
+ combo_box->priv->frame);
+ gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->frame), GTK_SHADOW_OUT);
+
+ g_signal_connect (combo_box->priv->toplevel, "button_press_event",
+ G_CALLBACK (gtk_combo_box_button_press), combo_box);
+ g_signal_connect (combo_box->priv->toplevel, "key_press_event",
+ G_CALLBACK (gtk_combo_box_key_press), combo_box);
+}
+
+E_MAKE_TYPE (gtk_combo_box,
+ "MyGtkComboBox",
+ GtkComboBox,
+ gtk_combo_box_class_init,
+ gtk_combo_box_init,
+ PARENT_TYPE)
+
+/**
+ * gtk_combo_box_set_display:
+ * @combo_box: the Combo Box to modify
+ * @display_widget: The widget to be displayed
+
+ * Sets the displayed widget for the @combo_box to be @display_widget
+ */
+void
+gtk_combo_box_set_display (GtkComboBox *combo_box, GtkWidget *display_widget)
+{
+ g_return_if_fail (combo_box != NULL);
+ g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+ g_return_if_fail (display_widget != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (display_widget));
+
+ if (combo_box->priv->display_widget &&
+ combo_box->priv->display_widget != display_widget)
+ gtk_container_remove (GTK_CONTAINER (combo_box),
+ combo_box->priv->display_widget);
+
+ combo_box->priv->display_widget = display_widget;
+
+ gtk_box_pack_start (GTK_BOX (combo_box), display_widget, TRUE, TRUE, 0);
+}
+
+static gboolean
+cb_tearable_enter_leave (GtkWidget *w, GdkEventCrossing *event, gpointer data)
+{
+ gboolean const flag = GPOINTER_TO_INT(data);
+ gtk_widget_set_state (w, flag ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL);
+ return FALSE;
+}
+
+/**
+ * gtk_combo_popup_tear_off
+ * @combo: Combo box
+ * @set_position: Set to position of popup shell if true
+ *
+ * Tear off the popup
+ *
+ * FIXME:
+ * Gtk popup menus are toplevel windows, not dialogs. I think this is wrong,
+ * and make the popups dialogs. But may be there should be a way to make
+ * them toplevel. We can do this after creating:
+ * GTK_WINDOW (tearoff)->type = GTK_WINDOW_TOPLEVEL;
+ */
+static void
+gtk_combo_popup_tear_off (GtkComboBox *combo, gboolean set_position)
+{
+ int x, y;
+
+ if (!combo->priv->tearoff_window) {
+ GtkWidget *tearoff;
+ gchar *title;
+
+ /* FIXME: made this a toplevel, not a dialog ! */
+ tearoff = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_widget_ref (tearoff);
+ gtk_object_sink (GTK_OBJECT (tearoff));
+ combo->priv->tearoff_window = tearoff;
+ gtk_widget_set_app_paintable (tearoff, TRUE);
+ g_signal_connect (tearoff, "key_press_event",
+ G_CALLBACK (gtk_combo_box_key_press),
+ combo);
+ gtk_widget_realize (tearoff);
+ title = g_object_get_data (G_OBJECT (combo),
+ "gtk-combo-title");
+ if (title)
+ gdk_window_set_title (tearoff->window, title);
+ gtk_window_set_policy (GTK_WINDOW (tearoff),
+ FALSE, TRUE, FALSE);
+ gtk_window_set_transient_for
+ (GTK_WINDOW (tearoff),
+ GTK_WINDOW (gtk_widget_get_toplevel
+ GTK_WIDGET (combo)));
+ }
+
+ if (GTK_WIDGET_VISIBLE (combo->priv->popup)) {
+ gtk_widget_hide (combo->priv->toplevel);
+
+ gtk_grab_remove (combo->priv->toplevel);
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ }
+
+ gtk_combo_popup_reparent (combo->priv->popup,
+ combo->priv->tearoff_window, FALSE);
+
+ /* It may have got confused about size */
+ gtk_widget_queue_resize (GTK_WIDGET (combo->priv->popup));
+
+ if (set_position) {
+ gtk_combo_box_get_pos (combo, &x, &y);
+ gtk_widget_set_uposition (combo->priv->tearoff_window, x, y);
+ }
+ gtk_widget_show (GTK_WIDGET (combo->priv->popup));
+ gtk_widget_show (combo->priv->tearoff_window);
+
+}
+
+/**
+ * gtk_combo_set_tearoff_state
+ * @combo_box: Combo box
+ * @torn_off: TRUE: Tear off. FALSE: Pop down and reattach
+ *
+ * Set the tearoff state of the popup
+ *
+ * Compare with gtk_menu_set_tearoff_state in gtk/gtkmenu.c
+ */
+static void
+gtk_combo_set_tearoff_state (GtkComboBox *combo,
+ gboolean torn_off)
+{
+ g_return_if_fail (combo != NULL);
+ g_return_if_fail (GTK_IS_COMBO_BOX (combo));
+
+ if (combo->priv->torn_off != torn_off) {
+ combo->priv->torn_off = torn_off;
+
+ if (combo->priv->torn_off) {
+ gtk_combo_popup_tear_off (combo, TRUE);
+ deactivate_arrow (combo);
+ } else {
+ gtk_widget_hide (combo->priv->tearoff_window);
+ gtk_combo_popup_reparent (combo->priv->popup,
+ combo->priv->toplevel,
+ FALSE);
+ }
+ }
+}
+
+/**
+ * gtk_combo_tearoff_bg_copy
+ * @combo_box: Combo box
+ *
+ * Copy popup window image to the tearoff window.
+ */
+static void
+gtk_combo_tearoff_bg_copy (GtkComboBox *combo)
+{
+ GdkPixmap *pixmap;
+ GdkGC *gc;
+ GdkGCValues gc_values;
+
+ GtkWidget *widget = combo->priv->popup;
+
+ if (combo->priv->torn_off) {
+ gc_values.subwindow_mode = GDK_INCLUDE_INFERIORS;
+ gc = gdk_gc_new_with_values (widget->window,
+ &gc_values, GDK_GC_SUBWINDOW);
+
+ pixmap = gdk_pixmap_new (widget->window,
+ widget->allocation.width,
+ widget->allocation.height,
+ -1);
+
+ gdk_draw_drawable (pixmap, gc,
+ widget->window,
+ 0, 0, 0, 0, -1, -1);
+ gdk_gc_unref (gc);
+
+ gtk_widget_set_usize (combo->priv->tearoff_window,
+ widget->allocation.width,
+ widget->allocation.height);
+
+ gdk_window_set_back_pixmap
+ (combo->priv->tearoff_window->window, pixmap, FALSE);
+ gdk_drawable_unref (pixmap);
+ }
+}
+
+/**
+ * gtk_combo_popup_reparent
+ * @popup: Popup
+ * @new_parent: New parent
+ * @unrealize: Unrealize popup if TRUE.
+ *
+ * Reparent the popup, taking care of the refcounting
+ *
+ * Compare with gtk_menu_reparent in gtk/gtkmenu.c
+ */
+static void
+gtk_combo_popup_reparent (GtkWidget *popup,
+ GtkWidget *new_parent,
+ gboolean unrealize)
+{
+ GtkObject *object = GTK_OBJECT (popup);
+ gboolean was_floating = GTK_OBJECT_FLOATING (object);
+
+ g_object_ref (object);
+ gtk_object_sink (object);
+
+ if (unrealize) {
+ g_object_ref (object);
+ gtk_container_remove (GTK_CONTAINER (popup->parent), popup);
+ gtk_container_add (GTK_CONTAINER (new_parent), popup);
+ g_object_unref (object);
+ }
+ else
+ gtk_widget_reparent (GTK_WIDGET (popup), new_parent);
+ gtk_widget_set_usize (new_parent, -1, -1);
+
+ if (was_floating)
+ GTK_OBJECT_SET_FLAGS (object, GTK_FLOATING);
+ else
+ g_object_unref (object);
+}
+
+/**
+ * cb_tearable_button_release
+ * @w: Widget
+ * @event: Event
+ * @combo: Combo box
+ *
+ * Toggle tearoff state.
+ */
+static gboolean
+cb_tearable_button_release (GtkWidget *w, GdkEventButton *event,
+ GtkComboBox *combo)
+{
+ GtkTearoffMenuItem *tearable;
+
+ g_return_val_if_fail (w != NULL, FALSE);
+ g_return_val_if_fail (GTK_IS_TEAROFF_MENU_ITEM (w), FALSE);
+
+ tearable = GTK_TEAROFF_MENU_ITEM (w);
+ tearable->torn_off = !tearable->torn_off;
+
+ if (!combo->priv->torn_off) {
+ gboolean need_connect;
+
+ need_connect = (!combo->priv->tearoff_window);
+ gtk_combo_set_tearoff_state (combo, TRUE);
+ if (need_connect)
+ g_signal_connect (combo->priv->tearoff_window,
+ "delete_event",
+ G_CALLBACK (cb_popup_delete),
+ combo);
+ } else
+ gtk_combo_box_popup_hide_unconditional (combo);
+
+ return TRUE;
+}
+
+static gboolean
+cb_popup_delete (GtkWidget *w, GdkEventAny *event, GtkComboBox *combo)
+{
+ gtk_combo_box_popup_hide_unconditional (combo);
+ return TRUE;
+}
+
+void
+gtk_combo_box_construct (GtkComboBox *combo_box, GtkWidget *display_widget, GtkWidget *pop_down_widget)
+{
+ GtkWidget *tearable;
+ GtkWidget *vbox;
+
+ g_return_if_fail (combo_box != NULL);
+ g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+ g_return_if_fail (display_widget != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (display_widget));
+
+ GTK_BOX (combo_box)->spacing = 0;
+ GTK_BOX (combo_box)->homogeneous = FALSE;
+
+ combo_box->priv->pop_down_widget = pop_down_widget;
+ combo_box->priv->display_widget = NULL;
+
+ vbox = gtk_vbox_new (FALSE, 5);
+ tearable = gtk_tearoff_menu_item_new ();
+ g_signal_connect (tearable, "enter-notify-event",
+ G_CALLBACK (cb_tearable_enter_leave),
+ GINT_TO_POINTER (TRUE));
+ g_signal_connect (tearable, "leave-notify-event",
+ G_CALLBACK (cb_tearable_enter_leave),
+ GINT_TO_POINTER (FALSE));
+ g_signal_connect (tearable, "button-release-event",
+ G_CALLBACK (cb_tearable_button_release),
+ (gpointer) combo_box);
+ gtk_box_pack_start (GTK_BOX (vbox), tearable, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), pop_down_widget, TRUE, TRUE, 0);
+ combo_box->priv->tearable = tearable;
+
+ /*
+ * Finish setup
+ */
+ gtk_combo_box_set_display (combo_box, display_widget);
+
+ gtk_container_add (GTK_CONTAINER (combo_box->priv->frame), vbox);
+ gtk_widget_show_all (combo_box->priv->frame);
+}
+
+GtkWidget *
+gtk_combo_box_new (GtkWidget *display_widget, GtkWidget *optional_popdown)
+{
+ GtkComboBox *combo_box;
+
+ g_return_val_if_fail (display_widget != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_WIDGET (display_widget), NULL);
+
+ combo_box = g_object_new (GTK_COMBO_BOX_TYPE, NULL);
+ gtk_combo_box_construct (combo_box, display_widget, optional_popdown);
+ return GTK_WIDGET (combo_box);
+}
+
+void
+gtk_combo_box_set_arrow_relief (GtkComboBox *cc, GtkReliefStyle relief)
+{
+ g_return_if_fail (cc != NULL);
+ g_return_if_fail (GTK_IS_COMBO_BOX (cc));
+
+ gtk_button_set_relief (GTK_BUTTON (cc->priv->arrow_button), relief);
+}
+
+/**
+ * gtk_combo_box_set_title
+ * @combo: Combo box
+ * @title: Title
+ *
+ * Set a title to display over the tearoff window.
+ *
+ * FIXME:
+ *
+ * This should really change the title even when the popup is already torn off.
+ * I guess the tearoff window could attach a listener to title change or
+ * something. But I don't think we need the functionality, so I didn't bother
+ * to investigate.
+ */
+void
+gtk_combo_box_set_title (GtkComboBox *combo,
+ const gchar *title)
+{
+ g_return_if_fail (combo != NULL);
+ g_return_if_fail (GTK_IS_COMBO_BOX (combo));
+
+ g_object_set_data_full (G_OBJECT (combo), "gtk-combo-title",
+ g_strdup (title), (GDestroyNotify) g_free);
+}
+
+/**
+ * gtk_combo_box_set_arrow_sensitive
+ * @combo: Combo box
+ * @sensitive: Sensitivity value
+ *
+ * Toggle the sensitivity of the arrow button
+ */
+
+void
+gtk_combo_box_set_arrow_sensitive (GtkComboBox *combo,
+ gboolean sensitive)
+{
+ g_return_if_fail (combo != NULL);
+
+ gtk_widget_set_sensitive (combo->priv->arrow_button, sensitive);
+}
+
+/**
+ * gtk_combo_box_set_tearable:
+ * @combo: Combo box
+ * @tearable: whether to allow the @combo to be tearable
+ *
+ * controls whether the combo box's pop up widget can be torn off.
+ */
+void
+gtk_combo_box_set_tearable (GtkComboBox *combo, gboolean tearable)
+{
+ g_return_if_fail (combo != NULL);
+ g_return_if_fail (GTK_IS_COMBO_BOX (combo));
+
+ if (tearable){
+ gtk_widget_show (combo->priv->tearable);
+ } else {
+ gtk_combo_set_tearoff_state (combo, FALSE);
+ gtk_widget_hide (combo->priv->tearable);
+ }
+}
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * gtk-combo-box.h - a customizable combobox
+ * Copyright 2000, 2001, Ximian, Inc.
+ *
+ * Authors:
+ * Miguel de Icaza <miguel@ximian.com>
+ *
+ * Modified for gLabels by:
+ * Jim Evins <evins@snaught.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _GTK_COMBO_BOX_H_
+#define _GTK_COMBO_BOX_H_
+
+#include <gtk/gtkhbox.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define GTK_COMBO_BOX_TYPE (gtk_combo_box_get_type())
+#define GTK_COMBO_BOX(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_combo_box_get_type (), GtkComboBox)
+#define GTK_COMBO_BOX_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gtk_combo_box_get_type (), GtkComboBoxClass)
+#define GTK_IS_COMBO_BOX(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gtk_combo_box_get_type ())
+
+typedef struct _GtkComboBox GtkComboBox;
+typedef struct _GtkComboBoxPrivate GtkComboBoxPrivate;
+typedef struct _GtkComboBoxClass GtkComboBoxClass;
+
+struct _GtkComboBox {
+ GtkHBox hbox;
+ GtkComboBoxPrivate *priv;
+};
+
+struct _GtkComboBoxClass {
+ GtkHBoxClass parent_class;
+
+ GtkWidget *(*pop_down_widget) (GtkComboBox *cbox);
+
+ /*
+ * invoked when the popup has been hidden, if the signal
+ * returns TRUE, it means it should be killed from the
+ */
+ gboolean *(*pop_down_done) (GtkComboBox *cbox, GtkWidget *);
+
+ /*
+ * Notification signals.
+ */
+ void (*pre_pop_down) (GtkComboBox *cbox);
+ void (*post_pop_hide) (GtkComboBox *cbox);
+};
+
+GtkType gtk_combo_box_get_type (void);
+void gtk_combo_box_construct (GtkComboBox *combo_box,
+ GtkWidget *display_widget,
+ GtkWidget *optional_pop_down_widget);
+void gtk_combo_box_get_pos (GtkComboBox *combo_box, int *x, int *y);
+
+GtkWidget *gtk_combo_box_new (GtkWidget *display_widget,
+ GtkWidget *optional_pop_down_widget);
+void gtk_combo_box_popup_hide (GtkComboBox *combo_box);
+
+void gtk_combo_box_set_display (GtkComboBox *combo_box,
+ GtkWidget *display_widget);
+
+void gtk_combo_box_set_title (GtkComboBox *combo,
+ const gchar *title);
+
+void gtk_combo_box_set_tearable (GtkComboBox *combo,
+ gboolean tearable);
+void gtk_combo_box_set_arrow_sensitive (GtkComboBox *combo,
+ gboolean sensitive);
+void gtk_combo_box_set_arrow_relief (GtkComboBox *cc,
+ GtkReliefStyle relief);
+#ifdef __cplusplus
+};
+#endif /* __cplusplus */
+
+#endif /* _GTK_COMBO_BOX_H_ */
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * widget-color-combo.c - A color selector combo box
+ * Copyright 2000, 2001, Ximian, Inc.
+ *
+ * Authors:
+ * Miguel de Icaza (miguel@kernel.org)
+ * Dom Lachowicz (dominicl@seas.upenn.edu)
+ *
+ * Reworked and split up into a separate ColorPalette object:
+ * Michael Levy (mlevy@genoscope.cns.fr)
+ *
+ * And later revised and polished by:
+ * Almer S. Tigelaar (almer@gnome.org)
+ *
+ * Modified for gLabels by:
+ * Jim Evins <evins@snaught.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <gtk/gtkentry.h>
+#include <gtk/gtksignal.h>
+#include <libgnomecanvas/gnome-canvas.h>
+#include <libgnomecanvas/gnome-canvas-pixbuf.h>
+#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
+#include "e-util.h"
+#include "e-colors.h"
+#include "widget-color-combo.h"
+
+enum {
+ CHANGED,
+ LAST_SIGNAL
+};
+
+static guint color_combo_signals [LAST_SIGNAL] = { 0, };
+
+#define PARENT_TYPE GTK_COMBO_BOX_TYPE
+static GObjectClass *color_combo_parent_class;
+
+#define make_color(CC,COL) (((COL) != NULL) ? (COL) : ((CC) ? ((CC)->default_color) : NULL))
+
+static void
+color_combo_set_color_internal (ColorCombo *cc, GdkColor *color)
+{
+ GdkColor *new_color;
+ GdkColor *outline_color;
+
+ new_color = make_color (cc,color);
+ /* If the new and the default are NULL draw an outline */
+ outline_color = (new_color) ? new_color : &e_dark_gray;
+
+ gnome_canvas_item_set (cc->preview_color_item,
+ "fill_color_gdk", new_color,
+ "outline_color_gdk", outline_color,
+ NULL);
+}
+
+static void
+color_combo_class_init (GObjectClass *object_class)
+{
+ color_combo_parent_class = g_type_class_ref (PARENT_TYPE);
+
+ color_combo_signals [CHANGED] =
+ g_signal_new ("color_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ColorComboClass, color_changed),
+ NULL, NULL,
+ e_marshal_NONE__POINTER_BOOLEAN_BOOLEAN_BOOLEAN,
+ G_TYPE_NONE, 4, G_TYPE_POINTER,
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
+}
+
+E_MAKE_TYPE (color_combo,
+ "ColorCombo",
+ ColorCombo,
+ color_combo_class_init,
+ NULL,
+ PARENT_TYPE)
+
+/*
+ * Fires signal "color_changed" with the current color as its param
+ */
+static void
+emit_color_changed (ColorCombo *cc, GdkColor *color,
+ gboolean is_custom, gboolean by_user, gboolean is_default)
+{
+ g_signal_emit (cc,
+ color_combo_signals [CHANGED], 0,
+ color, is_custom, by_user, is_default);
+ gtk_combo_box_popup_hide (GTK_COMBO_BOX (cc));
+}
+
+static void
+cb_palette_color_changed (ColorPalette *P, GdkColor *color,
+ gboolean custom, gboolean by_user, gboolean is_default,
+ ColorCombo *cc)
+{
+ color_combo_set_color_internal (cc, color);
+ emit_color_changed (cc, color, custom, by_user, is_default);
+}
+
+static void
+preview_clicked (GtkWidget *button, ColorCombo *cc)
+{
+ gboolean is_default;
+ GdkColor *color = color_palette_get_current_color (cc->palette, &is_default);
+ emit_color_changed (cc, color, FALSE, TRUE, is_default);
+ if (color)
+ gdk_color_free (color);
+}
+
+static void
+cb_cust_color_clicked (GtkWidget *widget, ColorCombo *cc)
+{
+ gtk_combo_box_popup_hide (GTK_COMBO_BOX (cc));
+}
+
+/*
+ * Creates the color table
+ */
+static void
+color_table_setup (ColorCombo *cc,
+ char const *no_color_label, ColorGroup *color_group)
+{
+ g_return_if_fail (cc != NULL);
+
+ /* Tell the palette that we will be changing it's custom colors */
+ cc->palette =
+ COLOR_PALETTE (color_palette_new (no_color_label,
+ cc->default_color,
+ color_group));
+
+ {
+ GtkWidget *picker = color_palette_get_color_picker (cc->palette);
+ g_signal_connect (picker, "clicked",
+ G_CALLBACK (cb_cust_color_clicked), cc);
+ }
+
+ g_signal_connect (cc->palette, "color_changed",
+ G_CALLBACK (cb_palette_color_changed), cc);
+
+ gtk_widget_show_all (GTK_WIDGET (cc->palette));
+
+ return;
+}
+
+void
+color_combo_box_set_preview_relief (ColorCombo *cc, GtkReliefStyle relief)
+{
+ g_return_if_fail (cc != NULL);
+ g_return_if_fail (IS_COLOR_COMBO (cc));
+
+ gtk_button_set_relief (GTK_BUTTON (cc->preview_button), relief);
+}
+
+/*
+ * Where the actual construction goes on
+ */
+static void
+color_combo_construct (ColorCombo *cc, GdkPixbuf *icon,
+ char const *no_color_label,
+ ColorGroup *color_group)
+{
+ GdkColor *color;
+ g_return_if_fail (cc != NULL);
+ g_return_if_fail (IS_COLOR_COMBO (cc));
+
+ /*
+ * Our button with the canvas preview
+ */
+ cc->preview_button = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (cc->preview_button), GTK_RELIEF_NONE);
+
+ cc->preview_canvas = GNOME_CANVAS (gnome_canvas_new ());
+
+ gnome_canvas_set_scroll_region (cc->preview_canvas, 0, 0, 24, 24);
+ if (icon) {
+ gnome_canvas_item_new (
+ GNOME_CANVAS_GROUP (gnome_canvas_root (cc->preview_canvas)),
+ GNOME_TYPE_CANVAS_PIXBUF,
+ "pixbuf", icon,
+ "x", 0.0,
+ "y", 0.0,
+ "anchor", GTK_ANCHOR_NW,
+ NULL);
+ gdk_pixbuf_unref (icon);
+
+ cc->preview_color_item = gnome_canvas_item_new (
+ GNOME_CANVAS_GROUP (gnome_canvas_root (cc->preview_canvas)),
+ gnome_canvas_rect_get_type (),
+ "x1", 3.0,
+ "y1", 19.0,
+ "x2", 20.0,
+ "y2", 22.0,
+ "fill_color", "black",
+ "width_pixels", 1,
+ NULL);
+ } else
+ cc->preview_color_item = gnome_canvas_item_new (
+ GNOME_CANVAS_GROUP (gnome_canvas_root (cc->preview_canvas)),
+ gnome_canvas_rect_get_type (),
+ "x1", 2.0,
+ "y1", 1.0,
+ "x2", 21.0,
+ "y2", 22.0,
+ "fill_color", "black",
+ "width_pixels", 1,
+ NULL);
+
+ gtk_container_add (GTK_CONTAINER (cc->preview_button), GTK_WIDGET (cc->preview_canvas));
+ gtk_widget_set_usize (GTK_WIDGET (cc->preview_canvas), 24, 22);
+ g_signal_connect (cc->preview_button, "clicked",
+ G_CALLBACK (preview_clicked), cc);
+
+ color_table_setup (cc, no_color_label, color_group);
+
+ gtk_widget_show_all (cc->preview_button);
+
+ gtk_combo_box_construct (GTK_COMBO_BOX (cc),
+ cc->preview_button,
+ GTK_WIDGET (cc->palette));
+
+ gtk_combo_box_set_tearable (GTK_COMBO_BOX (cc), FALSE);
+
+ color = color_palette_get_current_color (cc->palette, NULL);
+ color_combo_set_color_internal (cc, color);
+ if (color) gdk_color_free (color);
+}
+
+/* color_combo_get_color:
+ *
+ * Return current color, result must be freed with gdk_color_free !
+ */
+GdkColor *
+color_combo_get_color (ColorCombo *cc, gboolean *is_default)
+{
+ return color_palette_get_current_color (cc->palette, is_default);
+}
+
+/**
+ * color_combo_set_color
+ * @cc The combo
+ * @color The color
+ *
+ * Set the color of the combo to the given color. Causes the color_changed
+ * signal to be emitted.
+ */
+void
+color_combo_set_color (ColorCombo *cc, GdkColor *color)
+{
+ /* This will change the color on the palette than it will invoke
+ * cb_palette_color_changed which will call emit_color_changed and
+ * set_color_internal which will change the color on our preview and
+ * will let the users of the combo know that the current color has
+ * changed
+ */
+ if (color != NULL)
+ gdk_rgb_find_color (gtk_widget_get_colormap (GTK_WIDGET (cc)), color);
+ color_palette_set_current_color (cc->palette, color);
+}
+
+/**
+ * color_combo_set_color_to_default
+ * @cc The combo
+ *
+ * Set the color of the combo to the default color. Causes the color_changed
+ * signal to be emitted.
+ */
+void
+color_combo_set_color_to_default (ColorCombo *cc)
+{
+ color_palette_set_color_to_default (cc->palette);
+}
+
+/**
+ * color_combo_new :
+ * icon : optionally NULL.
+ * , const char *no_color_label,
+ * Default constructor. Pass an optional icon and an optional label for the
+ * no/auto color button.
+ */
+GtkWidget *
+color_combo_new (GdkPixbuf *icon, char const *no_color_label,
+ GdkColor *default_color,
+ ColorGroup *color_group)
+{
+ ColorCombo *cc;
+
+ cc = g_object_new (COLOR_COMBO_TYPE, NULL);
+
+ cc->default_color = default_color;
+
+ color_combo_construct (cc, icon, no_color_label, color_group);
+
+ return GTK_WIDGET (cc);
+}
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * widget-color-combo.h - A color selector combo box
+ * Copyright 2000, 2001, Ximian, Inc.
+ *
+ * Authors:
+ * Miguel de Icaza (miguel@kernel.org)
+ * Dom Lachowicz (dominicl@seas.upenn.edu)
+ *
+ * Reworked and split up into a separate ColorPalette object:
+ * Michael Levy (mlevy@genoscope.cns.fr)
+ *
+ * And later revised and polished by:
+ * Almer S. Tigelaar (almer@gnome.org)
+ *
+ * Modified for gLabels by:
+ * Jim Evins <evins@snaught.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef GNUMERIC_WIDGET_COLOR_COMBO_H
+#define GNUMERIC_WIDGET_COLOR_COMBO_H
+
+#include <gtk/gtkwidget.h>
+#include "gtk-combo-box.h"
+#include "color-palette.h"
+
+G_BEGIN_DECLS
+
+typedef struct _ColorCombo {
+ GtkComboBox combo_box;
+
+ /*
+ * Canvas where we display
+ */
+ GtkWidget *preview_button;
+ GnomeCanvas *preview_canvas;
+ GnomeCanvasItem *preview_color_item;
+ ColorPalette *palette;
+
+ GdkColor *default_color;
+ gboolean trigger;
+} ColorCombo;
+
+typedef struct {
+ GtkComboBoxClass parent_class;
+
+ /* Signals emited by this widget */
+ void (* color_changed) (ColorCombo *color_combo, GdkColor *color,
+ gboolean custom, gboolean by_user, gboolean is_default);
+} ColorComboClass;
+
+#define COLOR_COMBO_TYPE (color_combo_get_type ())
+#define COLOR_COMBO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), COLOR_COMBO_TYPE, ColorCombo))
+#define COLOR_COMBO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST(k), COLOR_COMBO_TYPE)
+#define IS_COLOR_COMBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), COLOR_COMBO_TYPE))
+
+GtkType color_combo_get_type (void);
+GtkWidget *color_combo_new (GdkPixbuf *icon,
+ char const *no_color_label,
+ GdkColor *default_color,
+ ColorGroup *color_group);
+void color_combo_set_color (ColorCombo *cc,
+ GdkColor *color);
+void color_combo_set_color_to_default (ColorCombo *cc);
+GdkColor *color_combo_get_color (ColorCombo *cc, gboolean *is_default);
+
+void color_combo_box_set_preview_relief (ColorCombo *cc, GtkReliefStyle relief);
+
+G_END_DECLS
+
+#endif /* GNUMERIC_WIDGET_COLOR_COMBO_H */
stock_align_bottom_16.png \
stock_align_vcenter_16.png \
stock_center_horiz_16.png \
- stock_center_vert_16.png
+ stock_center_vert_16.png \
+ stock_bucket_fill_16.png \
+ stock_bucket_fill_24.png \
+ stock_pencil_16.png \
+ stock_pencil_24.png
VARIABLES1 = \
stock_arrow_24 $(srcdir)/stock_arrow_24.png \
stock_align_bottom_16 $(srcdir)/stock_align_bottom_16.png \
stock_align_vcenter_16 $(srcdir)/stock_align_vcenter_16.png \
stock_center_horiz_16 $(srcdir)/stock_center_horiz_16.png \
- stock_center_vert_16 $(srcdir)/stock_center_vert_16.png
+ stock_center_vert_16 $(srcdir)/stock_center_vert_16.png \
+ stock_bucket_fill_16 $(srcdir)/stock_bucket_fill_16.png \
+ stock_bucket_fill_24 $(srcdir)/stock_bucket_fill_24.png \
+ stock_pencil_16 $(srcdir)/stock_pencil_16.png \
+ stock_pencil_24 $(srcdir)/stock_pencil_24.png
noinst_DATA = stockpixbufs.h
{ GL_STOCK_ALIGN_VCENTER, N_("Centers"), 0, 0, NULL },
{ GL_STOCK_CENTER_HORIZ, N_("Label Ce_nter"), 0, 0, NULL },
{ GL_STOCK_CENTER_VERT, N_("Label Ce_nter"), 0, 0, NULL },
+ { GL_STOCK_BUCKET_FILL, N_("Fill color"), 0, 0, NULL },
+ { GL_STOCK_PENCIL, N_("Line color"), 0, 0, NULL },
};
gtk_stock_add (items, G_N_ELEMENTS (items));
add_icons (factory, GL_STOCK_CENTER_HORIZ, NULL, stock_center_horiz_16);
add_icons (factory, GL_STOCK_CENTER_VERT, NULL, stock_center_vert_16);
+ add_icons (factory, GL_STOCK_BUCKET_FILL, stock_bucket_fill_24, stock_bucket_fill_16);
+ add_icons (factory, GL_STOCK_PENCIL, stock_pencil_24, stock_pencil_16);
+
g_object_unref (G_OBJECT(factory));
}
#define GL_STOCK_ALIGN_VCENTER "gl_stock_align_vcenter"
#define GL_STOCK_CENTER_HORIZ "gl_stock_center_horiz"
#define GL_STOCK_CENTER_VERT "gl_stock_center_vert"
+#define GL_STOCK_BUCKET_FILL "gl_stock_bucket_fill"
+#define GL_STOCK_PENCIL "gl_stock_pencil"
void gl_stock_init (void);
--- /dev/null
+/*
+ * (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ * property-bar.c: gLabels property bar
+ *
+ * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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
+ */
+
+#include <config.h>
+
+#include <libgnomeprint/gnome-font.h>
+
+#include "ui-property-bar.h"
+#include "ui-util.h"
+#include "mygal/widget-color-combo.h"
+#include "stock-pixmaps/stockpixbufs.h"
+#include "prefs.h"
+#include "color.h"
+
+#include "debug.h"
+
+/*============================================================================*/
+/* Private macros and constants. */
+/*============================================================================*/
+
+/*============================================================================*/
+/* Private globals */
+/*============================================================================*/
+
+static GObjectClass *parent_class;
+
+static gchar* doc_verbs [] = {
+ "/commands/PropFontName",
+ "/commands/PropFontSize",
+ "/commands/PropFontBold",
+ "/commands/PropFontItalic",
+ "/commands/PropTextAlignLeft",
+ "/commands/PropTextAlignCenter",
+ "/commands/PropTextAlignRight",
+ "/commands/PropFillColor",
+ "/commands/PropLineColor",
+ "/commands/PropTextColor",
+ "/commands/PropLineWidth",
+
+ NULL
+};
+
+static gchar* text_verbs [] = {
+ "/commands/PropFontName",
+ "/commands/PropFontSize",
+ "/commands/PropFontBold",
+ "/commands/PropFontItalic",
+ "/commands/PropTextAlignLeft",
+ "/commands/PropTextAlignCenter",
+ "/commands/PropTextAlignRight",
+ "/commands/PropTextColor",
+
+ NULL
+};
+
+static gchar* fill_verbs [] = {
+ "/commands/PropFillColor",
+
+ NULL
+};
+
+static gchar* line_color_verbs [] = {
+ "/commands/PropLineColor",
+
+ NULL
+};
+
+static gchar* line_width_verbs [] = {
+ "/commands/PropLineWidth",
+
+ NULL
+};
+
+
+/*============================================================================*/
+/* Local function prototypes */
+/*============================================================================*/
+
+static void gl_ui_property_bar_class_init (glUIPropertyBarClass *class);
+static void gl_ui_property_bar_instance_init (glUIPropertyBar *property_bar);
+static void gl_ui_property_bar_finalize (GObject *object);
+
+static void gl_ui_property_bar_construct (glUIPropertyBar *property_bar,
+ BonoboUIComponent *ui_component);
+
+static void selection_changed_cb (glView *view,
+ glUIPropertyBar *property_bar);
+
+static void font_family_changed_cb (GtkEntry *entry,
+ glUIPropertyBar *property_bar);
+
+static void font_size_changed_cb (GtkSpinButton *spin,
+ glUIPropertyBar *property_bar);
+
+static void text_color_changed_cb (ColorCombo *cc,
+ GdkColor *gdk_color,
+ gboolean custom,
+ gboolean by_user,
+ gboolean is_default,
+ glUIPropertyBar *property_bar);
+
+static void fill_color_changed_cb (ColorCombo *cc,
+ GdkColor *gdk_color,
+ gboolean custom,
+ gboolean by_user,
+ gboolean is_default,
+ glUIPropertyBar *property_bar);
+
+static void line_color_changed_cb (ColorCombo *cc,
+ GdkColor *gdk_color,
+ gboolean custom,
+ gboolean by_user,
+ gboolean is_default,
+ glUIPropertyBar *property_bar);
+
+static void line_width_changed_cb (GtkSpinButton *spin,
+ glUIPropertyBar *property_bar);
+
+static void prop_item_toggled_cb (BonoboUIComponent *ui_component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ glUIPropertyBar *property_bar);
+
+static void null_cmd (BonoboUIComponent *ui_component,
+ gpointer user_data,
+ const gchar *verbname);
+
+
+
+\f
+/****************************************************************************/
+/* Boilerplate Object stuff. */
+/****************************************************************************/
+guint
+gl_ui_property_bar_get_type (void)
+{
+ static guint property_bar_type = 0;
+
+ if (!property_bar_type) {
+ GTypeInfo property_bar_info = {
+ sizeof (glUIPropertyBarClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gl_ui_property_bar_class_init,
+ NULL,
+ NULL,
+ sizeof (glUIPropertyBar),
+ 0,
+ (GInstanceInitFunc) gl_ui_property_bar_instance_init,
+ };
+
+ property_bar_type =
+ g_type_register_static (G_TYPE_OBJECT,
+ "glUIPropertyBar",
+ &property_bar_info, 0);
+ }
+
+ return property_bar_type;
+}
+
+static void
+gl_ui_property_bar_class_init (glUIPropertyBarClass *class)
+{
+ GObjectClass *object_class = (GObjectClass *) class;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ parent_class = g_type_class_peek_parent (class);
+
+ object_class->finalize = gl_ui_property_bar_finalize;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+}
+
+static void
+gl_ui_property_bar_instance_init (glUIPropertyBar *property_bar)
+{
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ property_bar->view = NULL;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+}
+
+static void
+gl_ui_property_bar_finalize (GObject *object)
+{
+ glUIPropertyBar *property_bar;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GL_IS_UI_PROPERTY_BAR (object));
+
+ property_bar = GL_UI_PROPERTY_BAR (object);
+
+ if (property_bar->view) {
+ g_object_unref (G_OBJECT(property_bar->view));
+ property_bar = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+}
+
+/****************************************************************************/
+/* Create a NEW property_bar. */
+/****************************************************************************/
+GObject *
+gl_ui_property_bar_new (BonoboUIComponent *ui_component)
+{
+ glUIPropertyBar *property_bar;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ property_bar = g_object_new (gl_ui_property_bar_get_type (), NULL);
+
+ gl_ui_property_bar_construct (property_bar, ui_component);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+
+ return G_OBJECT(property_bar);
+}
+
+/******************************************************************************/
+/* Initialize property toolbar. */
+/******************************************************************************/
+static void
+gl_ui_property_bar_construct (glUIPropertyBar *property_bar,
+ BonoboUIComponent *ui_component)
+{
+ GtkWidget *wcombo;
+ GList *family_names = NULL;
+ GtkObject *adjust;
+ ColorGroup *cg;
+ GdkPixbuf *pixbuf;
+ gchar *good_font_family;
+ GdkColor *gdk_color;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ property_bar->ui_component = ui_component;
+
+ /* Font family entry widget */
+ wcombo = gtk_combo_new ();
+ family_names = gnome_font_family_list ();
+ gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), family_names);
+ property_bar->font_family_entry = GTK_COMBO (wcombo)->entry;
+ gtk_combo_set_value_in_list (GTK_COMBO(wcombo), TRUE, FALSE);
+ gtk_entry_set_editable (GTK_ENTRY (property_bar->font_family_entry), FALSE);
+ gtk_widget_set_size_request (wcombo, 200, -1);
+
+ /* Make sure we have a valid font family. if not provide a good default. */
+ if (g_list_find_custom (family_names,
+ gl_prefs->default_font_family,
+ (GCompareFunc)g_utf8_collate)) {
+ good_font_family = g_strdup (gl_prefs->default_font_family);
+ } else {
+ if (family_names != NULL) {
+ good_font_family = g_strdup (family_names->data); /* 1st entry */
+ } else {
+ good_font_family = NULL;
+ }
+ }
+ gtk_entry_set_text (GTK_ENTRY (property_bar->font_family_entry), good_font_family);
+ g_free (good_font_family);
+ gnome_font_family_list_free (family_names);
+
+ g_signal_connect (G_OBJECT (property_bar->font_family_entry),
+ "changed", G_CALLBACK (font_family_changed_cb), property_bar);
+
+ gl_ui_util_insert_widget (ui_component, wcombo, "/PropertyToolbar/PropFontName");
+
+ /* Font size entry widget */
+ adjust = gtk_adjustment_new (1.0, 1.0, 250.0, 1.0, 10.0, 10.0);
+ property_bar->font_size_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust),
+ 1.0, 0);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->font_size_spin),
+ gl_prefs->default_font_size);
+
+ g_signal_connect (G_OBJECT (property_bar->font_size_spin),
+ "changed", G_CALLBACK (font_size_changed_cb), property_bar);
+
+ gl_ui_util_insert_widget (ui_component, property_bar->font_size_spin,
+ "/PropertyToolbar/PropFontSize");
+
+ /* Bold and Italic toggles */
+ bonobo_ui_component_add_verb (ui_component, "PropFontBold", null_cmd, NULL);
+ gl_ui_util_set_verb_state (ui_component, "/commands/PropFontBold",
+ (gl_prefs->default_font_weight == GNOME_FONT_BOLD));
+ bonobo_ui_component_add_listener (ui_component, "PropFontBold",
+ (BonoboUIListenerFn)prop_item_toggled_cb,
+ (gpointer)property_bar);
+ bonobo_ui_component_add_verb (ui_component, "PropFontItalic", null_cmd, NULL);
+ gl_ui_util_set_verb_state (ui_component, "/commands/PropFontItalic",
+ gl_prefs->default_font_italic_flag);
+ bonobo_ui_component_add_listener (ui_component, "PropFontItalic",
+ (BonoboUIListenerFn)prop_item_toggled_cb,
+ (gpointer)property_bar);
+
+ /* Text alignment radio group */
+ bonobo_ui_component_add_verb (ui_component, "PropTextAlignLeft", null_cmd, NULL);
+ gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignLeft",
+ (gl_prefs->default_text_alignment == GTK_JUSTIFY_LEFT));
+ bonobo_ui_component_add_listener (ui_component, "PropTextAlignLeft",
+ (BonoboUIListenerFn)prop_item_toggled_cb,
+ (gpointer)property_bar);
+ bonobo_ui_component_add_verb (ui_component, "PropTextAlignCenter", null_cmd, NULL);
+ gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignCenter",
+ (gl_prefs->default_text_alignment == GTK_JUSTIFY_CENTER));
+ bonobo_ui_component_add_listener (ui_component, "PropTextAlignCenter",
+ (BonoboUIListenerFn)prop_item_toggled_cb,
+ (gpointer)property_bar);
+ bonobo_ui_component_add_verb (ui_component, "PropTextAlignRight", null_cmd, NULL);
+ gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignRight",
+ (gl_prefs->default_text_alignment == GTK_JUSTIFY_RIGHT));
+ bonobo_ui_component_add_listener (ui_component, "PropTextAlignRight",
+ (BonoboUIListenerFn)prop_item_toggled_cb,
+ (gpointer)property_bar);
+
+ /* Text color widget */
+ cg = color_group_fetch ("text_color_group", ui_component);
+ pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL);
+ gdk_color = gl_color_to_gdk_color (gl_prefs->default_text_color);
+ property_bar->text_color_combo = color_combo_new (pixbuf, _("Default"),
+ gdk_color, cg);
+ g_free (gdk_color);
+
+ g_signal_connect (G_OBJECT (property_bar->text_color_combo),
+ "color_changed",
+ G_CALLBACK (text_color_changed_cb), property_bar);
+
+ gl_ui_util_insert_widget (ui_component, property_bar->text_color_combo,
+ "/PropertyToolbar/PropTextColor");
+
+ /* Fill color widget */
+ cg = color_group_fetch ("fill_color_group", ui_component);
+ pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL);
+ gdk_color = gl_color_to_gdk_color (gl_prefs->default_fill_color);
+ property_bar->fill_color_combo = color_combo_new (pixbuf, _("No fill"),
+ gdk_color, cg);
+ g_free (gdk_color);
+
+ g_signal_connect (G_OBJECT (property_bar->fill_color_combo),
+ "color_changed",
+ G_CALLBACK (fill_color_changed_cb), property_bar);
+
+ gl_ui_util_insert_widget (ui_component, property_bar->fill_color_combo,
+ "/PropertyToolbar/PropFillColor");
+
+ /* Line color widget */
+ cg = color_group_fetch ("line_color_group", ui_component);
+ pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL);
+ gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color);
+ property_bar->line_color_combo = color_combo_new (pixbuf, _("No line"),
+ gdk_color, cg);
+ g_free (gdk_color);
+
+ g_signal_connect (G_OBJECT (property_bar->line_color_combo),
+ "color_changed",
+ G_CALLBACK (line_color_changed_cb), property_bar);
+
+ gl_ui_util_insert_widget (ui_component, property_bar->line_color_combo,
+ "/PropertyToolbar/PropLineColor");
+
+ /* Line width entry widget */
+ adjust = gtk_adjustment_new (1.0, 0.25, 4.0, 0.25, 1.0, 1.0);
+ property_bar->line_width_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 0.25, 2);
+
+ g_signal_connect (G_OBJECT (property_bar->line_width_spin),
+ "changed",
+ G_CALLBACK (line_width_changed_cb), property_bar);
+
+ gl_ui_util_insert_widget (ui_component, property_bar->line_width_spin,
+ "/PropertyToolbar/PropLineWidth");
+
+ gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+}
+
+/****************************************************************************/
+/* Set view associated with property_bar. */
+/****************************************************************************/
+void
+gl_ui_property_bar_set_view (glUIPropertyBar *property_bar,
+ glView *view)
+{
+ glLabel *label;
+ GList *family_names;
+ gchar *good_font_family;
+ GdkColor *gdk_color;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+ label = view->label;
+ g_return_if_fail (label && GL_IS_LABEL (label));
+
+ gl_ui_util_set_verb_list_sensitive (property_bar->ui_component, doc_verbs, TRUE);
+
+ property_bar->view = GL_VIEW (g_object_ref (G_OBJECT (view)));
+
+ /* Make sure we have a valid font family. if not provide a good default. */
+ family_names = gnome_font_family_list ();
+ if (g_list_find_custom (family_names,
+ view->default_font_family,
+ (GCompareFunc)g_utf8_collate)) {
+ good_font_family = g_strdup (view->default_font_family);
+ } else {
+ if (family_names != NULL) {
+ good_font_family = g_strdup (family_names->data); /* 1st entry */
+ } else {
+ good_font_family = NULL;
+ }
+ }
+ gtk_entry_set_text (GTK_ENTRY (property_bar->font_family_entry), good_font_family);
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->font_size_spin),
+ view->default_font_size);
+
+ gl_ui_util_set_verb_state (property_bar->ui_component,
+ "/commands/PropFontBold",
+ (view->default_font_weight == GNOME_FONT_BOLD));
+ gl_ui_util_set_verb_state (property_bar->ui_component,
+ "/commands/PropFontItalic",
+ view->default_font_italic_flag);
+
+ gl_ui_util_set_verb_state (property_bar->ui_component,
+ "/commands/PropTextAlignLeft",
+ (view->default_text_alignment == GTK_JUSTIFY_LEFT));
+ gl_ui_util_set_verb_state (property_bar->ui_component,
+ "/commands/PropTextAlignCenter",
+ (view->default_text_alignment == GTK_JUSTIFY_CENTER));
+ gl_ui_util_set_verb_state (property_bar->ui_component,
+ "/commands/PropTextAlignRight",
+ (view->default_text_alignment == GTK_JUSTIFY_RIGHT));
+
+ gdk_color = gl_color_to_gdk_color (view->default_text_color);
+ color_combo_set_color (COLOR_COMBO(property_bar->text_color_combo), gdk_color);
+ g_free (gdk_color);
+
+ gdk_color = gl_color_to_gdk_color (view->default_fill_color);
+ color_combo_set_color (COLOR_COMBO(property_bar->fill_color_combo), gdk_color);
+ g_free (gdk_color);
+
+ gdk_color = gl_color_to_gdk_color (view->default_line_color);
+ color_combo_set_color (COLOR_COMBO(property_bar->line_color_combo), gdk_color);
+ g_free (gdk_color);
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->line_width_spin),
+ view->default_line_width);
+
+ g_signal_connect (G_OBJECT(view), "selection_changed",
+ G_CALLBACK(selection_changed_cb), property_bar);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. View "selection state changed" callback. */
+/*---------------------------------------------------------------------------*/
+static void
+selection_changed_cb (glView *view,
+ glUIPropertyBar *property_bar)
+{
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+ g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
+
+ if (gl_view_is_selection_empty (view)) {
+
+ /* No selection: make all controls active. */
+ gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
+ doc_verbs, TRUE);
+
+ } else {
+
+ gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
+ text_verbs,
+ gl_view_can_selection_text (view));
+
+ gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
+ fill_verbs,
+ gl_view_can_selection_fill (view));
+
+ gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
+ line_color_verbs,
+ gl_view_can_selection_line_color (view));
+
+ gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
+ line_width_verbs,
+ gl_view_can_selection_line_width (view));
+
+ }
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+}
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. Font family entry changed. */
+/*--------------------------------------------------------------------------*/
+static void
+font_family_changed_cb (GtkEntry *entry,
+ glUIPropertyBar *property_bar)
+{
+ gchar *font_family;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ font_family = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+ if ( strlen(font_family) ) {
+ gl_view_set_selection_font_family (property_bar->view,
+ font_family);
+ gl_view_set_default_font_family (property_bar->view,
+ font_family);
+ }
+ g_free (font_family);
+}
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. Font size spin button changed. */
+/*--------------------------------------------------------------------------*/
+static void
+font_size_changed_cb (GtkSpinButton *spin,
+ glUIPropertyBar *property_bar)
+{
+ gdouble font_size;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ font_size = gtk_spin_button_get_value (spin);
+
+ gl_view_set_selection_font_size (property_bar->view,
+ font_size);
+ gl_view_set_default_font_size (property_bar->view,
+ font_size);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+}
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. Text color combo changed. */
+/*--------------------------------------------------------------------------*/
+static void
+text_color_changed_cb (ColorCombo *cc,
+ GdkColor *gdk_color,
+ gboolean custom,
+ gboolean by_user,
+ gboolean is_default,
+ glUIPropertyBar *property_bar)
+{
+ guint text_color;
+
+ g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ text_color = gl_color_from_gdk_color (gdk_color);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
+ text_color, custom, by_user, is_default);
+
+ if (is_default) {
+
+ gl_view_set_selection_text_color (property_bar->view,
+ gl_prefs->default_text_color);
+ gl_view_set_default_text_color (property_bar->view,
+ gl_prefs->default_text_color);
+
+ } else {
+
+ gl_view_set_selection_text_color (property_bar->view,
+ text_color);
+ gl_view_set_default_text_color (property_bar->view,
+ text_color);
+
+ }
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+}
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. Fill color combo changed. */
+/*--------------------------------------------------------------------------*/
+static void
+fill_color_changed_cb (ColorCombo *cc,
+ GdkColor *gdk_color,
+ gboolean custom,
+ gboolean by_user,
+ gboolean is_default,
+ glUIPropertyBar *property_bar)
+{
+ guint fill_color;
+
+ g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ fill_color = gl_color_from_gdk_color (gdk_color);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
+ fill_color, custom, by_user, is_default);
+
+ if (is_default) {
+
+ gl_view_set_selection_fill_color (property_bar->view,
+ GL_COLOR_NONE);
+ gl_view_set_default_fill_color (property_bar->view,
+ GL_COLOR_NONE);
+
+ } else {
+
+ gl_view_set_selection_fill_color (property_bar->view,
+ fill_color);
+ gl_view_set_default_fill_color (property_bar->view,
+ fill_color);
+
+ }
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+}
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. Line color combo changed. */
+/*--------------------------------------------------------------------------*/
+static void
+line_color_changed_cb (ColorCombo *cc,
+ GdkColor *gdk_color,
+ gboolean custom,
+ gboolean by_user,
+ gboolean is_default,
+ glUIPropertyBar *property_bar)
+{
+ guint line_color;
+
+ g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ line_color = gl_color_from_gdk_color (gdk_color);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
+ line_color, custom, by_user, is_default);
+
+ if (is_default) {
+
+ gl_view_set_selection_line_color (property_bar->view,
+ GL_COLOR_NONE);
+ gl_view_set_default_line_color (property_bar->view,
+ GL_COLOR_NONE);
+
+ } else {
+
+ gl_view_set_selection_line_color (property_bar->view,
+ line_color);
+ gl_view_set_default_line_color (property_bar->view,
+ line_color);
+
+ }
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+}
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. Line width spin button changed. */
+/*--------------------------------------------------------------------------*/
+static void
+line_width_changed_cb (GtkSpinButton *spin,
+ glUIPropertyBar *property_bar)
+{
+ gdouble line_width;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ line_width = gtk_spin_button_get_value (spin);
+
+ gl_view_set_selection_line_width (property_bar->view,
+ line_width);
+ gl_view_set_default_line_width (property_bar->view,
+ line_width);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Property bar item toggled callback. */
+/*---------------------------------------------------------------------------*/
+static void
+prop_item_toggled_cb (BonoboUIComponent *ui_component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ glUIPropertyBar *property_bar)
+{
+ gboolean s;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "");
+
+ s = (strcmp (state, "1") == 0);
+
+ /*
+ * Font properties: Bold & Italic
+ */
+ if (strcmp (path, "PropFontBold") == 0)
+ {
+ GnomeFontWeight weight = s ? GNOME_FONT_BOLD : GNOME_FONT_BOOK;
+
+ gl_view_set_selection_font_weight (property_bar->view, weight);
+ gl_view_set_default_font_weight (property_bar->view, weight);
+ return;
+ }
+
+ if (strcmp (path, "PropFontItalic") == 0)
+ {
+ gl_view_set_selection_font_italic_flag (property_bar->view, s);
+ gl_view_set_default_font_italic_flag (property_bar->view, s);
+ return;
+ }
+
+
+ /*
+ * Text alignment group
+ */
+ if (s && (strcmp (path, "PropTextAlignLeft") == 0))
+ {
+ gl_view_set_selection_text_alignment (property_bar->view,
+ GTK_JUSTIFY_LEFT);
+ gl_view_set_default_text_alignment (property_bar->view,
+ GTK_JUSTIFY_LEFT);
+
+ /* Adjust state of siblings */
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/PropTextAlignCenter",
+ FALSE);
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/PropTextAlignRight",
+ FALSE);
+ return;
+ }
+
+ if (s && (strcmp (path, "PropTextAlignCenter") == 0))
+ {
+ gl_view_set_selection_text_alignment (property_bar->view,
+ GTK_JUSTIFY_CENTER);
+ gl_view_set_default_text_alignment (property_bar->view,
+ GTK_JUSTIFY_CENTER);
+
+ /* Adjust state of siblings */
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/PropTextAlignLeft",
+ FALSE);
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/PropTextAlignRight",
+ FALSE);
+ return;
+ }
+
+ if (s && (strcmp (path, "PropTextAlignRight") == 0))
+ {
+ gl_view_set_selection_text_alignment (property_bar->view,
+ GTK_JUSTIFY_RIGHT);
+ gl_view_set_default_text_alignment (property_bar->view,
+ GTK_JUSTIFY_RIGHT);
+
+ /* Adjust state of siblings */
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/PropTextAlignLeft",
+ FALSE);
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/PropTextAlignCenter",
+ FALSE);
+ return;
+ }
+
+}
+
+/*---------------------------------------------------------------------------------------*/
+/* NULL command handler -- hides bogus "verb not found" errors for toggle toolbar items. */
+/*---------------------------------------------------------------------------------------*/
+static void
+null_cmd (BonoboUIComponent *ui_component,
+ gpointer user_data,
+ const gchar *verbname)
+{
+}
+
--- /dev/null
+/*
+ * (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ * ui-property-bar.h: Property toolbar header file
+ *
+ * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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
+ */
+
+#ifndef __UI_PROPERTY_BAR_H__
+#define __UI_PROPERTY_BAR_H__
+
+#include <glib-object.h>
+#include <bonobo/bonobo-ui-component.h>
+#include <bonobo/bonobo-window.h>
+
+#include "view.h"
+
+G_BEGIN_DECLS
+
+#define GL_TYPE_UI_PROPERTY_BAR (gl_ui_property_bar_get_type ())
+#define GL_UI_PROPERTY_BAR(obj) \
+ (GTK_CHECK_CAST((obj), GL_TYPE_UI_PROPERTY_BAR, glUIPropertyBar ))
+#define GL_UI_PROPERTY_BAR_CLASS(klass) \
+ (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_UI_PROPERTY_BAR, glUIPropertyBarClass))
+#define GL_IS_UI_PROPERTY_BAR(obj) \
+ (GTK_CHECK_TYPE ((obj), GL_TYPE_UI_PROPERTY_BAR))
+#define GL_IS_UI_PROPERTY_BAR_CLASS(klass) \
+ (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_UI_PROPERTY_BAR))
+
+typedef struct _glUIPropertyBar glUIPropertyBar;
+typedef struct _glUIPropertyBarClass glUIPropertyBarClass;
+
+struct _glUIPropertyBar {
+ GObject parent_widget;
+
+ BonoboUIComponent *ui_component;
+
+ glView *view;
+
+ GtkWidget *font_family_entry;
+ GtkWidget *font_size_spin;
+ GtkWidget *text_color_combo;
+
+ GtkWidget *fill_color_combo;
+
+ GtkWidget *line_color_combo;
+ GtkWidget *line_width_spin;
+};
+
+struct _glUIPropertyBarClass {
+ GObjectClass parent_class;
+};
+
+guint gl_ui_property_bar_get_type (void);
+
+GObject *gl_ui_property_bar_new (BonoboUIComponent *ui_component);
+
+void gl_ui_property_bar_set_view (glUIPropertyBar *property_bar,
+ glView *view);
+
+
+G_END_DECLS
+
+#endif /* __UI_PROPERTY_BAR_H__ */
--- /dev/null
+/*
+ * (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ * ui-util.c: GLabels ui utilities module
+ *
+ * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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
+ */
+#include <config.h>
+#include <bonobo/bonobo-control.h>
+
+#include "ui-util.h"
+
+#include "debug.h"
+
+/*==========================================================================*/
+/* Private macros and constants. */
+/*==========================================================================*/
+
+/*==========================================================================*/
+/* Private types. */
+/*==========================================================================*/
+
+/*==========================================================================*/
+/* Private globals */
+/*==========================================================================*/
+
+/*==========================================================================*/
+/* Local function prototypes */
+/*==========================================================================*/
+
+
+\f
+/*****************************************************************************/
+/* Set sensitivity of verb. */
+/*****************************************************************************/
+void
+gl_ui_util_set_verb_sensitive (BonoboUIComponent *ui_component,
+ gchar *cname,
+ gboolean sensitive)
+{
+ gl_debug (DEBUG_UI, "START");
+
+ g_return_if_fail (cname != NULL);
+ g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
+
+ bonobo_ui_component_set_prop (ui_component,
+ cname,
+ "sensitive",
+ sensitive ? "1" : "0",
+ NULL);
+
+ gl_debug (DEBUG_UI, "END");
+}
+
+/*****************************************************************************/
+/* Set sensitivity of a list of verbs. */
+/*****************************************************************************/
+void
+gl_ui_util_set_verb_list_sensitive (BonoboUIComponent *ui_component,
+ gchar **vlist,
+ gboolean sensitive)
+{
+ gl_debug (DEBUG_UI, "START");
+
+ g_return_if_fail (vlist != NULL);
+ g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
+
+ for ( ; *vlist; ++vlist)
+ {
+ bonobo_ui_component_set_prop (ui_component,
+ *vlist,
+ "sensitive",
+ sensitive ? "1" : "0",
+ NULL);
+ }
+
+ gl_debug (DEBUG_UI, "END");
+}
+
+/*****************************************************************************/
+/* Set state of a verb. */
+/*****************************************************************************/
+void
+gl_ui_util_set_verb_state (BonoboUIComponent *ui_component,
+ gchar *cname,
+ gboolean state)
+{
+ gl_debug (DEBUG_UI, "START");
+
+ g_return_if_fail (cname != NULL);
+ g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
+
+ bonobo_ui_component_set_prop (ui_component,
+ cname,
+ "state",
+ state ? "1" : "0",
+ NULL);
+
+ gl_debug (DEBUG_UI, "END");
+}
+
+\f
+/*****************************************************************************/
+/* Insert widget at path. */
+/*****************************************************************************/
+void
+gl_ui_util_insert_widget (BonoboUIComponent *ui_component,
+ GtkWidget *widget,
+ const char *path)
+{
+ BonoboControl *control;
+
+ gl_debug (DEBUG_UI, "START");
+
+ gtk_widget_show_all (widget);
+ control = bonobo_control_new (widget);
+ bonobo_ui_component_object_set (ui_component,
+ path,
+ BONOBO_OBJREF (control),
+ NULL);
+ bonobo_object_unref (BONOBO_OBJECT (control));
+
+ gl_debug (DEBUG_UI, "END");
+}
+
--- /dev/null
+/*
+ * (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ * ui-util.h: GLabels UI utilities module header file
+ *
+ * Copyright (C) 2001-2003 Jim Evins <evins@snaught.com>.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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
+ */
+#ifndef __GL_UI_UTIL_H__
+#define __GL_UI_UTIL_H__
+
+#include <bonobo/bonobo-ui-component.h>
+
+G_BEGIN_DECLS
+
+void gl_ui_util_set_verb_sensitive (BonoboUIComponent *ui_component,
+ gchar *cname,
+ gboolean sensitive);
+
+void gl_ui_util_set_verb_list_sensitive (BonoboUIComponent *ui_component,
+ gchar **vlist,
+ gboolean sensitive);
+
+void gl_ui_util_set_verb_state (BonoboUIComponent *ui_component,
+ gchar *cname,
+ gboolean state);
+
+void gl_ui_util_insert_widget (BonoboUIComponent *ui_component,
+ GtkWidget *widget,
+ const char *path);
+
+
+G_END_DECLS
+
+#endif /* __GL_UI_UTIL_H__ */
#include <gconf/gconf-client.h>
#include "ui.h"
+#include "ui-util.h"
#include "commands.h"
#include "tools.h"
#include "recent.h"
static void set_view_style (BonoboUIComponent *ui_component);
-static void set_verb_sensitive (BonoboUIComponent *ui_component,
- gchar *cname,
- gboolean sensitive);
-
-static void set_verb_list_sensitive (BonoboUIComponent *ui_component,
- gchar **vlist,
- gboolean sensitive);
-
-static void set_verb_state (BonoboUIComponent *ui_component,
- gchar *cname,
- gboolean state);
-
\f
/*****************************************************************************/
(BonoboUIListenerFn)view_menu_item_toggled_cb,
(gpointer)win);
- set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
+ gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
/* Status bar */
bonobo_ui_component_set_prop (ui_component,
bonobo_ui_component_freeze (ui_component, NULL);
- set_verb_list_sensitive (ui_component, doc_verbs, TRUE);
+ gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, TRUE);
label = view->label;
g_return_if_fail (label != NULL);
- set_verb_sensitive (ui_component, "/commands/EditUndo",
- gl_label_can_undo (label));
- set_verb_sensitive (ui_component, "/commands/EditRedo",
- gl_label_can_redo (label));
+ gl_ui_util_set_verb_sensitive (ui_component, "/commands/EditUndo",
+ gl_label_can_undo (label));
+ gl_ui_util_set_verb_sensitive (ui_component, "/commands/EditRedo",
+ gl_label_can_redo (label));
- set_verb_list_sensitive (ui_component,
- doc_modified_verbs,
- gl_label_is_modified (label));
+ gl_ui_util_set_verb_list_sensitive (ui_component,
+ doc_modified_verbs,
+ gl_label_is_modified (label));
- set_verb_sensitive (ui_component, "/commands/ToolsZoomIn",
- !gl_view_is_zoom_max (view));
- set_verb_sensitive (ui_component, "/commands/ToolsZoomOut",
- !gl_view_is_zoom_min (view));
+ gl_ui_util_set_verb_sensitive (ui_component, "/commands/ToolsZoomIn",
+ !gl_view_is_zoom_max (view));
+ gl_ui_util_set_verb_sensitive (ui_component, "/commands/ToolsZoomOut",
+ !gl_view_is_zoom_min (view));
- set_verb_list_sensitive (ui_component,
- selection_verbs,
- !gl_view_is_selection_empty (view));
+ gl_ui_util_set_verb_list_sensitive (ui_component,
+ selection_verbs,
+ !gl_view_is_selection_empty (view));
- set_verb_list_sensitive (ui_component,
- atomic_selection_verbs,
- gl_view_is_selection_atomic (view));
+ gl_ui_util_set_verb_list_sensitive (ui_component,
+ atomic_selection_verbs,
+ gl_view_is_selection_atomic (view));
- set_verb_list_sensitive (ui_component,
- multi_selection_verbs,
- !gl_view_is_selection_empty (view)
- && !gl_view_is_selection_atomic (view));
+ gl_ui_util_set_verb_list_sensitive (ui_component,
+ multi_selection_verbs,
+ !gl_view_is_selection_empty (view)
+ && !gl_view_is_selection_atomic (view));
bonobo_ui_component_thaw (ui_component, NULL);
bonobo_ui_component_freeze (ui_component, NULL);
- set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
+ gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
bonobo_ui_component_thaw (ui_component, NULL);
bonobo_ui_component_freeze (ui_component, NULL);
- set_verb_list_sensitive (ui_component,
- doc_modified_verbs,
- gl_label_is_modified (label));
+ gl_ui_util_set_verb_list_sensitive (ui_component,
+ doc_modified_verbs,
+ gl_label_is_modified (label));
bonobo_ui_component_thaw (ui_component, NULL);
bonobo_ui_component_freeze (ui_component, NULL);
- set_verb_list_sensitive (ui_component,
- selection_verbs,
- !gl_view_is_selection_empty (view));
+ gl_ui_util_set_verb_list_sensitive (ui_component,
+ selection_verbs,
+ !gl_view_is_selection_empty (view));
- set_verb_list_sensitive (ui_component,
- atomic_selection_verbs,
- gl_view_is_selection_atomic (view));
+ gl_ui_util_set_verb_list_sensitive (ui_component,
+ atomic_selection_verbs,
+ gl_view_is_selection_atomic (view));
- set_verb_list_sensitive (ui_component,
- multi_selection_verbs,
- !gl_view_is_selection_empty (view)
- && !gl_view_is_selection_atomic (view));
+ gl_ui_util_set_verb_list_sensitive (ui_component,
+ multi_selection_verbs,
+ !gl_view_is_selection_empty (view)
+ && !gl_view_is_selection_atomic (view));
bonobo_ui_component_thaw (ui_component, NULL);
bonobo_ui_component_freeze (ui_component, NULL);
- set_verb_sensitive (ui_component, "/commands/ToolsZoomIn",
- !gl_view_is_zoom_max (view));
- set_verb_sensitive (ui_component, "/commands/ToolsZoomOut",
- !gl_view_is_zoom_min (view));
+ gl_ui_util_set_verb_sensitive (ui_component, "/commands/ToolsZoomIn",
+ !gl_view_is_zoom_max (view));
+ gl_ui_util_set_verb_sensitive (ui_component, "/commands/ToolsZoomOut",
+ !gl_view_is_zoom_min (view));
bonobo_ui_component_thaw (ui_component, NULL);
bonobo_ui_component_freeze (ui_component, NULL);
- set_verb_sensitive (ui_component,
- "/commands/EditUndo", gl_label_can_undo (label));
+ gl_ui_util_set_verb_sensitive (ui_component,
+ "/commands/EditUndo",
+ gl_label_can_undo (label));
- set_verb_sensitive (ui_component,
- "/commands/EditRedo", gl_label_can_redo (label));
+ gl_ui_util_set_verb_sensitive (ui_component,
+ "/commands/EditRedo",
+ gl_label_can_redo (label));
bonobo_ui_component_thaw (ui_component, NULL);
bonobo_ui_component_freeze (ui_component, NULL);
/* Updated view menu */
- set_verb_state (ui_component,
- "/commands/ViewMainToolbar",
- gl_prefs->main_toolbar_visible);
-
- set_verb_sensitive (ui_component,
- "/commands/MainToolbarSystem",
- gl_prefs->main_toolbar_visible);
- set_verb_sensitive (ui_component,
- "/commands/MainToolbarIcon",
- gl_prefs->main_toolbar_visible);
- set_verb_sensitive (ui_component,
- "/commands/MainToolbarIconText",
- gl_prefs->main_toolbar_visible);
- set_verb_sensitive (ui_component,
- "/commands/MainToolbarTooltips",
- gl_prefs->main_toolbar_visible);
-
- set_verb_state (ui_component,
- "/commands/MainToolbarSystem",
- gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_SYSTEM);
-
- set_verb_state (ui_component,
- "/commands/MainToolbarIcon",
- gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_ICONS);
-
- set_verb_state (ui_component,
- "/commands/MainToolbarIconText",
- gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT);
-
- set_verb_state (ui_component,
- "/commands/MainToolbarTooltips",
- gl_prefs->main_toolbar_view_tooltips);
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/ViewMainToolbar",
+ gl_prefs->main_toolbar_visible);
+
+ gl_ui_util_set_verb_sensitive (ui_component,
+ "/commands/MainToolbarSystem",
+ gl_prefs->main_toolbar_visible);
+ gl_ui_util_set_verb_sensitive (ui_component,
+ "/commands/MainToolbarIcon",
+ gl_prefs->main_toolbar_visible);
+ gl_ui_util_set_verb_sensitive (ui_component,
+ "/commands/MainToolbarIconText",
+ gl_prefs->main_toolbar_visible);
+ gl_ui_util_set_verb_sensitive (ui_component,
+ "/commands/MainToolbarTooltips",
+ gl_prefs->main_toolbar_visible);
+
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/MainToolbarSystem",
+ gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_SYSTEM);
+
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/MainToolbarIcon",
+ gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_ICONS);
+
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/MainToolbarIconText",
+ gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT);
+
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/MainToolbarTooltips",
+ gl_prefs->main_toolbar_view_tooltips);
/* Actually update main_toolbar style */
bonobo_ui_component_freeze (ui_component, NULL);
/* Updated view menu */
- set_verb_state (ui_component,
- "/commands/ViewDrawingToolbar",
- gl_prefs->drawing_toolbar_visible);
-
- set_verb_sensitive (ui_component,
- "/commands/DrawingToolbarSystem",
- gl_prefs->drawing_toolbar_visible);
- set_verb_sensitive (ui_component,
- "/commands/DrawingToolbarIcon",
- gl_prefs->drawing_toolbar_visible);
- set_verb_sensitive (ui_component,
- "/commands/DrawingToolbarIconText",
- gl_prefs->drawing_toolbar_visible);
- set_verb_sensitive (ui_component,
- "/commands/DrawingToolbarTooltips",
- gl_prefs->drawing_toolbar_visible);
-
- set_verb_state (
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/ViewDrawingToolbar",
+ gl_prefs->drawing_toolbar_visible);
+
+ gl_ui_util_set_verb_sensitive (ui_component,
+ "/commands/DrawingToolbarSystem",
+ gl_prefs->drawing_toolbar_visible);
+ gl_ui_util_set_verb_sensitive (ui_component,
+ "/commands/DrawingToolbarIcon",
+ gl_prefs->drawing_toolbar_visible);
+ gl_ui_util_set_verb_sensitive (ui_component,
+ "/commands/DrawingToolbarIconText",
+ gl_prefs->drawing_toolbar_visible);
+ gl_ui_util_set_verb_sensitive (ui_component,
+ "/commands/DrawingToolbarTooltips",
+ gl_prefs->drawing_toolbar_visible);
+
+ gl_ui_util_set_verb_state (
ui_component,
"/commands/DrawingToolbarSystem",
gl_prefs->drawing_toolbar_buttons_style == GL_TOOLBAR_SYSTEM);
- set_verb_state (
+ gl_ui_util_set_verb_state (
ui_component,
"/commands/DrawingToolbarIcon",
gl_prefs->drawing_toolbar_buttons_style == GL_TOOLBAR_ICONS);
- set_verb_state (
+ gl_ui_util_set_verb_state (
ui_component,
"/commands/DrawingToolbarIconText",
gl_prefs->drawing_toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT);
- set_verb_state (ui_component,
+ gl_ui_util_set_verb_state (ui_component,
"/commands/DrawingToolbarTooltips",
gl_prefs->drawing_toolbar_view_tooltips);
bonobo_ui_component_freeze (ui_component, NULL);
- set_verb_state (ui_component,
- "/commands/ViewGrid",
- gl_prefs->grid_visible);
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/ViewGrid",
+ gl_prefs->grid_visible);
- set_verb_state (ui_component,
- "/commands/ViewMarkup",
- gl_prefs->markup_visible);
+ gl_ui_util_set_verb_state (ui_component,
+ "/commands/ViewMarkup",
+ gl_prefs->markup_visible);
error:
bonobo_ui_component_thaw (ui_component, NULL);
}
-/*---------------------------------------------------------------------------*/
-/* Set sensitivity of verb. */
-/*---------------------------------------------------------------------------*/
-static void
-set_verb_sensitive (BonoboUIComponent *ui_component,
- gchar *cname,
- gboolean sensitive)
-{
- gl_debug (DEBUG_UI, "START");
-
- g_return_if_fail (cname != NULL);
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
-
- bonobo_ui_component_set_prop (ui_component,
- cname,
- "sensitive",
- sensitive ? "1" : "0",
- NULL);
-
- gl_debug (DEBUG_UI, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* Set sensitivity of a list of verbs. */
-/*---------------------------------------------------------------------------*/
-static void
-set_verb_list_sensitive (BonoboUIComponent *ui_component,
- gchar **vlist,
- gboolean sensitive)
-{
- gl_debug (DEBUG_UI, "START");
-
- g_return_if_fail (vlist != NULL);
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
-
- for ( ; *vlist; ++vlist)
- {
- bonobo_ui_component_set_prop (ui_component,
- *vlist,
- "sensitive",
- sensitive ? "1" : "0",
- NULL);
- }
-
- gl_debug (DEBUG_UI, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* Set state of a verb. */
-/*---------------------------------------------------------------------------*/
-static void
-set_verb_state (BonoboUIComponent *ui_component,
- gchar *cname,
- gboolean state)
-{
- gl_debug (DEBUG_UI, "START");
-
- g_return_if_fail (cname != NULL);
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
-
- bonobo_ui_component_set_prop (ui_component,
- cname,
- "state",
- state ? "1" : "0",
- NULL);
-
- gl_debug (DEBUG_UI, "END");
-}
-
#include "wdgt-bc-style.h"
#include "wdgt-position.h"
#include "color.h"
-#include "prefs.h"
#include "pixmaps/cursor_barcode.xbm"
#include "pixmaps/cursor_barcode_mask.xbm"
GL_BARCODE_STYLE_POSTNET,
FALSE,
TRUE,
- gl_color_set_opacity (gl_prefs->default_line_color, 0.5));
+ gl_color_set_opacity (
+ gl_view_get_default_line_color(view),
+ 0.5));
view_barcode = gl_view_barcode_new (GL_LABEL_BARCODE(object),
view);
x0 = x;
GL_BARCODE_STYLE_POSTNET,
FALSE,
TRUE,
- gl_prefs->default_line_color);
+ gl_view_get_default_line_color(view));
gl_view_unselect_all (view);
gl_view_object_select (GL_VIEW_OBJECT(view_barcode));
gl_view_arrow_mode (view);
#include "wdgt-size.h"
#include "wdgt-position.h"
#include "color.h"
-#include "prefs.h"
#include "pixmaps/cursor_box.xbm"
#include "pixmaps/cursor_box_mask.xbm"
x, y);
gl_label_object_set_size (GL_LABEL_OBJECT(object),
0.0, 0.0);
- line_color = gl_color_set_opacity (gl_prefs->default_line_color, 0.5);
- fill_color = gl_color_set_opacity (gl_prefs->default_fill_color, 0.5);
+ line_color = gl_color_set_opacity (gl_view_get_default_line_color(view), 0.5);
+ fill_color = gl_color_set_opacity (gl_view_get_default_fill_color(view), 0.5);
gl_label_box_set_line_width (GL_LABEL_BOX(object),
- gl_prefs->default_line_width);
+ gl_view_get_default_line_width(view));
gl_label_box_set_line_color (GL_LABEL_BOX(object),
line_color);
gl_label_box_set_fill_color (GL_LABEL_BOX(object),
gl_label_object_set_size (GL_LABEL_OBJECT(object),
w, h);
gl_label_box_set_line_color (GL_LABEL_BOX(object),
- gl_prefs->default_line_color);
+ gl_view_get_default_line_color(view));
gl_label_box_set_fill_color (GL_LABEL_BOX(object),
- gl_prefs->default_fill_color);
+ gl_view_get_default_fill_color(view));
gl_view_unselect_all (view);
gl_view_object_select (GL_VIEW_OBJECT(view_box));
gl_view_arrow_mode (view);
#include "wdgt-size.h"
#include "wdgt-position.h"
#include "color.h"
-#include "prefs.h"
#include "pixmaps/cursor_ellipse.xbm"
#include "pixmaps/cursor_ellipse_mask.xbm"
x, y);
gl_label_object_set_size (GL_LABEL_OBJECT(object),
0.0, 0.0);
- line_color = gl_color_set_opacity (gl_prefs->default_line_color, 0.5);
- fill_color = gl_color_set_opacity (gl_prefs->default_fill_color, 0.5);
+ line_color = gl_color_set_opacity (gl_view_get_default_line_color(view), 0.5);
+ fill_color = gl_color_set_opacity (gl_view_get_default_fill_color(view), 0.5);
gl_label_ellipse_set_line_width (GL_LABEL_ELLIPSE(object),
- gl_prefs->default_line_width);
+ gl_view_get_default_line_width (view));
gl_label_ellipse_set_line_color (GL_LABEL_ELLIPSE(object),
line_color);
gl_label_ellipse_set_fill_color (GL_LABEL_ELLIPSE(object),
gl_label_object_set_size (GL_LABEL_OBJECT(object),
w, h);
gl_label_ellipse_set_line_color (GL_LABEL_ELLIPSE(object),
- gl_prefs->default_line_color);
+ gl_view_get_default_line_color (view));
gl_label_ellipse_set_fill_color (GL_LABEL_ELLIPSE(object),
- gl_prefs->default_fill_color);
+ gl_view_get_default_fill_color (view));
gl_view_unselect_all (view);
gl_view_object_select (GL_VIEW_OBJECT(view_ellipse));
gl_view_arrow_mode (view);
#include "wdgt-vector.h"
#include "wdgt-position.h"
#include "color.h"
-#include "prefs.h"
#include "pixmaps/cursor_line.xbm"
#include "pixmaps/cursor_line_mask.xbm"
gl_label_object_set_size (GL_LABEL_OBJECT(object),
0.0, 0.0);
gl_label_line_set_line_width (GL_LABEL_LINE(object),
- gl_prefs->default_line_width);
+ gl_view_get_default_line_width(view));
gl_label_line_set_line_color (GL_LABEL_LINE(object),
- gl_color_set_opacity (gl_prefs->default_line_color, 0.5));
+ gl_color_set_opacity (gl_view_get_default_line_color(view), 0.5));
view_line = gl_view_line_new (GL_LABEL_LINE(object),
view);
x0 = x;
gl_label_object_set_size (GL_LABEL_OBJECT(object),
w, h);
gl_label_line_set_line_color (GL_LABEL_LINE(object),
- gl_prefs->default_line_color);
+ gl_view_get_default_line_color(view));
gl_view_unselect_all (view);
gl_view_object_select (GL_VIEW_OBJECT(view_line));
gl_view_arrow_mode (view);
#include "wdgt-text-props.h"
#include "wdgt-position.h"
#include "color.h"
-#include "prefs.h"
#include "hig.h"
#include "pixmaps/cursor_text.xbm"
static GObject *object;
gdouble x, y;
GList *lines;
+ gchar *family;
gl_debug (DEBUG_VIEW, "");
object = gl_label_text_new (view->label);
gl_label_object_set_position (GL_LABEL_OBJECT(object),
x, y);
+ family = gl_view_get_default_font_family (view);
gl_label_text_set_props (GL_LABEL_TEXT(object),
- gl_prefs->default_font_family,
- gl_prefs->default_font_size,
- gl_prefs->default_font_weight,
- gl_prefs->default_font_italic_flag,
- gl_color_set_opacity (gl_prefs->default_text_color, 0.5),
- gl_prefs->default_text_alignment);
+ family,
+ gl_view_get_default_font_size (view),
+ gl_view_get_default_font_weight (view),
+ gl_view_get_default_font_italic_flag (view),
+ gl_color_set_opacity (gl_view_get_default_text_color (view), 0.5),
+ gl_view_get_default_text_alignment (view));
+ g_free (family);
lines = gl_text_node_lines_new_from_text (_("Text"));
gl_label_text_set_lines (GL_LABEL_TEXT(object), lines);
view_text = gl_view_text_new (GL_LABEL_TEXT(object),
event->button.y, &x, &y);
gl_label_object_set_position (GL_LABEL_OBJECT(object),
x, y);
+ family = gl_view_get_default_font_family (view);
gl_label_text_set_props (GL_LABEL_TEXT(object),
- gl_prefs->default_font_family,
- gl_prefs->default_font_size,
- gl_prefs->default_font_weight,
- gl_prefs->default_font_italic_flag,
- gl_prefs->default_text_color,
- gl_prefs->default_text_alignment);
+ family,
+ gl_view_get_default_font_size (view),
+ gl_view_get_default_font_weight (view),
+ gl_view_get_default_font_italic_flag (view),
+ gl_view_get_default_text_color (view),
+ gl_view_get_default_text_alignment (view));
+ g_free (family);
gl_view_unselect_all (view);
gl_view_object_select (GL_VIEW_OBJECT(view_text));
gl_view_arrow_mode (view);
#include "color.h"
#include "stock.h"
#include "merge-properties-dialog.h"
+#include "prefs.h"
#include "marshal.h"
#include "debug.h"
view->grid_spacing = 9;
+ view->default_font_family = NULL;
+
gl_debug (DEBUG_VIEW, "END");
}
construct_selection_menu (view);
construct_empty_selection_menu (view);
+ gl_view_set_default_font_family (view, gl_prefs->default_font_family);
+ gl_view_set_default_font_size (view, gl_prefs->default_font_size);
+ gl_view_set_default_font_weight (view, gl_prefs->default_font_weight);
+ gl_view_set_default_font_italic_flag (view, gl_prefs->default_font_italic_flag);
+ gl_view_set_default_text_color (view, gl_prefs->default_text_color);
+ gl_view_set_default_text_alignment (view, gl_prefs->default_text_alignment);
+ gl_view_set_default_line_width (view, gl_prefs->default_line_width);
+ gl_view_set_default_line_color (view, gl_prefs->default_line_color);
+ gl_view_set_default_fill_color (view, gl_prefs->default_fill_color);
+
gl_debug (DEBUG_VIEW, "END");
}
gl_debug (DEBUG_VIEW, "END");
}
+/*****************************************************************************/
+/* Can text properties be set for selection? */
+/*****************************************************************************/
+gboolean
+gl_view_can_selection_text (glView *view)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), FALSE);
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ if (gl_label_object_can_text (object)) {
+ return TRUE;
+ }
+
+ }
+
+ return FALSE;
+}
+
+/*****************************************************************************/
+/* Set font family for all text contained in selected objects. */
+/*****************************************************************************/
+void
+gl_view_set_selection_font_family (glView *view,
+ const gchar *font_family)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ gl_label_object_set_font_family (object, font_family);
+
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*****************************************************************************/
+/* Set font size for all text contained in selected objects. */
+/*****************************************************************************/
+void
+gl_view_set_selection_font_size (glView *view,
+ gdouble font_size)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ gl_label_object_set_font_size (object, font_size);
+
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*****************************************************************************/
+/* Set font weight for all text contained in selected objects. */
+/*****************************************************************************/
+void
+gl_view_set_selection_font_weight (glView *view,
+ GnomeFontWeight font_weight)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ gl_label_object_set_font_weight (object, font_weight);
+
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*****************************************************************************/
+/* Set font italic flag for all text contained in selected objects. */
+/*****************************************************************************/
+void
+gl_view_set_selection_font_italic_flag (glView *view,
+ gboolean font_italic_flag)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ gl_label_object_set_font_italic_flag (object, font_italic_flag);
+
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*****************************************************************************/
+/* Set text alignment for all text contained in selected objects. */
+/*****************************************************************************/
+void
+gl_view_set_selection_text_alignment (glView *view,
+ GtkJustification text_alignment)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ gl_label_object_set_text_alignment (object, text_alignment);
+
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*****************************************************************************/
+/* Set text color for all text contained in selected objects. */
+/*****************************************************************************/
+void
+gl_view_set_selection_text_color (glView *view,
+ guint text_color)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ gl_label_object_set_text_color (object, text_color);
+
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*****************************************************************************/
+/* Can fill properties be set for selection? */
+/*****************************************************************************/
+gboolean
+gl_view_can_selection_fill (glView *view)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), FALSE);
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ if (gl_label_object_can_fill (object)) {
+ return TRUE;
+ }
+
+ }
+
+ return FALSE;
+}
+
+/*****************************************************************************/
+/* Set fill color for all selected objects. */
+/*****************************************************************************/
+void
+gl_view_set_selection_fill_color (glView *view,
+ guint fill_color)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ gl_label_object_set_fill_color (object, fill_color);
+
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*****************************************************************************/
+/* Can line color properties be set for selection? */
+/*****************************************************************************/
+gboolean
+gl_view_can_selection_line_color (glView *view)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), FALSE);
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ if (gl_label_object_can_line_color (object)) {
+ return TRUE;
+ }
+
+ }
+
+ return FALSE;
+}
+
+/*****************************************************************************/
+/* Set line color for all selected objects. */
+/*****************************************************************************/
+void
+gl_view_set_selection_line_color (glView *view,
+ guint line_color)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ gl_label_object_set_line_color (object, line_color);
+
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*****************************************************************************/
+/* Can line width properties be set for selection? */
+/*****************************************************************************/
+gboolean
+gl_view_can_selection_line_width (glView *view)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), FALSE);
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ if (gl_label_object_can_line_width (object)) {
+ return TRUE;
+ }
+
+ }
+
+ return FALSE;
+}
+
+/*****************************************************************************/
+/* Set line width for all selected objects. */
+/*****************************************************************************/
+void
+gl_view_set_selection_line_width (glView *view,
+ gdouble line_width)
+{
+ GList *p;
+ glLabelObject *object;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ gl_label_object_set_line_width (object, line_width);
+
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
/*****************************************************************************/
/* "Cut" selected items and place in clipboard selections. */
/*****************************************************************************/
gl_debug (DEBUG_VIEW, "END");
}
+/****************************************************************************/
+/* Set default font family. */
+/****************************************************************************/
+void
+gl_view_set_default_font_family (glView *view,
+ const gchar *font_family)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ if (view->default_font_family) {
+ g_free (view->default_font_family);
+ }
+ view->default_font_family = g_strdup (font_family);
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+
+/****************************************************************************/
+/* Set default font size. */
+/****************************************************************************/
+void
+gl_view_set_default_font_size (glView *view,
+ gdouble font_size)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ view->default_font_size = font_size;
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+
+/****************************************************************************/
+/* Set default font weight. */
+/****************************************************************************/
+void
+gl_view_set_default_font_weight (glView *view,
+ GnomeFontWeight font_weight)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ view->default_font_weight = font_weight;
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+
+/****************************************************************************/
+/* Set default font italic flag. */
+/****************************************************************************/
+void
+gl_view_set_default_font_italic_flag (glView *view,
+ gboolean font_italic_flag)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ view->default_font_italic_flag = font_italic_flag;
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+
+/****************************************************************************/
+/* Set default text color. */
+/****************************************************************************/
+void
+gl_view_set_default_text_color (glView *view,
+ guint text_color)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ view->default_text_color = text_color;
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+
+/****************************************************************************/
+/* Set default text alignment. */
+/****************************************************************************/
+void
+gl_view_set_default_text_alignment (glView *view,
+ GtkJustification text_alignment)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ view->default_text_alignment = text_alignment;
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+
+/****************************************************************************/
+/* Set default line width. */
+/****************************************************************************/
+void
+gl_view_set_default_line_width (glView *view,
+ gdouble line_width)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ view->default_line_width = line_width;
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+
+/****************************************************************************/
+/* Set default line color. */
+/****************************************************************************/
+void
+gl_view_set_default_line_color (glView *view,
+ guint line_color)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ view->default_line_color = line_color;
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+
+/****************************************************************************/
+/* Set default fill color. */
+/****************************************************************************/
+void
+gl_view_set_default_fill_color (glView *view,
+ guint fill_color)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+
+ view->default_fill_color = fill_color;
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+
+
+/****************************************************************************/
+/* Get default font family. */
+/****************************************************************************/
+gchar *
+gl_view_get_default_font_family (glView *view)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), NULL);
+
+ gl_debug (DEBUG_VIEW, "END");
+
+ return g_strdup (view->default_font_family);
+}
+
+
+/****************************************************************************/
+/* Get default font size. */
+/****************************************************************************/
+gdouble
+gl_view_get_default_font_size (glView *view)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), 12.0);
+
+ gl_debug (DEBUG_VIEW, "END");
+
+ return view->default_font_size;
+}
+
+
+/****************************************************************************/
+/* Get default font weight. */
+/****************************************************************************/
+GnomeFontWeight
+gl_view_get_default_font_weight (glView *view)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), GNOME_FONT_BOOK);
+
+ gl_debug (DEBUG_VIEW, "END");
+
+ return view->default_font_weight;
+}
+
+
+/****************************************************************************/
+/* Get default font italic flag. */
+/****************************************************************************/
+gboolean
+gl_view_get_default_font_italic_flag (glView *view)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), FALSE);
+
+ gl_debug (DEBUG_VIEW, "END");
+
+ return view->default_font_italic_flag;
+}
+
+
+/****************************************************************************/
+/* Get default text color. */
+/****************************************************************************/
+guint
+gl_view_get_default_text_color (glView *view)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), 0);
+
+ gl_debug (DEBUG_VIEW, "END");
+
+ return view->default_text_color;
+}
+
+
+/****************************************************************************/
+/* Get default text alignment. */
+/****************************************************************************/
+GtkJustification
+gl_view_get_default_text_alignment (glView *view)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), GTK_JUSTIFY_LEFT);
+
+ gl_debug (DEBUG_VIEW, "END");
+
+ return view->default_text_alignment;
+}
+
+
+/****************************************************************************/
+/* Get default line width. */
+/****************************************************************************/
+gdouble
+gl_view_get_default_line_width (glView *view)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), 1.0);
+
+ gl_debug (DEBUG_VIEW, "END");
+
+ return view->default_line_width;
+}
+
+
+/****************************************************************************/
+/* Get default line color. */
+/****************************************************************************/
+guint gl_view_get_default_line_color (glView *view)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), 0);
+
+ gl_debug (DEBUG_VIEW, "END");
+
+ return view->default_line_color;
+}
+
+
+/****************************************************************************/
+/* Get default fill color. */
+/****************************************************************************/
+guint gl_view_get_default_fill_color (glView *view)
+{
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_val_if_fail (view && GL_IS_VIEW (view), 0);
+
+ gl_debug (DEBUG_VIEW, "END");
+
+ return view->default_fill_color;
+}
+
#include <gtk/gtk.h>
#include <libgnomecanvas/libgnomecanvas.h>
+#include <libgnomeprint/gnome-font.h>
#include "label-object.h"
/* Merge Properties Dialog */
GtkWidget *merge_props_dialog;
+
+ /* Default object text properties */
+ gchar *default_font_family;
+ gdouble default_font_size;
+ GnomeFontWeight default_font_weight;
+ gboolean default_font_italic_flag;
+ guint default_text_color;
+ GtkJustification default_text_alignment;
+
+ /* Default object line properties */
+ gdouble default_line_width;
+ guint default_line_color;
+
+ /* Default object fill properties */
+ guint default_fill_color;
};
struct _glViewClass {
gdouble dx,
gdouble dy);
+gboolean gl_view_can_selection_text (glView *view);
+
+void gl_view_set_selection_font_family (glView *view,
+ const gchar *font_family);
+
+void gl_view_set_selection_font_size (glView *view,
+ gdouble font_size);
+
+void gl_view_set_selection_font_weight (glView *view,
+ GnomeFontWeight font_weight);
+
+void gl_view_set_selection_font_italic_flag (glView *view,
+ gboolean font_italic_flag);
+
+void gl_view_set_selection_text_alignment (glView *view,
+ GtkJustification text_alignment);
+
+void gl_view_set_selection_text_color (glView *view,
+ guint text_color);
+
+gboolean gl_view_can_selection_fill (glView *view);
+
+void gl_view_set_selection_fill_color (glView *view,
+ guint fill_color);
+
+gboolean gl_view_can_selection_line_color (glView *view);
+
+void gl_view_set_selection_line_color (glView *view,
+ guint line_color);
+
+gboolean gl_view_can_selection_line_width (glView *view);
+
+void gl_view_set_selection_line_width (glView *view,
+ gdouble line_width);
+
+
void gl_view_cut (glView *view);
void gl_view_copy (glView *view);
void gl_view_edit_merge_props (glView *view);
+void gl_view_set_default_font_family (glView *view,
+ const gchar *font_family);
+
+void gl_view_set_default_font_size (glView *view,
+ gdouble font_size);
+
+void gl_view_set_default_font_weight (glView *view,
+ GnomeFontWeight font_weight);
+
+void gl_view_set_default_font_italic_flag (glView *view,
+ gboolean font_italic_flag);
+
+void gl_view_set_default_text_color (glView *view,
+ guint text_color);
+
+void gl_view_set_default_text_alignment (glView *view,
+ GtkJustification text_alignment);
+
+void gl_view_set_default_line_width (glView *view,
+ gdouble line_width);
+
+void gl_view_set_default_line_color (glView *view,
+ guint line_color);
+
+void gl_view_set_default_fill_color (glView *view,
+ guint fill_color);
+
+
+gchar *gl_view_get_default_font_family (glView *view);
+
+gdouble gl_view_get_default_font_size (glView *view);
+
+GnomeFontWeight gl_view_get_default_font_weight (glView *view);
+
+gboolean gl_view_get_default_font_italic_flag (glView *view);
+
+guint gl_view_get_default_text_color (glView *view);
+
+GtkJustification gl_view_get_default_text_alignment (glView *view);
+
+gdouble gl_view_get_default_line_width (glView *view);
+
+guint gl_view_get_default_line_color (glView *view);
+
+guint gl_view_get_default_fill_color (glView *view);
+
+
+
G_END_DECLS
#endif
GList *family_names;
gchar *good_font_family;
- /* Make sure we have a valid font family. if not privide a good default. */
+ /* Make sure we have a valid font family. if not provide a good default. */
family_names = gnome_font_family_list ();
if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) {
good_font_family = g_strdup (font_family);
/* Private macros and constants. */
/*============================================================================*/
-#define DEFAULT_WINDOW_WIDTH 500
-#define DEFAULT_WINDOW_HEIGHT 375
+#define DEFAULT_WINDOW_WIDTH 700
+#define DEFAULT_WINDOW_HEIGHT 560
#define CURSOR_INFO_WIDTH 150
#define ZOOM_INFO_WIDTH 50
window->cursor_info_frame,
window->zoom_info_frame);
+ window->property_bar =
+ GL_UI_PROPERTY_BAR(gl_ui_property_bar_new (ui_component));
+
gtk_window_set_default_size (GTK_WINDOW (window),
DEFAULT_WINDOW_WIDTH,
DEFAULT_WINDOW_HEIGHT);
gl_ui_update_all (window->uic, GL_VIEW(window->view));
+ gl_ui_property_bar_set_view (window->property_bar, GL_VIEW(window->view));
+
string = g_strdup_printf ("%3.0f%%",
100.0*gl_view_get_zoom (GL_VIEW(window->view)));
gtk_label_set_text (GTK_LABEL(window->zoom_info), string);
#include "view.h"
#include "label.h"
+#include "ui-property-bar.h"
+
G_BEGIN_DECLS
#define GL_TYPE_WINDOW (gl_window_get_type ())
GtkWidget *view;
+ glUIPropertyBar *property_bar;
+
GtkWidget *cursor_info;
GtkWidget *cursor_info_frame;
GtkWidget *zoom_info;