Re: [Nautilus-list] [PATCH] creating launchers with Nautilus
- From: Gaute Lindkvist <lindkvis stud ntnu no>
- To: Darin Adler <darin bentspoon com>
- Cc: Nautilus <nautilus-list lists eazel com>
- Subject: Re: [Nautilus-list] [PATCH] creating launchers with Nautilus
- Date: Wed, 6 Mar 2002 18:22:07 +0100 (CET)
> This patch needs a lot of work.
Ok.. I've fixed all of the concerns you listed. First of all, thanks for
taking the time to check out my patch even though I'm obviously not an
experienced C-coder. Even I can turn out useful in the end :-)
I'm a bit embarrased at the includes though, as I forgot completely to
check up on them. Even a lowly Javaprogrammer is pretty familiar with that
concept.
I've managed to get the string changes down to just a few, by reusing
sentences that work fine. I will still
need to get them approved, but there is no point in this if patch is
conceptually broken.
> And I think that this is probably not the right way to go -- please talk to
> George Lebl about this before pursuing it further.
>
I do not know George Lebl, but sent an e-mail to the address found by a
grep through the gnomevfs-includes a few days ago. He hasn't answered, but
when he does, I'll ask him about this issue as well.
Gaute
? src/file-manager/nautilus-launcher-dialog.c
? src/file-manager/nautilus-launcher-dialog.h
Index: po/POTFILES.in
===================================================================
RCS file: /cvs/gnome/nautilus/po/POTFILES.in,v
retrieving revision 1.106
diff -u -r1.106 POTFILES.in
--- po/POTFILES.in 2002/02/28 01:42:38 1.106
+++ po/POTFILES.in 2002/03/06 17:17:56
@@ -85,6 +85,7 @@
src/file-manager/nautilus-icon-view-ui.xml
src/file-manager/nautilus-indexing-info.c
src/file-manager/nautilus-search-list-view-ui.xml
+src/file-manager/nautilus-launcher-dialog.c
src/nautilus-application.c
src/nautilus-bookmarks-window.c
src/nautilus-complex-search-bar.c
Index: src/file-manager/Makefile.am
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/Makefile.am,v
retrieving revision 1.67
diff -u -r1.67 Makefile.am
--- src/file-manager/Makefile.am 2002/02/14 23:21:59 1.67
+++ src/file-manager/Makefile.am 2002/03/06 17:17:57
@@ -26,6 +26,7 @@
fm-properties-window.c \
fm-search-list-view.c \
nautilus-indexing-info.c \
+ nautilus-launcher-dialog.c \
fm-desktop-icon-view.h \
fm-directory-view.h \
fm-error-reporting.h \
@@ -36,6 +37,7 @@
fm-properties-window.h \
fm-search-list-view.h \
nautilus-indexing-info.h \
+ nautilus-launcher-dialog.h \
$(NULL)
uidir = $(datadir)/gnome-2.0/ui
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.511
diff -u -r1.511 fm-directory-view.c
--- src/file-manager/fm-directory-view.c 2002/03/02 00:30:55 1.511
+++ src/file-manager/fm-directory-view.c 2002/03/06 17:18:10
@@ -33,6 +33,7 @@
#include "fm-desktop-icon-view.h"
#include "fm-error-reporting.h"
#include "fm-properties-window.h"
+#include "nautilus-launcher-dialog.h"
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-window.h>
#include <bonobo/bonobo-zoomable.h>
@@ -107,6 +108,7 @@
#define FM_DIRECTORY_VIEW_COMMAND_OPEN_ALTERNATE "/commands/OpenAlternate"
#define FM_DIRECTORY_VIEW_COMMAND_OPEN_WITH "/commands/Open With"
#define FM_DIRECTORY_VIEW_COMMAND_NEW_FOLDER "/commands/New Folder"
+#define FM_DIRECTORY_VIEW_COMMAND_NEW_LAUNCHER "/commands/New Launcher"
#define FM_DIRECTORY_VIEW_COMMAND_DELETE "/commands/Delete"
#define FM_DIRECTORY_VIEW_COMMAND_SHOW_TRASH "/commands/Show Trash"
#define FM_DIRECTORY_VIEW_COMMAND_TRASH "/commands/Trash"
@@ -929,6 +931,18 @@
}
static void
+new_launcher_callback (BonoboUIComponent *component, gpointer callback_data, const char *verb)
+{
+ char *path;
+
+ g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
+ path = nautilus_directory_get_uri(FM_DIRECTORY_VIEW (callback_data)->details->model);
+ nautilus_present_launcher_dialog (path, fm_directory_view_get_containing_window (FM_DIRECTORY_VIEW (callback_data)), NULL);
+ g_free (path);
+
+}
+
+static void
open_properties_window_callback (BonoboUIComponent *component, gpointer callback_data, const char *verb)
{
FMDirectoryView *view;
@@ -4106,6 +4120,7 @@
BONOBO_UI_VERB ("Duplicate", duplicate_callback),
BONOBO_UI_VERB ("Empty Trash", bonobo_menu_empty_trash_callback),
BONOBO_UI_VERB ("New Folder", new_folder_callback),
+ BONOBO_UI_VERB ("New Launcher", new_launcher_callback),
BONOBO_UI_VERB ("Open Scripts Folder", open_scripts_folder_callback),
BONOBO_UI_VERB ("Open", open_callback),
BONOBO_UI_VERB ("OpenAlternate", open_alternate_callback),
@@ -4186,6 +4201,9 @@
nautilus_bonobo_set_sensitive (view->details->ui,
FM_DIRECTORY_VIEW_COMMAND_NEW_FOLDER,
+ can_create_files);
+ nautilus_bonobo_set_sensitive (view->details->ui,
+ FM_DIRECTORY_VIEW_COMMAND_NEW_LAUNCHER,
can_create_files);
nautilus_bonobo_set_sensitive (view->details->ui,
Index: src/file-manager/nautilus-directory-view-ui.xml
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/nautilus-directory-view-ui.xml,v
retrieving revision 1.33
diff -u -r1.33 nautilus-directory-view-ui.xml
--- src/file-manager/nautilus-directory-view-ui.xml 2002/03/01 18:12:30 1.33
+++ src/file-manager/nautilus-directory-view-ui.xml 2002/03/06 17:18:11
@@ -15,6 +15,9 @@
<cmd name="New Folder"
_label="New Folder"
_tip="Create a new empty folder inside this folder"/>
+ <cmd name="New Launcher"
+ _label="New Launcher"
+ _tip="Create a new launcher inside this folder"/>
<cmd name="Open"
_label="Open"
_tip="Open the selected item in this window"/>
@@ -76,6 +79,10 @@
_label="_New Folder"
accel="*Control*n"
verb="New Folder"/>
+ <menuitem name="New Launcher"
+ _label="_New Launcher"
+ verb="New Launcher"/>
+
</placeholder>
<placeholder name="Open Placeholder">
<menuitem name="Open"
@@ -183,6 +190,7 @@
<placeholder name="Before Zoom Items">
<placeholder name="New Items">
<menuitem name="New Folder" verb="New Folder"/>
+ <menuitem name="New Launcher" verb="New Launcher"/>
</placeholder>
<submenu name="Scripts"
_label="Scripts"
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* fm-directory-view.h
*
* Copyright (C) 2002 Free Software Foundaton
*
* 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.
*
* Authors: Gaute Lindkvist <lindkvis linpro no>
*/
#include <gtk/gtkwindow.h>
G_BEGIN_DECLS
void
nautilus_present_launcher_dialog (
char * path,
GtkWindow * parent,
char * old_launcher );
G_END_DECLS
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus_launcher_dialog.c
*
* Copyright (C) 2002 Free Software Foundation
*
* 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.
*
* Authors: Gaute Lindkvist <lindkvis linpro no>
*/
#include <config.h>
#include "nautilus-launcher-dialog.h"
#include <string.h>
#include <libgnome/gnome-help.h>
#include <libgnome/gnome-desktop-item.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libgnomeui/gnome-ditem-edit.h>
#include <libgnomeui/gnome-uidefs.h>
#include <libgnome/gnome-i18n.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
#include "fm-directory-view.h"
static char * current_path = NULL;
/* Tries to save the desktop file. Returns TRUE if ok, FALSE if not.
* It will overwrite existing desktop files if the same name is given.
*/
static gboolean
launcher_save_to_file (GtkWidget *dialog, gpointer data)
{
GError * error;
gboolean return_value;
GnomeDesktopItem *item;
char * filename;
char * location;
GtkDialog *error_dialog;
GnomeDItemEdit *dedit;
dedit = GNOME_DITEM_EDIT (data);
error = NULL;
item = gnome_ditem_edit_get_ditem (dedit);
filename = gnome_ditem_edit_get_name (dedit);
/* If we have no file name, we'll use a default */
if (strlen(filename) < 1) {
filename = _("No name");
gnome_desktop_item_set_string (item, GNOME_DESKTOP_ITEM_NAME, filename);
}
location = nautilus_make_path (current_path, filename);
g_free (current_path);
current_path = NULL;
/* Do the actual saving */
return_value = gnome_desktop_item_save (item, location, TRUE, &error);
if (!return_value) {
error_dialog = eel_show_error_dialog (error->message, g_strdup_printf(_("Error while creating link in \"%s\""), location), GTK_WINDOW (dialog));
g_error_free (error);
g_free (location);
g_free (filename);
return FALSE;
}
else {
/* Commented out because it should perhaps not be here, */
/* or perhaps activated if fam is not present: */
/* nautilus_directory_force_reload (nautilus_directory_get (location)); */
g_error_free (error);
g_free (location);
g_free (filename);
gtk_widget_destroy (GTK_WIDGET (dialog));
return TRUE;
}
}
static void
callback_handler (GtkWidget *dialog, int response, gpointer data)
{
GError * error = NULL;
switch (response) {
case GTK_RESPONSE_OK:
launcher_save_to_file (dialog, data);
break;
case GTK_RESPONSE_CANCEL:
gtk_widget_destroy (dialog);
break;
case GTK_RESPONSE_HELP:
//eel_show_error_dialog ("No help available yet", _("No help"), GTK_WINDOW (dialog));
gnome_help_display_desktop (NULL, "nautilus", "launchers", NULL, &error);
if (error != NULL) {
g_warning ("help error: %s\n", error->message);
g_error_free (error);
}
break;
}
}
void
nautilus_present_launcher_dialog ( char * path, GtkWindow * parent, char * old_launcher)
{
GtkWidget *dialog;
GnomeDItemEdit *dee;
GnomeDesktopItem *ditem = NULL;
GError * error = NULL;
current_path = g_malloc(strlen(path) + 1);
current_path = g_strdup(path);
dialog = gtk_dialog_new_with_buttons (_("Create launcher"),
parent /* parent */,
0 /* flags */,
GTK_STOCK_HELP,
GTK_RESPONSE_HELP,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_OK,
GTK_RESPONSE_OK,
NULL);
dee = GNOME_DITEM_EDIT (gnome_ditem_edit_new ());
if (old_launcher != NULL) {
ditem = gnome_desktop_item_new_from_uri (gnome_vfs_get_local_path_from_uri (old_launcher), GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS, &error);
if (ditem == NULL) {
eel_show_error_dialog (error->message, g_strdup_printf(_("Sorry, but there was an error reading %s"), old_launcher), GTK_WINDOW (parent));
g_error_free (error);
}
}
else {
ditem = gnome_desktop_item_new ();
}
gnome_ditem_edit_set_editable (dee, TRUE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
GTK_WIDGET (dee),
TRUE, TRUE, GNOME_PAD_SMALL);
gnome_desktop_item_set_entry_type (ditem, GNOME_DESKTOP_ITEM_TYPE_APPLICATION);
gnome_ditem_edit_set_ditem (dee, ditem);
gnome_desktop_item_unref (ditem);
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (callback_handler),
dee);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_widget_show_all (dialog);
gnome_ditem_edit_grab_focus (dee);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]