Re: [PATCH] Scaffold -- Added tooltips and file modified flag into document-manager
- From: Jeroen Zwartepoorte <jeroen xs4all nl>
- To: Rui Lopes <rui ruilopes com>
- Cc: gnome-devtools gnome org
- Subject: Re: [PATCH] Scaffold -- Added tooltips and file modified flag into document-manager
- Date: 07 Sep 2003 12:57:43 +0200
I just committed a modified version of your patch (merged the
document_(un)modified methods calls with docman_doc_(un)modified:
2003-09-07 Rui Lopes <rui ruilopes com>
* plugins/document-manager/scaffold-document-manager.c: Added tooltips
to document-manager tabs that show the full filename. Added a simple
modified flag ('*') to document-manager tab when a file is modified.
See attached patch.
Thanks,
Jeroen
On Thu, 2003-09-04 at 13:31, Rui Lopes wrote:
> Hi all,
>
>
> On Qua, 2003-09-03 at 16:59, Rui Lopes wrote:
> > Some more things for Scaffold:
> >
> > * Added tooltips to document-manager tabs that show the full filename.
> > * Added a simple modified flag ('*') to document-manager tab when a file
> > is modified.
> >
> >
> > Review my TODO and XXX comments and tell me what you think!
>
>
> Use the attached patch instead. It adds two lines that I forgot, and
> also adds a ChangeLog entry.
>
>
>
> Regards,
> Rui Lopes
? docman.patch
? plugins/project-manager/project-tool.loT
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/scaffold/ChangeLog,v
retrieving revision 1.274
diff -u -p -r1.274 ChangeLog
--- ChangeLog 7 Sep 2003 10:16:25 -0000 1.274
+++ ChangeLog 7 Sep 2003 10:49:26 -0000
@@ -1,5 +1,19 @@
2003-09-07 Rui Lopes <rui ruilopes com>
+ * plugins/document-manager/scaffold-document-manager.c:
+ (scaffold_notebook_document_manager_new), (set_doc_uri),
+ (scaffold_notebook_document_manager_remove_doc), (add_doc),
+ (docman_dispose),
+ (scaffold_notebook_document_manager_instance_init),
+ (document_modified), (document_unmodified),
+ (scaffold_notebook_document_manager_get_prefs_page),
+ (scaffold_notebook_document_manager_open): Added tooltips to
+ document-manager tabs that show the full filename. Added a
+ simple modified flag ('*') to document-manager tab when a
+ file is modified.
+
+2003-09-07 Rui Lopes <rui ruilopes com>
+
* data/Makefile.am: s/install-data-local/install-schemas. Fixes some
gconf installation problems.
* plugins/gnome-project-types/scaffold-gnome-application-type.c:
Index: plugins/document-manager/scaffold-document-manager.c
===================================================================
RCS file: /cvs/gnome/scaffold/plugins/document-manager/scaffold-document-manager.c,v
retrieving revision 1.32
diff -u -p -r1.32 scaffold-document-manager.c
--- plugins/document-manager/scaffold-document-manager.c 8 Aug 2003 20:44:19 -0000 1.32
+++ plugins/document-manager/scaffold-document-manager.c 7 Sep 2003 10:49:28 -0000
@@ -61,6 +61,8 @@ struct _ScaffoldNotebookDocumentManagerP
GHashTable *verbs;
GConfClient *client;
+
+ GtkTooltips *tooltips;
};
typedef struct {
@@ -101,7 +103,7 @@ scaffold_notebook_document_manager_new (
ScaffoldNotebookDocumentManager *dm;
dm = g_object_new (SCAFFOLD_TYPE_NOTEBOOK_DOCUMENT_MANAGER, NULL);
-
+
dm->ui_container = ui_container;
dm->ui_component = ui_component;
@@ -141,6 +143,7 @@ set_doc_uri (ScaffoldNotebookDocumentMan
{
gchar *basename;
GdkPixbuf *pixbuf;
+ GtkWidget *tooltip;
GtkWidget *label;
GtkWidget *icon;
@@ -154,6 +157,10 @@ set_doc_uri (ScaffoldNotebookDocumentMan
gtk_label_set_text (GTK_LABEL (label), basename);
g_free (basename);
+ tooltip = g_object_get_data (G_OBJECT (document),
+ "ScaffoldNotebookDocumentManager::tooltip");
+ gtk_tooltips_set_tip (docman->priv->tooltips, tooltip, filename, NULL);
+
pixbuf = gdl_icons_get_uri_icon (docman->priv->icons, filename);
icon = g_object_get_data (G_OBJECT (document),
"ScaffoldNotebookDocumentManager::icon");
@@ -179,9 +186,9 @@ scaffold_notebook_document_manager_remov
g_signal_emit_by_name (docman, "document_removed", document);
- docman->documents =
- g_list_remove (docman->documents, document);
+ docman->documents = g_list_remove (docman->documents, document);
}
+
g_object_unref (document);
}
@@ -263,12 +270,12 @@ close_document_cb (GtkButton *button,
"text/plain",
NULL);
}
-
}
static void
add_doc (ScaffoldNotebookDocumentManager *docman, ScaffoldDocument *document)
{
+ GtkWidget *event_box;
GtkWidget *tab_hbox;
GtkWidget *label;
GtkWidget *button;
@@ -289,7 +296,8 @@ add_doc (ScaffoldNotebookDocumentManager
if (uri) {
label_str = g_path_get_basename (uri);
} else {
- label_str = g_strdup_printf ("Untitled %ld", ++docman->priv->untitled_count);
+ label_str = g_strdup_printf (_("Untitled %ld"),
+ ++docman->priv->untitled_count);
SCAFFOLD_BONOBO_DOCUMENT (document)->untitled = TRUE;
}
@@ -310,15 +318,22 @@ add_doc (ScaffoldNotebookDocumentManager
label = gtk_label_new (label_str);
g_object_set_data (G_OBJECT (document),
- "ScaffoldNotebookDocumentManager::label",
- label);
+ "ScaffoldNotebookDocumentManager::label", label);
g_object_set_data (G_OBJECT (document),
- "ScaffoldNotebookDocumentManager::icon",
- icon);
+ "ScaffoldNotebookDocumentManager::icon", icon);
g_free (label_str);
- /* Build the tab widget close button */
+ /* Build the tab widgets and tooltip */
+ event_box = gtk_event_box_new ();
+ g_object_set_data (G_OBJECT (document),
+ "ScaffoldNotebookDocumentManager::tooltip",
+ event_box);
+
+ if (uri)
+ gtk_tooltips_set_tip (docman->priv->tooltips, event_box,
+ uri, NULL);
+
tab_hbox = gtk_hbox_new (FALSE, 2);
pixmap = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);;
button = gtk_button_new ();
@@ -326,8 +341,7 @@ add_doc (ScaffoldNotebookDocumentManager
gtk_container_add (GTK_CONTAINER (button), pixmap);
gtk_widget_set_size_request (button, 18, 18);
- g_object_set_data (G_OBJECT (button), "document",
- (gpointer) document);
+ g_object_set_data (G_OBJECT (button), "document", document);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (close_document_cb), docman);
@@ -335,29 +349,23 @@ add_doc (ScaffoldNotebookDocumentManager
gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (tab_hbox), button, FALSE, FALSE, 0);
- gtk_widget_show_all (tab_hbox);
+ gtk_container_add (GTK_CONTAINER (event_box), tab_hbox);
+ gtk_widget_show_all (event_box);
gtk_notebook_append_page (GTK_NOTEBOOK (docman),
- GTK_WIDGET (document), tab_hbox);
+ GTK_WIDGET (document), event_box);
- /* Listen for changes */
- g_signal_connect (document, "modified",
- G_CALLBACK (docman_doc_modified),
- docman);
- g_signal_connect (document, "unmodified",
- G_CALLBACK (docman_doc_unmodified),
- docman);
- g_signal_connect (document, "uri_changed",
- G_CALLBACK (docman_doc_uri_changed),
- docman);
-
-
- g_signal_connect (G_OBJECT(document), "destroy",
- G_CALLBACK (docman_doc_destroy),
- (gpointer) docman);
+ g_signal_connect (G_OBJECT (document), "modified",
+ G_CALLBACK (docman_doc_modified), docman);
+ g_signal_connect (G_OBJECT (document), "unmodified",
+ G_CALLBACK (docman_doc_unmodified), docman);
+ g_signal_connect (G_OBJECT (document), "uri_changed",
+ G_CALLBACK (docman_doc_uri_changed), docman);
+ g_signal_connect (G_OBJECT (document), "destroy",
+ G_CALLBACK (docman_doc_destroy), docman);
gtk_widget_show (GTK_WIDGET (document));
- gtk_widget_grab_focus (GTK_WIDGET(document));
+ gtk_widget_grab_focus (GTK_WIDGET (document));
/* Add the document to the recent files list. */
if (!scaffold_bonobo_document_is_untitled (SCAFFOLD_BONOBO_DOCUMENT (document)))
@@ -368,9 +376,8 @@ add_doc (ScaffoldNotebookDocumentManager
(SCAFFOLD_DOCUMENT_MANAGER (docman), document);
/* Well, it won't always set off the signal. Not the first time. */
- if (!docman->current_document) {
+ if (!docman->current_document)
set_current_document (docman, document);
- }
g_signal_emit_by_name (docman, "document_added", document);
}
@@ -410,6 +417,11 @@ docman_dispose (GObject *object)
g_list_free (docman->documents);
docman->documents = NULL;
}
+
+ if (docman->priv->tooltips) {
+ g_object_unref (docman->priv->tooltips);
+ docman->priv->tooltips = NULL;
+ }
}
static void
@@ -552,11 +564,17 @@ scaffold_notebook_document_manager_insta
"activate",
G_CALLBACK (docman_recent_files),
dm);
+
+ dm->priv->tooltips = gtk_tooltips_new ();
+ g_object_ref (G_OBJECT (dm->priv->tooltips));
+ gtk_object_sink (GTK_OBJECT (dm->priv->tooltips));
}
static void
-docman_switch_notebookpage(GtkWidget* widget, GtkNotebookPage* page,
- gint page_num, gpointer data)
+docman_switch_notebookpage (GtkWidget *widget,
+ GtkNotebookPage *page,
+ gint page_num,
+ gpointer data)
{
ScaffoldDocument *document;
ScaffoldNotebookDocumentManager *docman;
@@ -571,7 +589,7 @@ docman_switch_notebookpage(GtkWidget* wi
(SCAFFOLD_DOCUMENT_MANAGER (docman), page_num);
if (!document) {
- g_warning ("Couldn't find document\n");
+ g_warning ("Couldn't find document");
return;
}
@@ -594,44 +612,77 @@ docman_recent_files (GdlRecent *recent,
docman = SCAFFOLD_NOTEBOOK_DOCUMENT_MANAGER (data);
scaffold_document_manager_open (SCAFFOLD_DOCUMENT_MANAGER (docman),
- uri,
- NULL);
+ uri, NULL);
}
static void
docman_doc_modified (GtkWidget *widget, gpointer data)
{
ScaffoldNotebookDocumentManager *docman;
+ ScaffoldDocument *document;
+ GtkWidget *label;
+ const gchar *filename;
+ gchar *new_name;
g_return_if_fail (data != NULL);
g_return_if_fail (SCAFFOLD_IS_DOCUMENT_MANAGER (data));
docman = SCAFFOLD_NOTEBOOK_DOCUMENT_MANAGER (data);
+ document = docman->current_document;
+ /* Update commands. */
bonobo_ui_component_set_prop (docman->ui_component,
"/commands/FileSave",
"sensitive", "1", NULL);
bonobo_ui_component_set_prop (docman->ui_component,
"/commands/FileRevert",
"sensitive", "1", NULL);
+
+ /* Update label. */
+ label = g_object_get_data (G_OBJECT (document),
+ "ScaffoldNotebookDocumentManager::label");
+ filename = gtk_label_get_label (GTK_LABEL (label));
+
+ new_name = g_strdup_printf ("%s*", filename);
+ gtk_label_set_label (GTK_LABEL (label), new_name);
+ g_free (new_name);
}
static void
docman_doc_unmodified (GtkWidget *widget, gpointer data)
{
ScaffoldNotebookDocumentManager *docman;
+ ScaffoldDocument *document;
+ GtkWidget *label;
+ const gchar *filename;
+ gchar *new_name;
+ int length;
g_return_if_fail (data != NULL);
g_return_if_fail (SCAFFOLD_IS_DOCUMENT_MANAGER (data));
docman = SCAFFOLD_NOTEBOOK_DOCUMENT_MANAGER (data);
+ document = docman->current_document;
+ /* Update commands. */
bonobo_ui_component_set_prop (docman->ui_component,
"/commands/FileSave",
"sensitive", "0", NULL);
bonobo_ui_component_set_prop (docman->ui_component,
"/commands/FileRevert",
"sensitive", "0", NULL);
+
+ /* Update label. */
+ label = g_object_get_data (G_OBJECT (document),
+ "ScaffoldNotebookDocumentManager::label");
+ filename = gtk_label_get_label (GTK_LABEL (label));
+
+ length = strlen (filename);
+ if (length > 1 && filename[length - 1] == '*') {
+ new_name = g_strndup (filename, length - 1);
+ gtk_label_set_label (GTK_LABEL (label), new_name);
+ g_free (new_name);
+ }
}
static void
@@ -1003,7 +1054,7 @@ scaffold_notebook_document_manager_open
if (!gnome_vfs_uri_exists (uri)) {
char *msg;
msg = g_strdup_printf (_("Could not find file '%s'"), string_uri);
- g_warning (msg);
+ g_warning ("Could not find file '%s'", string_uri);
scaffold_dialog_error (msg);
g_free (msg);
gnome_vfs_uri_unref (uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]