dia r4053 - in trunk: . app data plug-ins/cairo plug-ins/postscript plug-ins/wmf
- From: hans svn gnome org
- To: svn-commits-list gnome org
- Subject: dia r4053 - in trunk: . app data plug-ins/cairo plug-ins/postscript plug-ins/wmf
- Date: Sun, 25 May 2008 18:34:23 +0000 (UTC)
Author: hans
Date: Sun May 25 18:34:23 2008
New Revision: 4053
URL: http://svn.gnome.org/viewvc/dia?rev=4053&view=rev
Log:
2008-05-18 Hans Breuer <hans breuer org>
* app/commands.c(file_print_callback) : implement by querying for
print plug-ins in order of preference for different platforms
* app/display.c(ddisplay_set_cursor) : don't try to set a cursor on a
window not yet created
* app/interface.c(use_integrated_ui_for_display_shell) : pass the
renderer preference when ddisplay_set_renderer() - too early
* app/render_gdk.c(set_size): handle being called without a window
gracefully. Together this allows to start the Integrated UI without
g_warning().
* app/menu.[ch] : make add_plugin_actions() work for all GUI variants,
get rid of add_toolbox_plugin_actions(). Fixes bug #526146
* plug-ins/cairo/diacairo.c plug-ins/postscript/postscript.c
plug-ins/wmf/wmf.cpp : don't crash on data being NULL (integrated UI
does not yet properly disable menu items)
* data/display-ui.xml : get rid of the "<Display>/Diagram" by moving
the *two* entries to the Edit menu (like with Integrated UI)
* data/integrated-ui.xml : add Find & Replace
* app/interface.c : use fallback window icon code for Integrated UI,
too. Fixes bug #526147
Modified:
trunk/ChangeLog
trunk/app/commands.c
trunk/app/display.c
trunk/app/interface.c
trunk/app/menus.c
trunk/app/menus.h
trunk/app/render_gdk.c
trunk/data/display-ui.xml
trunk/data/integrated-ui.xml
trunk/plug-ins/cairo/diacairo.c
trunk/plug-ins/postscript/postscript.c
trunk/plug-ins/wmf/wmf.cpp
Modified: trunk/app/commands.c
==============================================================================
--- trunk/app/commands.c (original)
+++ trunk/app/commands.c Sun May 25 18:34:23 2008
@@ -104,14 +104,24 @@
}
void
-file_print_callback (GtkAction *action)
+file_print_callback (GtkAction *_action)
{
Diagram *dia;
+ GtkAction *action;
dia = ddisplay_active_diagram();
if (!dia) return;
+
+ action = menus_get_action ("FilePrintGTK");
+ if (!action)
+ action = menus_get_action ("FilePrintGDI");
+ if (!action)
+ action = menus_get_action ("FilePrintPS");
#if 1
- message_error ("No print plug-in here (yet)!");
+ if (action)
+ gtk_action_activate (action);
+ else
+ message_error (_("No print plug-in found!"));
#else
#ifdef G_OS_WIN32
/* This option could be used with Gnome too. Does it make sense there ? */
Modified: trunk/app/display.c
==============================================================================
--- trunk/app/display.c (original)
+++ trunk/app/display.c Sun May 25 18:34:23 2008
@@ -1356,7 +1356,8 @@
void
ddisplay_set_cursor(DDisplay *ddisp, GdkCursor *cursor)
{
- gdk_window_set_cursor(ddisp->canvas->window, cursor);
+ if (ddisp->canvas->window)
+ gdk_window_set_cursor(ddisp->canvas->window, cursor);
}
/** Returns whether the rulers are currently showing on the display.
Modified: trunk/app/interface.c
==============================================================================
--- trunk/app/interface.c (original)
+++ trunk/app/interface.c Sun May 25 18:34:23 2008
@@ -676,7 +676,7 @@
* The show causes a GDK_CONFIGURE event but this is not happening here. If this
* is not set a seg-fault occurs when dia_renderer_get_width_pixels() is called
*/
- ddisplay_set_renderer(ddisp, /* aa */0);
+ ddisplay_set_renderer(ddisp, ddisp->aa_renderer);
/* set the focus to the canvas area */
gtk_widget_grab_focus (ddisp->canvas);
@@ -1586,10 +1586,24 @@
return FALSE;
}
+static void
+app_set_icon (GtkWindow *window)
+{
+ gtk_window_set_icon_name (window, "dia");
+ if (!gtk_window_get_icon (window)) {
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline (-1, dia_app_icon, FALSE, NULL);
+ if (pixbuf) {
+ gtk_window_set_icon (window, pixbuf);
+ g_object_unref (pixbuf);
+ }
+ }
+}
+
/**
* Create integrated user interface
*/
-void create_integrated_ui (void)
+void
+create_integrated_ui (void)
{
GtkWidget *window;
GtkWidget *main_vbox;
@@ -1616,7 +1630,7 @@
gtk_window_set_default_size (GTK_WINDOW (window), 146, 349);
- gtk_window_set_icon_name (GTK_WINDOW (window), "dia");
+ app_set_icon (GTK_WINDOW (window));
g_signal_connect (GTK_OBJECT (window), "delete_event",
G_CALLBACK (toolbox_delete),
@@ -1736,7 +1750,7 @@
gtk_window_set_role (GTK_WINDOW (window), "toolbox_window");
gtk_window_set_default_size(GTK_WINDOW(window), 146, 349);
- gtk_window_set_icon_name (GTK_WINDOW (window), "dia");
+ app_set_icon (GTK_WINDOW (window));
if (!gtk_window_get_icon (GTK_WINDOW (window))) {
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline (-1, dia_app_icon, FALSE, NULL);
if (pixbuf) {
Modified: trunk/app/menus.c
==============================================================================
--- trunk/app/menus.c (original)
+++ trunk/app/menus.c Sun May 25 18:34:23 2008
@@ -61,8 +61,7 @@
static GtkWidget *
create_integrated_ui_toolbar (void);
-static void
-add_toolbox_plugin_actions (GtkUIManager *ui_manager);
+static void add_plugin_actions (GtkUIManager *ui_manager, const char *base_path);
static gchar*
build_ui_filename (const gchar* name);
@@ -667,7 +666,7 @@
/* initialize callbacks from plug-ins */
static void
-add_plugin_actions (GtkUIManager *ui_manager)
+add_plugin_actions (GtkUIManager *ui_manager, const gchar *base_path)
{
GtkActionGroup *actions;
GtkAction *action;
@@ -689,6 +688,7 @@
g_object_unref (actions);
for (cblist = filter_get_callbacks(); cblist; cblist = cblist->next) {
+ gchar *menu_path = NULL;
cbf = cblist->data;
@@ -703,9 +703,16 @@
continue;
}
- if (strncmp (cbf->menupath, DISPLAY_MENU, strlen (DISPLAY_MENU)) != 0) {
- /* hook for toolbox, skip */
+ if ( base_path != NULL
+ && strncmp (cbf->menupath, base_path, strlen (base_path)) != 0) {
+ /* hook for wrong base path, skip */
continue;
+ } else if (!base_path) {
+ /* only replace what we know */
+ if (strncmp (cbf->menupath, DISPLAY_MENU, strlen (DISPLAY_MENU)) == 0)
+ menu_path = g_strdup_printf ("%s%s", INTEGRATED_MENU, cbf->menupath + strlen (DISPLAY_MENU));
+ else if (strncmp (cbf->menupath, TOOLBOX_MENU, strlen (TOOLBOX_MENU)) == 0)
+ menu_path = g_strdup_printf ("%s%s", INTEGRATED_MENU, cbf->menupath + strlen (TOOLBOX_MENU));
}
action = gtk_action_new (cbf->action, cbf->description, NULL, NULL);
@@ -715,13 +722,14 @@
gtk_action_group_add_action (actions, action);
g_object_unref (G_OBJECT (action));
- id = ensure_menu_path (ui_manager, actions, cbf->menupath, TRUE);
+ id = ensure_menu_path (ui_manager, actions, menu_path ? menu_path : cbf->menupath, TRUE);
gtk_ui_manager_add_ui (ui_manager, id,
- cbf->menupath,
+ menu_path ? menu_path : cbf->menupath,
cbf->description,
cbf->action,
GTK_UI_MANAGER_AUTO,
FALSE);
+ g_free (menu_path);
}
}
@@ -891,9 +899,8 @@
g_assert (display_menubar);
- add_toolbox_plugin_actions (toolbox_ui_manager);
-
- add_plugin_actions (display_ui_manager);
+ add_plugin_actions (toolbox_ui_manager, TOOLBOX_MENU);
+ add_plugin_actions (display_ui_manager, DISPLAY_MENU);
/* load accelerators and prepare to later save them */
accelfilename = dia_config_filename("menurc");
@@ -905,65 +912,6 @@
gtk_quit_add(1, save_accels, NULL);
}
-static void
-add_toolbox_plugin_actions (GtkUIManager *ui_manager)
-{
- GtkActionGroup *plugin_actions;
- /* GtkActionGroup *actions; */
- GtkAction *action;
- GList *cblist;
- DiaCallbackFilter *cbf = NULL;
- /* gchar *name; */
- guint id;
- /* static guint cnt = 0; */
-
- /* plugin menu hooks */
- plugin_actions = gtk_action_group_new ("toolbox-plugin-actions");
- gtk_action_group_set_translation_domain (plugin_actions, NULL);
- gtk_action_group_set_translate_func (plugin_actions, _dia_translate, NULL, NULL);
- gtk_ui_manager_insert_action_group (ui_manager,
- plugin_actions, 5 /* "back" */);
- g_object_unref (plugin_actions);
-
- for (cblist = filter_get_callbacks(); cblist; cblist = cblist->next) {
-
- cbf = cblist->data;
-
- if (cbf == NULL) {
- g_warning ("missing DiaCallbackFilter instance");
- continue;
- }
-
- if (cbf->action == NULL) {
- g_warning ("Plugin '%s': doesn't specify action. Loading failed.",
- cbf->description);
- continue;
- }
-
- if (strncmp (cbf->menupath, TOOLBOX_MENU, strlen (TOOLBOX_MENU)) != 0) {
- /* no hook for display, skip */
- continue;
- }
-
- action = gtk_action_new (cbf->action, cbf->description,
- NULL, NULL);
- g_signal_connect (G_OBJECT (action), "activate",
- G_CALLBACK (plugin_callback),
- (gpointer) cbf);
-
- gtk_action_group_add_action (plugin_actions, action);
- g_object_unref (G_OBJECT (action));
-
- id = ensure_menu_path (ui_manager, plugin_actions, cbf->menupath, TRUE);
- gtk_ui_manager_add_ui (ui_manager, id,
- cbf->menupath,
- cbf->description,
- cbf->action,
- GTK_UI_MANAGER_AUTO,
- FALSE);
- }
-}
-
void
menus_get_integrated_ui_menubar (GtkWidget **menubar,
GtkWidget **toolbar,
@@ -1015,11 +963,10 @@
}
g_free (uifile);
- add_toolbox_plugin_actions (integrated_ui_manager);
- add_plugin_actions (integrated_ui_manager);
+ add_plugin_actions (integrated_ui_manager, NULL);
integrated_ui_accels = gtk_ui_manager_get_accel_group (integrated_ui_manager);
- integrated_ui_menubar = gtk_ui_manager_get_widget (integrated_ui_manager, "/IntegratedUIMenu");
+ integrated_ui_menubar = gtk_ui_manager_get_widget (integrated_ui_manager, INTEGRATED_MENU);
integrated_ui_toolbar = create_integrated_ui_toolbar ();
if (menubar)
@@ -1108,9 +1055,8 @@
}
g_free (uifile);
- add_plugin_actions (*ui_manager);
-
- menu_bar = gtk_ui_manager_get_widget (*ui_manager, "/DisplayMenu");
+ add_plugin_actions (*ui_manager, DISPLAY_MENU);
+ menu_bar = gtk_ui_manager_get_widget (*ui_manager, DISPLAY_MENU);
return menu_bar;
}
@@ -1148,6 +1094,17 @@
action = gtk_action_group_get_action (display_tool_actions, name);
}
}
+ if (!action) {
+ GList *groups, *list;
+
+ /* search everthing there is, could probably replace the above */
+ groups = gtk_ui_manager_get_action_groups (display_ui_manager);
+ for (list = groups; list != NULL; list = list->next) {
+ action = gtk_action_group_get_action (GTK_ACTION_GROUP (list->data), name);
+ if (action)
+ break;
+ }
+ }
return action;
}
@@ -1163,12 +1120,12 @@
if (is_integrated_ui ())
{
ui_manager = integrated_ui_manager;
- recent_path = "/IntegratedUIMenu/File/FileRecentEnd";
+ recent_path = INTEGRATED_MENU "/File/FileRecentEnd";
}
else
{
ui_manager = toolbox_ui_manager;
- recent_path = "/ToolboxMenu/File/FileRecentEnd";
+ recent_path = TOOLBOX_MENU "/File/FileRecentEnd";
}
if (recent_actions) {
Modified: trunk/app/menus.h
==============================================================================
--- trunk/app/menus.h (original)
+++ trunk/app/menus.h Sun May 25 18:34:23 2008
@@ -22,7 +22,7 @@
#define TOOLBOX_MENU "/ToolboxMenu"
#define DISPLAY_MENU "/DisplayMenu"
-#define POPUP_MENU "/PopupMenu"
+#define INTEGRATED_MENU "/IntegratedUIMenu"
struct zoom_pair { const gchar *string; const gint value; };
Modified: trunk/app/render_gdk.c
==============================================================================
--- trunk/app/render_gdk.c (original)
+++ trunk/app/render_gdk.c Sun May 25 18:34:23 2008
@@ -103,7 +103,10 @@
if (renderer->pixmap != NULL)
gdk_drawable_unref(renderer->pixmap);
- renderer->pixmap = gdk_pixmap_new(GDK_WINDOW(window), width, height, -1);
+ if (window)
+ renderer->pixmap = gdk_pixmap_new(GDK_WINDOW(window), width, height, -1);
+ else /* the integrated UI insist to call us too early */
+ renderer->pixmap = gdk_pixmap_new(NULL, width, height, 24);
if (renderer->gc == NULL) {
renderer->gc = gdk_gc_new(renderer->pixmap);
Modified: trunk/data/display-ui.xml
==============================================================================
--- trunk/data/display-ui.xml (original)
+++ trunk/data/display-ui.xml Sun May 25 18:34:23 2008
@@ -34,13 +34,10 @@
<menuitem name="EditCuttext" action="EditCuttext" />
<menuitem name="EditPastetext" action="EditPastetext" />
<separator name="EditSep4" />
- <separator name="EditExtensionStart" />
- </menu>
- <menu name="Diagram" action="Diagram">
<menuitem name="DiagramProperties" action="DiagramProperties" />
<menuitem name="DiagramLayers" action="DiagramLayers" />
- <separator name="DiagramSep1" />
- <separator name="DIagramExtensionStart" />
+ <separator name="EditSep5" />
+ <separator name="EditExtensionStart" />
</menu>
<menu name="View" action="View">
<menuitem name="ViewZoomin" action="ViewZoomin" />
Modified: trunk/data/integrated-ui.xml
==============================================================================
--- trunk/data/integrated-ui.xml (original)
+++ trunk/data/integrated-ui.xml Sun May 25 18:34:23 2008
@@ -41,10 +41,13 @@
<menuitem name="EditDuplicate" action="EditDuplicate" />
<menuitem name="EditDelete" action="EditDelete" />
<separator name="EditSep2" />
+ <menuitem name="EditFind" action="EditFind" />
+ <menuitem name="EditReplace" action="EditReplace" />
+ <separator name="EditSep3" />
<menuitem name="EditCopytext" action="EditCopytext" />
<menuitem name="EditCuttext" action="EditCuttext" />
<menuitem name="EditPastetext" action="EditPastetext" />
- <separator name="EditSep3" />
+ <separator name="EditSep4" />
<menuitem name="DiagramProperties" action="DiagramProperties" />
<menuitem name="DiagramLayers" action="DiagramLayers" />
</menu>
Modified: trunk/plug-ins/cairo/diacairo.c
==============================================================================
--- trunk/plug-ins/cairo/diacairo.c (original)
+++ trunk/plug-ins/cairo/diacairo.c Sun May 25 18:34:23 2008
@@ -289,8 +289,13 @@
/* as of this writing the only format Gtk+ supports here is PDF */
g_assert (OUTPUT_PDF == kind);
# endif
-
- gtk_print_operation_set_export_filename (op, filename_utf8);
+
+ if (!data) {
+ message_error (_("Nothing to print"));
+ return;
+ }
+
+ gtk_print_operation_set_export_filename (op, filename_utf8 ? filename_utf8 : "output.pdf");
res = gtk_print_operation_run (op, GTK_PRINT_OPERATION_ACTION_EXPORT, NULL, &error);
if (GTK_PRINT_OPERATION_RESULT_ERROR == res) {
message_error (error->message);
Modified: trunk/plug-ins/postscript/postscript.c
==============================================================================
--- trunk/plug-ins/postscript/postscript.c (original)
+++ trunk/plug-ins/postscript/postscript.c Sun May 25 18:34:23 2008
@@ -35,7 +35,10 @@
guint flags, /* further additions */
void *user_data)
{
- diagram_print_ps (data, filename);
+ if (!data)
+ message_error (_("Nothing to print"));
+ else
+ diagram_print_ps (data, filename ? filename : "output.ps");
}
static DiaCallbackFilter cb_ps_print = {
Modified: trunk/plug-ins/wmf/wmf.cpp
==============================================================================
--- trunk/plug-ins/wmf/wmf.cpp (original)
+++ trunk/plug-ins/wmf/wmf.cpp Sun May 25 18:34:23 2008
@@ -1385,7 +1385,10 @@
guint flags,
void *user_data)
{
- diagram_print_gdi (data, filename);
+ if (!data)
+ message_error (_("Nothing to print"));
+ else
+ diagram_print_gdi (data, filename);
}
static DiaCallbackFilter cb_gdi_print = {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]