mirror of https://github.com/MidnightCommander/mc
COOL CODE! OH MAN! I AM GOOD!
Ok, so this time I got the stuff to auto-load desktop startup links. This means you can ship stuff to pre-configure the desktop of the users now. We support program-based setup and url-links. Details on the lib/README.desktop file
This commit is contained in:
parent
6263497852
commit
9207af342d
|
@ -20,6 +20,7 @@ bindir = @bindir@
|
|||
sysconfdir = @sysconfdir@
|
||||
corbadir = $(sysconfdir)/CORBA/servers
|
||||
libdir = $(exec_prefix)/lib/mc
|
||||
desktopdir = $(libdir)/desktop-scripts
|
||||
idldir = $(prefix)/share/idl
|
||||
suppbindir = $(libdir)/bin
|
||||
gnewdir = $(prefix)/share/mc/templates
|
||||
|
@ -60,7 +61,7 @@ AWK_VAR_OPTION = @AWK_VAR_OPTION@
|
|||
# No way, to make make happy (except GNU), we cannot use := to append
|
||||
# something to these, so that's why there is a leading _
|
||||
XCFLAGS = @CFLAGS@
|
||||
XCPPFLAGS = @CPPFLAGS@ @MCCPPFLAGS@ -I.. -DBINDIR=\""$(bindir)/"\" -DLIBDIR=\""$(libdir)/"\" -DICONDIR=\""$(icondir)/"\" $(XINC) -DLOCALEDIR=\""$(localedir)/"\" -DCONFDIR=\""$(confdir)/"\"
|
||||
XCPPFLAGS = @CPPFLAGS@ @MCCPPFLAGS@ -I.. -DBINDIR=\""$(bindir)/"\" -DLIBDIR=\""$(libdir)/"\" -DICONDIR=\""$(icondir)/"\" $(XINC) -DLOCALEDIR=\""$(localedir)/"\" -DCONFDIR=\""$(confdir)/"\" -DDESKTOP_INIT_DIR=\""$(desktopdir)/"\"
|
||||
XLDFLAGS = @LDFLAGS@
|
||||
XDEFS = @DEFS@
|
||||
XLIBS = @LIBS@
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
1999-03-20 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* gdesktop-init.c (desktop_load_init_from): New file that loads
|
||||
new configuration files from the installation directory.
|
||||
|
||||
* gdesktop.c: Drop all the reload code from there, put it above.
|
||||
|
||||
* gpopup2.c (create_mime_actions): Attach to the menu, not the uiinfo.
|
||||
|
||||
1999-03-19 Jonathan Blandford <jrb@redhat.com>
|
||||
|
|
|
@ -35,6 +35,7 @@ GNOMESRCS = \
|
|||
gcmd.c \
|
||||
gcorba.c \
|
||||
gdesktop-icon.c \
|
||||
gdesktop-init.c \
|
||||
gdesktop.c \
|
||||
gdialogs.c \
|
||||
gdnd.c \
|
||||
|
@ -141,6 +142,7 @@ OBJS = \
|
|||
gcmd.o \
|
||||
gcustom-layout.o\
|
||||
gdesktop-icon.o \
|
||||
gdesktop-init.o \
|
||||
gdesktop.o \
|
||||
gdnd.o \
|
||||
ghelp.o \
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (C) 1998-1999 The Free Software Foundation
|
||||
*
|
||||
* Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <unistd.h>
|
||||
#include "main.h"
|
||||
#include "util.h"
|
||||
#include <libgnome/libgnome.h>
|
||||
#include "gdesktop.h"
|
||||
#include "gdesktop-init.h"
|
||||
#include "gprint.h"
|
||||
#include "gmount.h"
|
||||
|
||||
static void
|
||||
desktop_load_init_from (const char *file)
|
||||
{
|
||||
void *iterator_handle;
|
||||
char *config_path = g_strconcat ("=", file, "=", NULL);
|
||||
|
||||
iterator_handle = gnome_config_init_iterator_sections (config_path);
|
||||
|
||||
do {
|
||||
char *key;
|
||||
char *file_and_section;
|
||||
char *title, *type;
|
||||
|
||||
/* Get next section name */
|
||||
iterator_handle = gnome_config_iterator_next (
|
||||
iterator_handle, &key, NULL);
|
||||
|
||||
/* Now access the values in the section */
|
||||
file_and_section = g_strconcat (config_path, "/", key, "/", NULL);
|
||||
gnome_config_push_prefix (file_and_section);
|
||||
title = gnome_config_get_translated_string ("title=None");
|
||||
type = gnome_config_get_string ("type=url");
|
||||
|
||||
/*
|
||||
* handle the different link types
|
||||
*/
|
||||
if (strcmp (type, "url") == 0){
|
||||
int used;
|
||||
char *icon = NULL, *url;
|
||||
|
||||
url = gnome_config_get_string ("url");
|
||||
icon = gnome_config_get_string_with_default ("icon=", &used);
|
||||
if (!icon)
|
||||
icon = g_concat_dir_and_file (ICONDIR, "gnome-http-url.png");
|
||||
|
||||
if (url && *url){
|
||||
char *filename = g_concat_dir_and_file (desktop_directory, key);
|
||||
|
||||
desktop_create_url (filename, title, url, icon);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
if (url)
|
||||
g_free (url);
|
||||
g_free (icon);
|
||||
}
|
||||
g_free (title);
|
||||
g_free (file_and_section);
|
||||
gnome_config_pop_prefix ();
|
||||
} while (iterator_handle);
|
||||
|
||||
g_free (config_path);
|
||||
}
|
||||
|
||||
static void
|
||||
desktop_init_at (const char *dir)
|
||||
{
|
||||
DIR *d;
|
||||
struct dirent *dent;
|
||||
const int links_extlen = sizeof (".links")-1;
|
||||
struct stat s;
|
||||
|
||||
d = opendir (dir);
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
while ((dent = readdir (d)) != NULL){
|
||||
int len = strlen (dent->d_name);
|
||||
char *fname;
|
||||
|
||||
fname = g_concat_dir_and_file (dir, dent->d_name);
|
||||
|
||||
/*
|
||||
* If it is an executable
|
||||
*/
|
||||
if (access (fname, X_OK) == 0){
|
||||
char *desktop_quoted;
|
||||
char *command;
|
||||
|
||||
desktop_quoted = name_quote (desktop_directory, 0);
|
||||
command = g_strconcat (fname, " --desktop-dir", desktop_quoted, NULL);
|
||||
g_free (desktop_quoted);
|
||||
|
||||
my_system (EXECUTE_WAIT | EXECUTE_AS_SHELL, shell, command);
|
||||
g_free (command);
|
||||
g_free (fname);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (len < links_extlen){
|
||||
g_free (fname);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp (dent->d_name + len - links_extlen, ".links")){
|
||||
g_free (fname);
|
||||
continue;
|
||||
}
|
||||
|
||||
desktop_load_init_from (fname);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gdesktop_init (void)
|
||||
{
|
||||
char *dir;
|
||||
|
||||
desktop_init_at (DESKTOP_INIT_DIR);
|
||||
|
||||
dir = gnome_util_home_file ("desktop-init");
|
||||
desktop_init_at (dir);
|
||||
g_free (dir);
|
||||
|
||||
gmount_setup_devices ();
|
||||
gprint_setup_devices ();
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef GDESKTOP_INIT_H
|
||||
#define GDESKTOP_INIT_H
|
||||
|
||||
void gdesktop_init (void);
|
||||
|
||||
#endif
|
|
@ -25,13 +25,11 @@
|
|||
#include "gmetadata.h"
|
||||
#include "gcmd.h"
|
||||
#include "gdnd.h"
|
||||
#include "gmount.h"
|
||||
#include "gpopup.h"
|
||||
#include "gprint.h"
|
||||
#include "gscreen.h"
|
||||
#include "../vfs/vfs.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "gmount.h"
|
||||
|
||||
|
||||
struct layout_slot {
|
||||
|
@ -2042,7 +2040,8 @@ create_layout_info (void)
|
|||
layout_slots = g_new0 (struct layout_slot, layout_cols * layout_rows);
|
||||
}
|
||||
|
||||
/* Check that the user's desktop directory exists, and if not, create the
|
||||
/*
|
||||
* Check that the user's desktop directory exists, and if not, create the
|
||||
* default desktop setup.
|
||||
*/
|
||||
static void
|
||||
|
@ -2072,7 +2071,7 @@ create_desktop_dir (void)
|
|||
}
|
||||
g_free (home_link_name);
|
||||
|
||||
gmount_setup_devices ();
|
||||
gdesktop_init ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2376,8 +2375,9 @@ void
|
|||
desktop_rescan_devices (void)
|
||||
{
|
||||
desktop_cleanup_devices ();
|
||||
gmount_setup_devices ();
|
||||
gprint_setup_devices ();
|
||||
|
||||
gdesktop_init ();
|
||||
|
||||
desktop_reload_icons (FALSE, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -2409,7 +2409,7 @@ GnomeUIInfo desktop_popup_items[] = {
|
|||
GNOMEUIINFO_ITEM_NONE (N_("Arrange Icons"), NULL, handle_arrange_icons),
|
||||
GNOMEUIINFO_ITEM_NONE (N_("Create New Window"), NULL, handle_new_window),
|
||||
GNOMEUIINFO_SEPARATOR,
|
||||
GNOMEUIINFO_ITEM_NONE (N_("Rescan Mountable Devices"), NULL, handle_rescan_devices),
|
||||
GNOMEUIINFO_ITEM_NONE (N_("Recreate Desktop Shortcuts"), NULL, handle_rescan_devices),
|
||||
GNOMEUIINFO_ITEM_NONE (N_("Rescan Desktop"), NULL, handle_rescan_desktop),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
@ -2903,3 +2903,24 @@ desktop_destroy (void)
|
|||
XDeleteProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (), gdk_atom_intern ("XdndProxy", FALSE));
|
||||
}
|
||||
|
||||
void
|
||||
desktop_create_url (const char *filename, const char *title, const char *url, const char *icon)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen (filename, "w");
|
||||
if (f) {
|
||||
|
||||
fprintf (f, "URL: %s\n", url);
|
||||
fclose (f);
|
||||
|
||||
gnome_metadata_set (filename, "desktop-url",
|
||||
strlen (url) + 1, url);
|
||||
gnome_metadata_set (filename, "icon-caption",
|
||||
strlen (title) + 1, title);
|
||||
|
||||
gnome_metadata_set (filename, "icon-filename", strlen (icon) + 1, icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
26
gnome/gdnd.c
26
gnome/gdnd.c
|
@ -264,26 +264,16 @@ drop_url_on_directory (GdkDragContext *context, GtkSelectionData *selection_data
|
|||
template = g_concat_dir_and_file (destdir, "urlXXXXXX");
|
||||
|
||||
if (mktemp (template)) {
|
||||
FILE *f;
|
||||
char *icon;
|
||||
|
||||
f = fopen (template, "w");
|
||||
if (f) {
|
||||
char *icon;
|
||||
|
||||
fprintf (f, "URL: %s\n", selection_data->data);
|
||||
fclose (f);
|
||||
|
||||
gnome_metadata_set (template, "desktop-url",
|
||||
strlen (selection_data->data) + 1, selection_data->data);
|
||||
gnome_metadata_set (template, "icon-caption",
|
||||
strlen (selection_data->data) + 1, selection_data->data);
|
||||
|
||||
icon = g_concat_dir_and_file (ICONDIR, "gnome-http-url.png");
|
||||
gnome_metadata_set (template, "icon-filename", strlen (icon) + 1, icon);
|
||||
g_free (icon);
|
||||
}
|
||||
icon = g_concat_dir_and_file (ICONDIR, "gnome-http-url.png");
|
||||
desktop_create_url (
|
||||
template,
|
||||
selection_data->data,
|
||||
selection_data->data,
|
||||
icon);
|
||||
g_free (icon);
|
||||
}
|
||||
|
||||
g_free (template);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ gprint_setup_devices (void)
|
|||
return;
|
||||
|
||||
desktop_quoted = name_quote (desktop_directory, 0);
|
||||
command = g_strconcat (gprint_path, " --create-printers ", desktop_quoted, NULL);
|
||||
command = g_strconcat (gprint_path, " --desktop-dir ", desktop_quoted, NULL);
|
||||
g_free (desktop_quoted);
|
||||
|
||||
my_system (EXECUTE_WAIT | EXECUTE_AS_SHELL, shell, command);
|
||||
|
|
|
@ -113,6 +113,17 @@ panel_file_list_set_type_bitmap (GtkCList *cl, int row, int column, int color, f
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
panel_cancel_drag_scroll (WPanel *panel)
|
||||
{
|
||||
g_return_if_fail (panel != NULL);
|
||||
|
||||
if (panel->timer_id != -1){
|
||||
gtk_timeout_remove (panel->timer_id);
|
||||
panel->timer_id = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the color attributes for a given row.
|
||||
*/
|
||||
|
@ -605,10 +616,7 @@ typedef gboolean (*scroll_fn)(gpointer data);
|
|||
static gboolean
|
||||
panel_setup_drag_scroll (WPanel *panel, int x, int y, desirable_fn desirable, scroll_fn scroll)
|
||||
{
|
||||
if (panel->timer_id != -1){
|
||||
gtk_timeout_remove (panel->timer_id);
|
||||
panel->timer_id = -1;
|
||||
}
|
||||
panel_cancel_drag_scroll (panel);
|
||||
|
||||
panel->drag_motion_x = x;
|
||||
panel->drag_motion_y = y;
|
||||
|
@ -728,6 +736,7 @@ panel_drag_data_get (GtkWidget *widget,
|
|||
char *data;
|
||||
GList *files;
|
||||
|
||||
panel_cancel_drag_scroll (panel);
|
||||
data = panel_build_selected_file_list (panel, &len);
|
||||
|
||||
switch (info){
|
||||
|
@ -1005,6 +1014,7 @@ panel_drag_begin (GtkWidget *widget, GdkDragContext *context, WPanel *panel)
|
|||
static void
|
||||
panel_drag_end (GtkWidget *widget, GdkDragContext *context, WPanel *panel)
|
||||
{
|
||||
panel_cancel_drag_scroll (panel);
|
||||
panel->dragging = 0;
|
||||
}
|
||||
|
||||
|
@ -1164,10 +1174,7 @@ panel_clist_drag_leave (GtkWidget *widget, GdkDragContext *ctx, guint time, void
|
|||
{
|
||||
WPanel *panel = data;
|
||||
|
||||
if (panel->timer_id != -1){
|
||||
gtk_timeout_remove (panel->timer_id);
|
||||
panel->timer_id = -1;
|
||||
}
|
||||
panel_cancel_drag_scroll (panel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1280,10 +1287,7 @@ panel_icon_list_drag_leave (GtkWidget *widget, GdkDragContext *ctx, guint time,
|
|||
{
|
||||
WPanel *panel = data;
|
||||
|
||||
if (panel->timer_id != -1){
|
||||
gtk_timeout_remove (panel->timer_id);
|
||||
panel->timer_id = -1;
|
||||
}
|
||||
panel_cancel_drag_scroll (panel);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -15,14 +15,26 @@ INSTALL_DATA = @INSTALL_DATA@
|
|||
LIBFILES_IN = mc.ext.in mc-gnome.ext.in
|
||||
LIBFILES_OUT = mc.ext mc-gnome.ext
|
||||
LIBFILES_CONST = mc.hint mc.lib mc.menu
|
||||
DESKTOP_FILES = startup.links README.desktop
|
||||
TIFILES = README.xterm linux.ti xterm.ad xterm.ti ansi.ti vt100.ti xterm.tcap
|
||||
DISTLIB = $(LIBFILES_IN) $(LIBFILES_CONST) $(TIFILES) \
|
||||
Makefile.in tdiff xnc.hlp ncurses.h mc.sh mc.csh mcserv.init \
|
||||
mcserv.pamd tkmc.wmconfig mc.ext.in.qnx.diff mc.global
|
||||
|
||||
DISTLIB = \
|
||||
$(LIBFILES_IN) \
|
||||
$(LIBFILES_CONST) \
|
||||
$(TIFILES) \
|
||||
$(DESKTOP_FILES) \
|
||||
Makefile.in tdiff \
|
||||
xnc.hlp ncurses.h \
|
||||
mc.sh mc.csh \
|
||||
mcserv.init \
|
||||
mcserv.pamd \
|
||||
tkmc.wmconfig \
|
||||
mc.ext.in.qnx.diff \
|
||||
mc.global
|
||||
|
||||
all: Makefile
|
||||
|
||||
Makefile.in: ../config.status
|
||||
Makefile: ../config.status Makefile.in
|
||||
(cd ..; CONFIG_FILES=lib/Makefile CONFIG_HEADERS= ./config.status)
|
||||
|
||||
check:
|
||||
|
@ -49,6 +61,9 @@ install:
|
|||
do $(INSTALL_DATA) $(srcdir)/$$I $(DESTDIR)$(tidir)/$$I; done
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(confdir)
|
||||
$(INSTALL_DATA) $(srcdir)/mc.global $(DESTDIR)$(confdir)
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(desktopdir)
|
||||
for I in $(DESKTOP_FILES); \
|
||||
do $(INSTALL_DATA) $(srcdir)/$$I $(DESTDIR)$(desktopdir)/$$I; done
|
||||
|
||||
uninstall:
|
||||
for I in $(LIBFILES_OUT) $(LIBFILES_CONST); \
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
* The Desktop startup directory
|
||||
|
||||
The directory $(libdir)/desktop-scripts is a place holder for
|
||||
information on how to configure the default's user desktop. There are
|
||||
a number of files that can be installed in this directory:
|
||||
|
||||
* Link definition files: These files are used to create
|
||||
links to web and ftp sites on the user's desktop.
|
||||
|
||||
* Executables: Programs or links to programs that will be
|
||||
executed when the user requests a directory rescan.
|
||||
|
||||
* Link definition file format
|
||||
|
||||
The file should contain an ini-like file whose contents are as follows:
|
||||
|
||||
[linkname]
|
||||
title=Title in english
|
||||
title[NN]=Title in language NN
|
||||
type=url
|
||||
url=some-url
|
||||
|
||||
The linkname is the name of the file that will be created in the
|
||||
user's desktop directory.
|
||||
|
||||
title is the caption that will be used by this file. This can be
|
||||
localized by providing one or more title[NN] entries, where NN is
|
||||
the setting that would be set by the user for the NN locale.
|
||||
|
||||
|
||||
* Executables
|
||||
|
||||
Executable programs will be executed like this:
|
||||
|
||||
program --desktop-dir DESKTOPDIR
|
||||
|
||||
Where DESKTOPDIR is the user's desktop directory.
|
|
@ -0,0 +1,9 @@
|
|||
[gnews]
|
||||
title=GNOME News
|
||||
type=url
|
||||
url=http://www.gnome.org/news
|
||||
|
||||
[slashdot]
|
||||
title=Slashdot
|
||||
type=url
|
||||
url=http://slashdot.org
|
21
src/main.c
21
src/main.c
|
@ -358,6 +358,9 @@ int finish_program = 0;
|
|||
/* If set, then no windows are displayed in the GNOME edition */
|
||||
int nowindows = 0;
|
||||
|
||||
/* If set it displays the directory that holds the gnome .links files */
|
||||
int display_linksdir = 0;
|
||||
|
||||
/* Forward declarations */
|
||||
char *get_mc_lib_dir ();
|
||||
int panel_event (Gpm_Event *event, WPanel *panel);
|
||||
|
@ -2544,7 +2547,7 @@ process_args (int c, const char *option_arg)
|
|||
version (1);
|
||||
finish_program = 1;
|
||||
break;
|
||||
|
||||
|
||||
case 'c':
|
||||
disable_colors = 0;
|
||||
#ifdef HAVE_SLANG
|
||||
|
@ -2713,6 +2716,8 @@ static struct poptOption argument_table [] = {
|
|||
{ "geometry", '\0', POPT_ARG_STRING, &cmdline_geometry, 0, N_("Geometry for the window"), N_("GEOMETRY")},
|
||||
{"nowindows", '\0', POPT_ARG_NONE, &nowindows, 0, N_("No windows opened at startup"), NULL},
|
||||
{"force-activation",0,POPT_ARG_NONE, &force_activation, 0, N_("Force activation even if a server is already running"), NULL},
|
||||
{"desktop-linksdir", '\0', POPT_ARG_NONE, &display_linksdir, 0,
|
||||
N_("Displays the directory that holds the .links startup files")},
|
||||
#endif
|
||||
|
||||
{ NULL, 0, 0, NULL, 0 }
|
||||
|
@ -2741,6 +2746,11 @@ handle_args (int argc, char *argv [])
|
|||
orb = gnome_CORBA_init_with_popt_table (
|
||||
"gmc", VERSION, &argc, argv, argument_table, 0, &ctx, GNORBA_INIT_SERVER_FUNC, &ev);
|
||||
|
||||
if (display_linksdir){
|
||||
puts (DESKTOP_INIT_DIR);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
corba_init ();
|
||||
if (!force_activation)
|
||||
if (try_to_activate_running_copy ())
|
||||
|
@ -2748,6 +2758,10 @@ handle_args (int argc, char *argv [])
|
|||
#else
|
||||
gnome_init_with_popt_table ("gmc", VERSION, argc, argv, argument_table, 0, &ctx);
|
||||
#endif
|
||||
if (display_linksdir){
|
||||
puts (DESKTOP_INIT_DIR);
|
||||
exit (1);
|
||||
}
|
||||
gtk_widget_push_visual (gdk_imlib_get_visual ());
|
||||
gtk_widget_push_colormap (gdk_imlib_get_colormap ());
|
||||
|
||||
|
@ -2888,7 +2902,6 @@ mc_tree_store_save (void)
|
|||
{
|
||||
char *tree_file;
|
||||
|
||||
printf ("Saving tree!\n");
|
||||
tree_file = concat_dir_and_file (home_dir, MC_TREE);
|
||||
tree_store_save (tree_file);
|
||||
g_free (tree_file);
|
||||
|
@ -2896,10 +2909,6 @@ mc_tree_store_save (void)
|
|||
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
#ifdef HAVE_GNOME
|
||||
/* Just to time things */
|
||||
printf ("GNU Midnight Commander " VERSION "\n");
|
||||
#endif
|
||||
/* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain ("mc", LOCALEDIR);
|
||||
|
|
Loading…
Reference in New Issue