Commit 9891788c authored by JP Rosevear's avatar JP Rosevear Committed by JP Rosevear

optionally compile nautilus-main-menu dir

2006-12-15  JP Rosevear  <jpr@novell.com>

	* Makefile.am: optionally compile nautilus-main-menu dir

	* nautilus-main-menu/nautilus-main-menu.[hc], main-menu.c: add
	nautilus extension skeleton to add items to favorites

	* configure.in: add --enable-nautilus-extension option and
	appropriate checks
parent 0acdfe95
2006-12-15 JP Rosevear <jpr@novell.com>
* Makefile.am: optionally compile nautilus-main-menu dir
* nautilus-main-menu/nautilus-main-menu.[hc], main-menu.c: add
nautilus extension skeleton to add items to favorites
* configure.in: add --enable-nautilus-extension option and
appropriate checks
2006-12-13 Pema Geyleg <pgeyleg@gmail.com>
* configure.in: Added 'dz' in ALL_LINGUAS
......
if ENABLE_NAUTILUS_EXTENSION
NAUTILUS_DIR=nautilus-main-menu
else
NAUTILUS_DIR=
endif
SUBDIRS = \
libslab \
application-browser/etc \
......@@ -6,6 +12,7 @@ SUBDIRS = \
control-center/src \
main-menu/etc \
main-menu/src \
$(NAUTILUS_DIR) \
patch \
po
......
......@@ -83,6 +83,32 @@ dnl ==============================================
dnl End: Gconf
dnl ==============================================
dnl ==============================================
dnl Nautilus Extension
dnl ==============================================
ENABLE_PROFILER=
AC_ARG_ENABLE(nautilus-extension,
AC_HELP_STRING([--enable-nautilus-extension], [Enable nautilus extension]),
[ENABLE_NAUTILUS_EXTENSION=1])
if test "x$ENABLE_NAUTILUS_EXTENSION" = "x1"
then
NAUTILUS_REQUIRED=2.6.0
PKG_CHECK_MODULES(NAUTILUS, [libnautilus-extension >= $NAUTILUS_REQUIRED glib-2.0 gobject-2.0 gconf-2.0])
AC_SUBST(NAUTILUS_CFLAGS)
AC_SUBST(NAUTILUS_LIBS)
fi
AM_CONDITIONAL(ENABLE_NAUTILUS_EXTENSION, test "x$ENABLE_NAUTILUS_EXTENSION" = "x1")
dnl ==============================================
dnl End: Nautilus Extension
dnl ==============================================
GTK_DOC_CHECK(1.0)
AC_OUTPUT([
......@@ -95,6 +121,7 @@ libslab/Makefile
libslab/libslab.pc
main-menu/etc/Makefile
main-menu/src/Makefile
nautilus-main-menu/Makefile
patch/Makefile
po/Makefile.in
])
.deps
.libs
Makefile
Makefile.in
nld-marshal.c
nld-marshal.h
search-entry-watermark.h
libslab.pc
INCLUDES = \
-DG_LOG_DOMAIN=\"Nautilus-Main-Menu\" \
-DDATADIR=\"$(datadir)\" \
-I$(top_srcdir) \
-I$(top_builddir) \
$(NAUTILUS_CFLAGS) \
$(WARN_CFLAGS)
# FIXME: get this from the .pc file
nautilus_extensiondir=$(libdir)/nautilus/extensions-1.0
nautilus_extension_LTLIBRARIES=libnautilus-main-menu.la
libnautilus_main_menu_la_SOURCES = \
nautilus-main-menu.c \
nautilus-main-menu.h \
main-menu.c
libnautilus_main_menu_la_LDFLAGS = -module -avoid-version
libnautilus_main_menu_la_LIBADD = $(NAUTILUS_LIBS) $(GNOMEVFS_LIBS) $(GCONF_LIBS) $(GNOMEDESKTOP_LIBS)
AM_CPPFLAGS = \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
\ No newline at end of file
/*
* main-menu.c
*
* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
*
* This library 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 library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Author: Christian Neumair <chris@gnome-de.org>
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "nautilus-main-menu.h"
#include <libintl.h>
static GType type_list[1];
void
nautilus_module_initialize (GTypeModule *module)
{
g_print ("Initializing nautilus-main-menu extension\n");
nautilus_main_menu_register_type (module);
type_list[0] = NAUTILUS_TYPE_MAIN_MENU;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
}
void
nautilus_module_shutdown (void)
{
g_print ("Shutting down nautilus-main-menu extension\n");
}
void
nautilus_module_list_types (const GType **types,
int *num_types)
{
*types = type_list;
*num_types = G_N_ELEMENTS (type_list);
}
/*
* nautilus-main-menu.c
*
* Copyright (C) 2006 Novell, Inc.
*
* This library 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 library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Author: JP Rosevear <jpr@novell.com>
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "nautilus-main-menu.h"
#include <libnautilus-extension/nautilus-menu-provider.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtkicontheme.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtkmain.h>
#include <gconf/gconf-client.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <string.h> /* for strcmp */
#include <unistd.h> /* for chdir */
static void nautilus_main_menu_instance_init (NautilusMainMenu *cvs);
static void nautilus_main_menu_class_init (NautilusMainMenuClass *class);
static GType menu_type = 0;
typedef enum {
FILE_INFO_LAUNCHER,
FILE_INFO_DOCUMENT,
FILE_INFO_OTHER,
} MenuFileInfo;
static const char * const document_blacklist [] =
{
"application/x-executable"
};
static MenuFileInfo
get_menu_file_info (NautilusFileInfo *file_info)
{
MenuFileInfo ret;
gchar *mime_type;
g_assert (file_info);
mime_type = nautilus_file_info_get_mime_type (file_info);
g_print ("Checking mime type %s\n", mime_type);
if (strcmp (mime_type, "application/x-desktop") == 0) {
ret = FILE_INFO_LAUNCHER;
} else {
int i;
ret = FILE_INFO_DOCUMENT;
for (i = 0; i < G_N_ELEMENTS (document_blacklist); i++) {
if (strcmp (mime_type, document_blacklist [i]) == 0) {
ret = FILE_INFO_DOCUMENT;
break;
}
}
}
g_free (mime_type);
return ret;
}
static void
main_menu_callback (NautilusMenuItem *item,
NautilusFileInfo *file_info)
{
static GConfClient *client;
client = gconf_client_get_default ();
switch (get_menu_file_info (file_info)) {
case FILE_INFO_LAUNCHER:
/* Add to the launcher favorites */
break;
case FILE_INFO_DOCUMENT:
/* Add to document favorites */
break;
case FILE_INFO_OTHER:
default:
g_assert_not_reached ();
}
}
static NautilusMenuItem *
main_menu_menu_item_new (MenuFileInfo menu_file_info)
{
NautilusMenuItem *ret;
const char *name;
const char *tooltip;
switch (menu_file_info) {
case FILE_INFO_LAUNCHER:
name = _("Add to Favorites");
tooltip = _("Add the current launcher to favorites");
break;
case FILE_INFO_DOCUMENT:
name = _("Add to Favorites");
tooltip = _("Add the current document to favorites");
break;
case FILE_INFO_OTHER:
default:
g_assert_not_reached ();
}
ret = nautilus_menu_item_new ("NautilusMainMenu::main_menu",
name, tooltip, "gnome-fs-client");
return ret;
}
static GList *
nautilus_main_menu_get_file_items (NautilusMenuProvider *provider,
GtkWidget *window,
GList *files)
{
NautilusMenuItem *item;
MenuFileInfo menu_file_info;
GList *l;
for (l = files; l != NULL; l = l->next) {
menu_file_info = get_menu_file_info (l->data);
switch (menu_file_info) {
case FILE_INFO_LAUNCHER:
case FILE_INFO_DOCUMENT:
item = main_menu_menu_item_new (menu_file_info);
g_signal_connect (item, "activate",
G_CALLBACK (main_menu_callback),
files->data);
return g_list_append (NULL, item);
case FILE_INFO_OTHER:
continue;
default:
g_assert_not_reached ();
}
}
return NULL;
}
static void
nautilus_main_menu_menu_provider_iface_init (NautilusMenuProviderIface *iface)
{
iface->get_file_items = nautilus_main_menu_get_file_items;
}
static void
nautilus_main_menu_instance_init (NautilusMainMenu *cvs)
{
}
static void
nautilus_main_menu_class_init (NautilusMainMenuClass *class)
{
}
GType
nautilus_main_menu_get_type (void)
{
return menu_type;
}
void
nautilus_main_menu_register_type (GTypeModule *module)
{
static const GTypeInfo info = {
sizeof (NautilusMainMenuClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) nautilus_main_menu_class_init,
NULL,
NULL,
sizeof (NautilusMainMenu),
0,
(GInstanceInitFunc) nautilus_main_menu_instance_init,
};
static const GInterfaceInfo menu_provider_iface_info = {
(GInterfaceInitFunc) nautilus_main_menu_menu_provider_iface_init,
NULL,
NULL
};
menu_type = g_type_module_register_type (module,
G_TYPE_OBJECT,
"NautilusMainMenu",
&info, 0);
g_type_module_add_interface (module,
menu_type,
NAUTILUS_TYPE_MENU_PROVIDER,
&menu_provider_iface_info);
}
/*
* nautilus-main-menu.h
*
* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
*
* This library 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 library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Author: Christian Neumair <chris@gnome-de.org>
*
*/
#ifndef NAUTILUS_MAIN_MENU_H
#define NAUTILUS_MAIN_MENU_H
#include <glib-object.h>
G_BEGIN_DECLS
/* Declarations for the open terminal extension object. This object will be
* instantiated by nautilus. It implements the GInterfaces
* exported by libnautilus. */
#define NAUTILUS_TYPE_MAIN_MENU (nautilus_main_menu_get_type ())
#define NAUTILUS_MAIN_MENU(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NAUTILUS_TYPE_MAIN_MENU, NautilusMainMenu))
#define NAUTILUS_IS_MAIN_MENU(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NAUTILUS_TYPE_MAIN_MENU))
typedef struct _NautilusMainMenu NautilusMainMenu;
typedef struct _NautilusMainMenuClass NautilusMainMenuClass;
struct _NautilusMainMenu {
GObject parent_slot;
};
struct _NautilusMainMenuClass {
GObjectClass parent_slot;
};
GType nautilus_main_menu_get_type (void);
void nautilus_main_menu_register_type (GTypeModule *module);
G_END_DECLS
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment