bonobo activation server file for the fontilus component.

2003-02-02  James Henstridge  <james@daa.com.au>

    * src/fontilus.server.in.in: bonobo activation server file for the
    fontilus component.

    * src/fontilus-context-menu.c: Bonobo listener component to
    implement custom context menu items for fonts under fonts:///,
    which allows us to set the default font for the desktop.
This commit is contained in:
James Henstridge 2003-02-02 15:06:29 +00:00 committed by James Henstridge
parent 4ddeecaeed
commit 5992c48c1f
6 changed files with 198 additions and 4 deletions

View file

@ -8,5 +8,8 @@ Makefile.in
.deps
gnome-thumbnail-font
gnome-font-viewer
fontilus-context-menu
font-method.directory
fontilus.schemas
fontilus.server
fontilus.server.in

View file

@ -1,3 +1,12 @@
2003-02-02 James Henstridge <james@daa.com.au>
* src/fontilus.server.in.in: bonobo activation server file for the
fontilus component.
* src/fontilus-context-menu.c: Bonobo listener component to
implement custom context menu items for fonts under fonts:///,
which allows us to set the default font for the desktop.
2003-02-02 Daniel Yacob <locales@geez.org>
* configure.in: Added Amharic (am) to ALL_LINGUAS

View file

@ -1,6 +1,6 @@
INCLUDES = $(FONT_METHOD_CFLAGS) $(THUMBNAILER_CFLAGS) $(FONT_VIEW_CFLAGS) \
-DDIRECTORY_DIR=\"$(vfsdirectorydir)\"
$(CONTEXT_MENU_CFLAGS) -DDIRECTORY_DIR=\"$(vfsdirectorydir)\"
vfsmoduledir = $(libdir)/gnome-vfs-2.0/modules
vfsmodule_LTLIBRARIES = libfont-method.la
@ -18,14 +18,16 @@ gnome_thumbnail_font_SOURCES = ftstream-vfs.c thumbnailer.c
gnome_font_viewer_LDADD = $(FONT_VIEW_LIBS)
gnome_font_viewer_SOURCES = ftstream-vfs.c font-view.c
libexec_PROGRAMS = fontilus-context-menu
fontilus_context_menu_LDADD = $(CONTEXT_MENU_LIBS)
fontilus_context_menu_SOURCES = fontilus-context-menu.c
vfsmoduleconfdir = $(sysconfdir)/gnome-vfs-2.0/modules
vfsmoduleconf_DATA = font-method.conf
vfsdirectorydir = $(datadir)/gnome/vfolders
vfsdirectory_DATA = font-method.directory
@INTLTOOL_DIRECTORY_RULE@
mimeinfodir = $(datadir)/mime-info
mimeinfo_DATA = fontilus.keys fontilus.mime
@ -35,12 +37,19 @@ appreg_DATA = fontilus.applications
schemasdir = $(sysconfdir)/gconf/schemas
schemas_DATA = fontilus.schemas
serverdir = $(libdir)/bonobo/servers
server_DATA = fontilus.server
fontilus.server.in: fontilus.server.in.in
sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@
install-data-local:
if test -z "$(DESTDIR)"; then \
GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule fontilus.schemas; \
fi
@INTLTOOL_DIRECTORY_RULE@
@INTLTOOL_SCHEMAS_RULE@
@INTLTOOL_SERVER_RULE@
EXTRA_DIST = \
font-method.conf \

View file

@ -364,7 +364,7 @@ set_icon(GtkWindow *window, const gchar *uri)
if (!pixbuf) goto end;
gtk_window_set_icon(window, pixbuf);
end:
end:
if (pixbuf) g_object_unref(pixbuf);
g_free(icon_file);
g_free(icon_name);

View file

@ -0,0 +1,139 @@
/* -*- mode: C; c-basic-offset: 4 -*-
* Copyright (C) 2002 James Henstridge
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include <gtk/gtk.h>
#include <libgnome/gnome-i18n.h>
#include <libbonobo.h>
#include <libgnomevfs/gnome-vfs.h>
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
#define GTK_FONT_KEY "/desktop/gnome/interface/font_name"
static GConfClient *default_client;
static gchar *
get_font_name(const gchar *uri)
{
gchar *unescaped;
gchar *base;
unescaped = gnome_vfs_unescape_string(uri, "/");
if (!unescaped) return NULL;
base = g_path_get_basename(unescaped);
g_free(unescaped);
if (!base) return NULL;
return base;
}
/* create a font string suitable to store in GTK_FONT_KEY using font_name.
* tries to preserve the font size from the old string */
static gchar *
make_font_string(const gchar *old_string, const gchar *font_name)
{
const gchar *space;
if (!old_string)
return g_strdup(font_name);
space = strrchr(old_string, ' ');
/* if no space, or the character after the last space is not a digit */
if (!space || (space[1] < '0' || '9' < space[1]))
return g_strdup(font_name);
/* if it looks like the last word is a number, append it to the
* font name to form the new name */
return g_strconcat(font_name, space, NULL);
}
static void
handle_event(BonoboListener *listener, const gchar *event_name,
const CORBA_any *args, CORBA_Environment *ev, gpointer user_data)
{
const CORBA_sequence_CORBA_string *list;
gchar *font_name = NULL;
if (!CORBA_TypeCode_equivalent(args->_type, TC_CORBA_sequence_CORBA_string, ev)) {
goto end;
}
list = (CORBA_sequence_CORBA_string *)args->_value;
if (list->_length != 1) {
goto end;
}
font_name = get_font_name(list->_buffer[0]);
if (!font_name) goto end;
/* set font */
if (!strcmp(event_name, "UseAsApplicationFont")) {
gchar *curval, *newval;
curval = gconf_client_get_string(default_client,
GTK_FONT_KEY, NULL);
newval = make_font_string(curval, font_name);
gconf_client_set_string(default_client, GTK_FONT_KEY, newval, NULL);
g_free(newval);
g_free(curval);
} else {
goto end;
}
end:
g_free(font_name);
}
/* --- factory --- */
static BonoboObject *
view_factory(BonoboGenericFactory *this_factory,
const gchar *iid,
gpointer user_data)
{
BonoboListener *listener;
listener = bonobo_listener_new(handle_event, NULL);
return BONOBO_OBJECT(listener);
}
int
main(int argc, char *argv[])
{
bindtextdomain(GETTEXT_PACKAGE, FONTILUS_LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
BONOBO_FACTORY_INIT(_("Font context menu items"), VERSION,
&argc, argv);
default_client = gconf_client_get_default();
g_return_val_if_fail(default_client != NULL, -1);
return bonobo_generic_factory_main("OAFIID:Fontilus_Context_Menu_Factory",
view_factory, NULL);
}

View file

@ -0,0 +1,34 @@
<?xml version="1.0"?> <!--*- mode: xml -*-->
<oaf_info>
<oaf_server iid="OAFIID:Fontilus_Context_Menu_Factory"
type="exe" location="@LIBEXECDIR@/fontilus-context-menu">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/ObjectFactory:1.0" />
</oaf_attribute>
<oaf_attribute name="name" type="string" _value="Fontilus context menu factory" />
<oaf_attribute name="description" type="string" _value="Factory for the fontilus context menu" />
</oaf_server>
<oaf_server iid="OAFIID:Fontilus_Context_Menu"
type="factory" location="OAFIID:Fontilus_Context_Menu_Factory">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/Unknown:1.0" />
<item value="IDL:Bonobo/Listener:1.0" />
</oaf_attribute>
<oaf_attribute name="name" type="string" _value="Fontilus context menu" />
<oaf_attribute name="description" type="string" _value="Nautilus context menu entries for fonts" />
<oaf_attribute name="bonobo:supported_uri_schemes" type="stringv">
<item value="fonts" />
</oaf_attribute>
<oaf_attribute name="bonobo:supported_mime_types" type="stringv">
<item value="application/x-font-ttf" />
<item value="application/x-font-type1" />
<item value="application/x-font-pcf" />
<item value="application/x-font-otf" />
</oaf_attribute>
<oaf_attribute name="nautilus:context_menu_handler" type="boolean" value="true" />
<oaf_attribute name="nautilus:can_handle_multiple_files" type="boolean" value="false" />
<oaf_attribute name="nautilusverb:UseAsApplicationFont" type="string" _value="Use as application font" />
</oaf_server>
</oaf_info>