[PATCH:anjuta2] Fail nicely when no bonobo mime handlers available



Attached is a patch to provide decent error messages in anjuta2's
document-manager when there are no Bonobo controls available to handle a
particular mime-type (like what I had today).

There is a useful error message upon startup if anjuta2 is deficient (no
text/plain handler). Also, if the user opens a document with no
mime-type view available, then user does not get an empty notebook pane
but instead a helpful error message.

Mark
? document-manager-2_01.patch
Index: anjuta-document.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/document-manager/anjuta-document.c,v
retrieving revision 1.41
diff -u -r1.41 anjuta-document.c
--- anjuta-document.c	2002/01/26 17:06:48	1.41
+++ anjuta-document.c	2002/02/02 04:53:20
@@ -244,7 +244,15 @@
 	if (document->priv->available_components) {
 		activate_component (document, 
 				    choose_default_component (document));
-	}	
+	} else {
+	  /* No Bonobo Control to view document, tell user */
+	  char* error_msg = g_strdup_printf ("Document-Manager\nFailed to make temp file - consider installing glimmer from CVS\nNo available bonobo objects to open this file.\nMime Type: %s", mime_type);
+
+	  anjuta_error_dialog (error_msg);
+
+	  g_free (error_msg);
+
+	}
 }
 
 void
@@ -456,6 +464,17 @@
 		activate_component (document, 
 				    choose_default_component (document));
 		load_uri_into_control (document);
+	} else {
+	  /* No Bonobo Control to view document, tell user */
+	  char* error_msg = g_strdup_printf ("Document-Manager\nNo available bonobo objects to open this file.\nMime Type: %s", mime_type);
+
+	  anjuta_error_dialog (error_msg);
+
+	  g_free (error_msg);
+
+	  document->file_loaded = FALSE;
+
+	  return FALSE;
 	}
 
 	document->file_loaded = TRUE;
@@ -1074,12 +1093,17 @@
 
 	document->priv->available_components = 
 		get_available_components (document->mime_type);
-	document->priv->available_apps = 
-		get_available_apps (document->mime_type);
-	menu = build_component_menu (document);
-	gtk_widget_show_all (menu);
-	gtk_option_menu_set_menu (GTK_OPTION_MENU (document->priv->viewer_option),
-				  menu);
+
+	if( document->priv->available_components ) {
+	  /* We have a bonobo control for the request mime_type */
+	  
+	  document->priv->available_apps = 
+	    get_available_apps (document->mime_type);
+	  menu = build_component_menu (document);
+	  gtk_widget_show_all (menu);
+	  gtk_option_menu_set_menu (GTK_OPTION_MENU (document->priv->viewer_option),
+				    menu);
+	}
 }
 
 static void
Index: file-ops.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/document-manager/file-ops.c,v
retrieving revision 1.31
diff -u -r1.31 file-ops.c
--- file-ops.c	2002/01/26 17:06:49	1.31
+++ file-ops.c	2002/02/02 04:53:20
@@ -96,7 +96,9 @@
     	if ( !document || !anjuta_document_is_free(document) ) {
 		document = ANJUTA_DOCUMENT( anjuta_document_new(docman->ui_container) );
 		anjuta_document_load_uri( document, filename);
-		anjuta_document_manager_add_doc( docman, document );
+		if( document->file_loaded == TRUE ) {
+		  anjuta_document_manager_add_doc( docman, document );
+		}
     	} else {
 		anjuta_document_load_uri(document, filename);
 	}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]