...
 
Commits (95)
......@@ -4,4 +4,6 @@ JP Rosevear <jpr@novell.com>
Scott Reeves <sreeves@novell.com>
Contributors:
Rodney Dawes
Jaap A. Haitsma
Jonh Wendell
2007-01-30 Scott Reeves <sreeves@novell.com>
* application-browser/src/application-browser.c
* control-center/src/control-center.c
* libslab/application-tile.c
* libslab/application-tile.h
* libslab/app-shell.c
* libslab/app-shell.h:
Fix for BNC#185957 - inconsistent GenericName display
2007-01-25 Scott Reeves <sreeves@novell.com>
* control-center/src/control-center.c: - stop CC common tasks from
launching twic
* main-menu/src/system-tile.c: - patch from Otavio Salvador for
system-tile's launched twice.
* libslab/application-tile.c: - When no GenericName is present then
just show and center the Name
2007-01-19 Scott Reeves <sreeves@novell.com>
* control-center/src/control-center.c
* libslab/app-shell.c:
Check the exit arg when exiting via keyboard and context menu
2007-01-18 Rodrigo Moya <rodrigo@gnome-db.org>
* libslab/app-shell.c (main_delete_callback): return FALSE if we
want the window destroyed.
2007-01-17 Rodrigo Moya <rodrigo@gnome-db.org>
* libslab/app-shell.[ch] (appshelldata_new): added an argument to
specify whether to exit the program when the shell window is closed.
* application-browser/src/application-browser.c (main): pass FALSE,
don't quit.
* control-center/src/control-center.c (main): pass TRUE, quit when
closed.
(handle_static_action_clicked): check for the exit_on_close flag if
the GConf key is set.
2007-01-12 Scott Reeves <sreeves@novell.com>
* libslab/libslab.pc.in:
Clean up the .pc file
2007-01-12 Scott Reeves <sreeves@novell.com>
* ChangeLog
* libslab/app-resizer.c
* libslab/tile-action.c
* libslab/shell-window.c
* libslab/slab-section.c
* libslab/app-shell-startup.c
* libslab/app-shell.c:
Patch from Jens Granseuer for http://bugzilla.gnome.org/show_bug.cgi?id=383029.
http://bugzilla.gnome.org/show_bug.cgi?id=393708.
2007-01-11 Scott Reeves <sreeves@novell.com>
* libslab/app-shell.c:
Original Patch from Denis Washington. Tweaked the category name after
discussion on #control-center to indicate more clearly that this is
not a permanent home for items. They should classify themselves into
one of the existing top level categories.
http://bugzilla.gnome.org/show_bug.cgi?id=384051.
2006-12-28 Adam Weinberger <adamw@gnome.org>
* configure.in: Added en_CA to ALL_LINGUAS.
2006-12-22 Scott Reeves <sreeves@novell.com>
* libslab/app-shell-startup.c:
Fix for vncviewer and singleton.
https://bugzilla.novell.com/show_bug.cgi?id=180062
2006-12-18 Thomas Wood <thos@gnome.org>
* libslab/app-shell.c:
......
......@@ -39,7 +39,7 @@ After installing a "Gnome Main Menu" applet should appear in your "Add to panel
Contributing
------------
This project can be found in gnome-cvs under the module named "slab". To
This project can be found in gnome svn under the module named "gnome-main-menu". To
access this see: http://developer.gnome.org/tools/cvs.html. Feel free to send
any patches to anyone in the MAINTAINERS file.
......
......@@ -83,8 +83,8 @@ main (int argc, char *argv[])
NewAppConfig *config = g_new0 (NewAppConfig, 1);
config->max_items = get_slab_gconf_int (NEW_APPS_MAX_ITEMS);
config->name = _("New Applications");
AppShellData *app_data = appshelldata_new (
"applications.menu", config, APPLICATION_BROWSER_PREFIX, GTK_ICON_SIZE_DND);
AppShellData *app_data = appshelldata_new ("applications.menu", config,
APPLICATION_BROWSER_PREFIX, GTK_ICON_SIZE_DND, TRUE, FALSE);
generate_categories (app_data);
layout_shell (app_data, _("Filter"), _("Groups"), _("Application Actions"), NULL, NULL);
......
AC_INIT([gnome-main-menu], [0.6.3], [])
AC_INIT([gnome-main-menu], [0.9.5], [])
AC_CONFIG_SRCDIR([.])
AC_CONFIG_HEADERS([config.h])
......@@ -22,7 +22,7 @@ dnl ==============================================
GETTEXT_PACKAGE=gnome-main-menu
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
ALL_LINGUAS="ar bg bn br bs ca cs cy da de dz el en_GB en_IGID es fi fr gl he hi hr hu id it ja ka km ko lo lt mk nb nl pa pl pt_BR pt ro ru sk sl sr sv ta tr uk zh_CN zh_TW"
ALL_LINGUAS="af ar bg bn br bs ca cs cy da de dz el en_GB en_IGID en_US es et fi fr gl gu he hi hr hu id it ja ka km ko lo lt mk mr nb nl pa pl pt_BR pt ro ru sk sl sr sv ta tr uk vi xh zh_CN zh_TW zu"
IT_PROG_INTLTOOL([0.34])
AM_GLIB_GNU_GETTEXT
......@@ -43,7 +43,7 @@ PKG_CHECK_MODULES(LIBSLAB, [ $COMMON_MODULES gnome-desktop-2.0 librsvg-2.0 libgn
AC_SUBST(LIBSLAB_CFLAGS)
AC_SUBST(LIBSLAB_LIBS)
PKG_CHECK_MODULES(MAIN_MENU, [ $COMMON_MODULES libpanelapplet-2.0 gnome-desktop-2.0 gconf-2.0 libgtop-2.0 libgnome-2.0 libgnomeui-2.0 dbus-glib-1 NetworkManager hal-storage ])
PKG_CHECK_MODULES(MAIN_MENU, [ $COMMON_MODULES libpanelapplet-2.0 gnome-desktop-2.0 gconf-2.0 libgtop-2.0 libgnome-2.0 libgnomeui-2.0 dbus-glib-1 NetworkManager hal-storage cairo ])
AC_CHECK_HEADERS(iwlib.h, [ AC_CHECK_LIB(iw, iw_sockets_open, have_iwlib=yes, have_iwlib=no)], have_iwlib=no)
......
......@@ -51,6 +51,7 @@ static GSList *get_actions_list ();
static GSList *
get_actions_list ()
{
GSList *l;
GSList *key_list;
GSList *actions_list = NULL;
AppAction *action;
......@@ -62,12 +63,13 @@ get_actions_list ()
return NULL;
}
for (; key_list; key_list = key_list->next)
for (l = key_list; l != NULL; l = l->next)
{
gchar *entry = (gchar *) key_list->data;
gchar *entry = (gchar *) l->data;
gchar **temp;
action = g_new (AppAction, 1);
gchar **temp = g_strsplit (entry, CONTROL_CENTER_ACTIONS_SEPARATOR, 2);
temp = g_strsplit (entry, CONTROL_CENTER_ACTIONS_SEPARATOR, 2);
action->name = g_strdup (temp[0]);
if ((action->item = load_desktop_item_from_unknown (temp[1])) == NULL)
{
......@@ -75,19 +77,23 @@ get_actions_list ()
}
else
{
actions_list = g_slist_append (actions_list, action);
actions_list = g_slist_prepend (actions_list, action);
}
g_strfreev (temp);
g_free (entry);
}
g_slist_free (key_list);
return actions_list;
return g_slist_reverse (actions_list);
}
void
handle_static_action_clicked (Tile * tile, TileEvent * event, gpointer data)
{
if (event->type == TILE_EVENT_ACTIVATED_DOUBLE_CLICK)
return;
gchar *temp;
AppShellData *app_data = (AppShellData *) data;
......@@ -97,7 +103,12 @@ handle_static_action_clicked (Tile * tile, TileEvent * event, gpointer data)
temp = g_strdup_printf("%s%s", app_data->gconf_prefix, EXIT_SHELL_ON_STATIC_ACTION);
if (get_slab_gconf_bool(temp))
gtk_main_quit ();
{
if (app_data->exit_on_close)
gtk_main_quit ();
else
hide_shell (app_data);
}
g_free (temp);
}
......@@ -107,6 +118,9 @@ main (int argc, char *argv[])
BonoboApplication *bonobo_app = NULL;
gboolean hidden = FALSE;
gchar * startup_id;
AppShellData *app_data;
GSList *actions;
GnomeProgram *program;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
......@@ -127,7 +141,7 @@ main (int argc, char *argv[])
}
startup_id = g_strdup (g_getenv (DESKTOP_STARTUP_ID));
gnome_program_init ("Gnome Control Center", "0.1", LIBGNOMEUI_MODULE,
program = gnome_program_init ("GNOME Control Center", "0.1", LIBGNOMEUI_MODULE,
argc, argv, NULL, NULL);
if (apss_already_running (argc, argv, &bonobo_app, "GNOME-NLD-ControlCenter", startup_id))
......@@ -138,11 +152,11 @@ main (int argc, char *argv[])
exit (1);
}
AppShellData *app_data = appshelldata_new (
"preferences.menu", NULL, CONTROL_CENTER_PREFIX, GTK_ICON_SIZE_DIALOG);
app_data = appshelldata_new ("preferences.menu", NULL, CONTROL_CENTER_PREFIX,
GTK_ICON_SIZE_DIALOG, FALSE, TRUE);
generate_categories (app_data);
GSList *actions = get_actions_list ();
actions = get_actions_list ();
layout_shell (app_data, _("Filter"), _("Groups"), _("Common Tasks"), actions,
handle_static_action_clicked);
......
[Desktop Entry]
X-SuSE-translate=true
_Name=Software Update
Exec=gnomesu rug update unstable
Icon=system-software-update
Terminal=true
Name=Logout
Icon=gnome-logout
Exec=gnome-session-save --kill
Terminal=false
Type=Application
StartupNotify=true
Encoding=UTF-8
NoDisplay=true
Categories=GNOME;Application;
OnlyShowIn=GNOME;
......@@ -10,14 +10,19 @@ libslab_la_SOURCES = \
app-shell.c \
app-shell-startup.c \
application-tile.c \
directory-tile.c \
document-tile.c \
double-click-detector.c \
double-click-detector.h \
eggbookmarkfile.c \
eggbookmarkfile.h \
egg-recent-item.c \
egg-recent-item.h \
egg-recent-model.c \
egg-recent-model.h \
gnome-utils.c \
libslab-utils.c \
libslab-utils.h \
nameplate-tile.c \
recent-files.c \
recent-files.h \
......@@ -28,6 +33,7 @@ libslab_la_SOURCES = \
shell-window.c \
slab-gnome-util.c \
slab-section.c \
system-tile.c \
themed-icon.c \
themed-icon.h \
tile-action.c \
......@@ -40,6 +46,7 @@ libslab_include_HEADERS = \
app-shell.h \
app-shell-startup.h \
application-tile.h \
directory-tile.h \
document-tile.h \
gnome-utils.h \
nameplate-tile.h \
......@@ -49,6 +56,7 @@ libslab_include_HEADERS = \
shell-window.h \
slab-gnome-util.h \
slab-section.h \
system-tile.h \
tile.h
libslab_la_LIBADD = \
......
......@@ -68,11 +68,13 @@ app_resizer_get_type (void)
static void
app_resizer_class_init (AppResizerClass * klass)
{
GtkWidgetClass *widget_class;
parent_class = g_type_class_peek_parent (klass);
((GtkObjectClass *) klass)->destroy = app_resizer_destroy;
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
widget_class->size_allocate = app_resizer_size_allocate;
}
......@@ -99,10 +101,12 @@ remove_container_entries (GtkContainer * widget)
static void
resize_table (GtkTable * table, gint columns, GList * launcher_list)
{
float rows, remainder;
remove_container_entries (GTK_CONTAINER (table));
float rows = ((float) g_list_length (launcher_list)) / (float) columns;
float remainder = rows - ((int) rows);
rows = ((float) g_list_length (launcher_list)) / (float) columns;
remainder = rows - ((int) rows);
if (remainder != 0.0)
rows += 1;
......@@ -158,6 +162,8 @@ calculate_num_cols (AppResizer * resizer, gint avail_width)
{
if (resizer->table_elements_homogeneous)
{
gint num_cols;
if (resizer->cached_element_width == -1)
{
GtkTable *table = GTK_TABLE (resizer->cached_tables_list->data);
......@@ -168,7 +174,7 @@ calculate_num_cols (AppResizer * resizer, gint avail_width)
resizer->cached_table_spacing = gtk_table_get_default_col_spacing (table);
}
gint num_cols =
num_cols =
(avail_width +
resizer->cached_table_spacing) / (resizer->cached_element_width +
resizer->cached_table_spacing);
......@@ -216,6 +222,7 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
static gboolean first_time = TRUE;
gint new_num_cols;
gint useable_area;
if (first_time)
{
......@@ -231,11 +238,12 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
if (!resizer->cached_tables_list) /* if everthing is currently filtered out - just return */
{
GtkAllocation child_allocation;
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
(*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
/* We want the message to center itself and only scroll if it's bigger than the available real size. */
GtkAllocation child_allocation;
child_allocation.x = 0;
child_allocation.y = 0;
child_allocation.width = MAX (allocation->width, child->requisition.width);
......@@ -246,7 +254,7 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
child_allocation.height);
return;
}
gint useable_area =
useable_area =
allocation->width - (child->requisition.width -
GTK_WIDGET (resizer->cached_tables_list->data)->requisition.width);
new_num_cols =
......@@ -272,10 +280,12 @@ GtkWidget *
app_resizer_new (GtkVBox * child, gint initial_num_columns, gboolean homogeneous,
AppShellData * app_data)
{
AppResizer *widget;
g_assert (child != NULL);
g_assert (GTK_IS_VBOX (child));
AppResizer *widget = g_object_new (APP_RESIZER_TYPE, NULL);
widget = g_object_new (APP_RESIZER_TYPE, NULL);
widget->cached_element_width = -1;
widget->cur_num_cols = initial_num_columns;
widget->table_elements_homogeneous = homogeneous;
......
......@@ -30,16 +30,17 @@
gint
apss_new_instance_cb (BonoboApplication * app, gint argc, char *argv[], gpointer data)
{
/* g_message ("new_instance_cb got called\n"); */
AppShellData *app_data = (AppShellData *) data;
SlabSection *section = SLAB_SECTION (app_data->filter_section);
NldSearchBar *search_bar;
gboolean visible;
/* g_message ("new_instance_cb got called\n"); */
/* Make sure our implementation has not changed */
g_assert (NLD_IS_SEARCH_BAR (section->contents));
NldSearchBar *search_bar = NLD_SEARCH_BAR (section->contents);
search_bar = NLD_SEARCH_BAR (section->contents);
gboolean visible;
g_object_get (app_data->main_gnome_app, "visible", &visible, NULL);
if (!visible)
{
......@@ -51,9 +52,11 @@ apss_new_instance_cb (BonoboApplication * app, gint argc, char *argv[], gpointer
{
gchar **results = g_strsplit (argv[0], "_TIME", 0);
gint lastentry = 0;
guint32 timestamp;
while (results[lastentry] != NULL)
lastentry++;
guint32 timestamp = (guint32) g_strtod (results[lastentry - 1], NULL);
timestamp = (guint32) g_strtod (results[lastentry - 1], NULL);
g_strfreev (results);
/* gdk_x11_window_move_to_current_desktop(window); */
......@@ -70,35 +73,39 @@ gboolean
apss_already_running (int argc, char *argv[], BonoboApplication ** app,
const gchar * name, gchar * startup_id)
{
gchar const *envp[] = { "LANG", NULL };
char * display_name;
gchar *serverinfo;
BonoboAppClient *client;
Bonobo_RegistrationResult reg_res;
if (bonobo_init (&argc, argv) == FALSE)
g_error ("Problem with bonobo_init");
if (!bonobo_activate ())
g_error ("Problem with bonobo_activate()");
bonobo_activation_set_activation_env_value ("DISPLAY",
gdk_display_get_name (gdk_display_get_default ()));
*app = bonobo_application_new (name);
gchar const *envp[] = { "LANG", NULL };
gchar *serverinfo = bonobo_application_create_serverinfo (*app, envp);
BonoboAppClient *client;
display_name = (char *) gdk_display_get_name (gdk_display_get_default ());
bonobo_activation_set_activation_env_value ("DISPLAY", display_name);
//make this a singleton per display per user
display_name = g_strconcat (name, display_name, NULL);
*app = bonobo_application_new (display_name);
g_free (display_name);
Bonobo_RegistrationResult reg_res =
bonobo_application_register_unique (*app, serverinfo, &client);
serverinfo = bonobo_application_create_serverinfo (*app, envp);
reg_res = bonobo_application_register_unique (*app, serverinfo, &client);
g_free (serverinfo);
switch (reg_res)
{
case Bonobo_ACTIVATION_REG_ALREADY_ACTIVE:
{
gchar *newargv[1];
int i;
bonobo_object_unref (BONOBO_OBJECT (*app));
*app = NULL;
gchar *newargv[1];
newargv[0] = startup_id;
i = bonobo_app_client_new_instance (client,
((newargv[0] && newargv[0][0] != '\0') ? 1 : 0), newargv, NULL);
......
This diff is collapsed.
......@@ -92,6 +92,9 @@ typedef struct _AppShellData
gboolean filtered_out_everything;
GtkWidget *filtered_out_everything_widget;
GtkLabel *filtered_out_everything_widget_label;
gboolean show_tile_generic_name;
gboolean exit_on_close;
} AppShellData;
typedef struct
......@@ -120,7 +123,8 @@ void generate_categories (AppShellData * app_data);
/* If new_apps is NULL then the new applications category is not created */
AppShellData *appshelldata_new (const gchar * menu_name, NewAppConfig * new_apps,
const gchar * gconf_keys_prefix, GtkIconSize icon_size);
const gchar * gconf_keys_prefix, GtkIconSize icon_size,
gboolean show_tile_generic_name, gboolean exit_on_close);
void layout_shell (AppShellData * app_data, const gchar * filter_title, const gchar * groups_title,
const gchar * actions_title, GSList * actions,
......
/*
* This file is part of libtile.
*
* Copyright (c) 2006 Novell, Inc.
* Copyright (c) 2006, 2007 Novell, Inc.
*
* Libtile is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
......@@ -30,6 +30,7 @@
#include <libgnomevfs/gnome-vfs-monitor.h>
#include "slab-gnome-util.h"
#include "libslab-utils.h"
#include "themed-icon.h"
......@@ -67,13 +68,14 @@ static void remove_from_startup_list (ApplicationTile *);
static gboolean verify_package_management_command (gchar *);
static void run_package_management_command (ApplicationTile *, gchar *);
static gboolean is_desktop_item_in_user_list (const gchar *);
static void update_user_list_menu_item (ApplicationTile *);
static void update_user_list_menu_item (ApplicationTile *);
static StartupStatus get_desktop_item_startup_status (GnomeDesktopItem *);
static void update_startup_menu_item (ApplicationTile *);
static void gconf_user_list_change_cb (GConfClient *, guint, GConfEntry *, gpointer);
static void apps_store_monitor_cb (
GnomeVFSMonitorHandle *, const gchar *,
const gchar *, GnomeVFSMonitorEventType, gpointer);
typedef struct {
GnomeDesktopItem *desktop_item;
......@@ -82,11 +84,11 @@ typedef struct {
gboolean image_is_broken;
GtkIconSize image_size;
gboolean show_generic_name;
gboolean is_in_user_list;
StartupStatus startup_status;
GConfClient *gconf_client;
guint gconf_conn_id;
GnomeVFSMonitorHandle *user_spec_monitor_handle;
} ApplicationTilePrivate;
#define APPLICATION_TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APPLICATION_TILE_TYPE, ApplicationTilePrivate))
......@@ -126,11 +128,12 @@ application_tile_class_init (ApplicationTileClass *app_tile_class)
GtkWidget *
application_tile_new (const gchar *desktop_item_id)
{
return application_tile_new_full (desktop_item_id, GTK_ICON_SIZE_DND);
return application_tile_new_full (desktop_item_id, GTK_ICON_SIZE_DND, TRUE);
}
GtkWidget *
application_tile_new_full (const gchar *desktop_item_id, GtkIconSize image_size)
application_tile_new_full (const gchar *desktop_item_id,
GtkIconSize image_size, gboolean show_generic_name)
{
ApplicationTile *this;
ApplicationTilePrivate *priv;
......@@ -153,6 +156,7 @@ application_tile_new_full (const gchar *desktop_item_id, GtkIconSize image_size)
priv->image_size = image_size;
priv->desktop_item = desktop_item;
priv->show_generic_name = show_generic_name;
application_tile_setup (this);
......@@ -170,8 +174,7 @@ application_tile_init (ApplicationTile *tile)
priv->is_in_user_list = FALSE;
priv->gconf_client = NULL;
priv->gconf_conn_id = 0;
priv->user_spec_monitor_handle = NULL;
}
static void
......@@ -190,10 +193,10 @@ application_tile_finalize (GObject *g_object)
if (priv->image_id)
g_free (priv->image_id);
gconf_client_notify_remove (priv->gconf_client, priv->gconf_conn_id);
g_object_unref (priv->gconf_client);
if (priv->user_spec_monitor_handle)
gnome_vfs_monitor_cancel (priv->user_spec_monitor_handle);
(* G_OBJECT_CLASS (application_tile_parent_class)->finalize) (g_object);
G_OBJECT_CLASS (application_tile_parent_class)->finalize (g_object);
}
static void
......@@ -280,7 +283,10 @@ application_tile_setup (ApplicationTile *this)
atk_object_set_description (accessible, desc);
header = create_header (name);
subheader = create_subheader (desc);
if (desc && priv->show_generic_name) /*if no GenericName then just show and center the Name */
subheader = create_subheader (desc);
else
subheader = NULL;
context_menu = GTK_MENU (gtk_menu_new ());
......@@ -295,7 +301,7 @@ application_tile_setup (ApplicationTile *this)
"application-description", desc,
NULL);
priv->is_in_user_list = is_desktop_item_in_user_list (TILE (this)->uri);
priv->is_in_user_list = libslab_user_apps_store_has_uri (TILE (this)->uri);
priv->startup_status = get_desktop_item_startup_status (priv->desktop_item);
actions = g_new0 (TileAction *, 6);
......@@ -387,10 +393,7 @@ application_tile_setup (ApplicationTile *this)
gtk_container_add (menu_ctnr, menu_item);
}
priv->gconf_client = gconf_client_get_default ();
priv->gconf_conn_id = gconf_client_notify_add (
priv->gconf_client, SLAB_USER_SPECIFIED_APPS_KEY,
gconf_user_list_change_cb, this, NULL, &error);
priv->user_spec_monitor_handle = libslab_add_apps_monitor (apps_store_monitor_cb, this);
if (error) {
g_warning ("error monitoring %s [%s]\n", SLAB_USER_SPECIFIED_APPS_KEY, error->message);
......@@ -467,80 +470,34 @@ static void
add_to_user_list (ApplicationTile *this)
{
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
GList *tiles;
GSList *app_list;
gchar *loc;
GConfClient *gconf_client;
GError *error;
loc = (gchar *) gnome_desktop_item_get_location (priv->desktop_item);
app_list = get_slab_gconf_slist (SLAB_USER_SPECIFIED_APPS_KEY);
app_list = g_slist_append (app_list, loc);
gconf_client = gconf_client_get_default ();
error = NULL;
gconf_client_set_list (gconf_client, SLAB_USER_SPECIFIED_APPS_KEY, GCONF_VALUE_STRING,
app_list, &error);
tiles = libslab_get_user_app_uris ();
if (! g_list_find_custom (tiles, TILE (this)->uri, (GCompareFunc) libslab_strcmp)) {
tiles = g_list_append (tiles, TILE (this)->uri);
libslab_save_app_uris (tiles);
}
if (error)
g_warning (
"error adding %s to %s [%s]\n",
loc, SLAB_USER_SPECIFIED_APPS_KEY, error->message);
priv->is_in_user_list = FALSE;
priv->is_in_user_list = TRUE;
g_list_free (tiles);
}
static void
remove_from_user_list (ApplicationTile *this)
{
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
GList *tiles;
GSList *app_list;
GSList *new_app_list;
const gchar *loc;
gint offset;
GConfClient *gconf_client;
GError *error;
GSList *node;
app_list = get_slab_gconf_slist (SLAB_USER_SPECIFIED_APPS_KEY);
if (! app_list)
return;
loc = gnome_desktop_item_get_location (priv->desktop_item);
new_app_list = NULL;
for (node = app_list; node; node = node->next) {
offset = strlen (loc) - strlen ((gchar *) node->data);
if (offset < 0)
offset = 0;
if (strcmp (& loc [offset], (gchar *) node->data))
new_app_list = g_slist_append (new_app_list, node->data);
}
gconf_client = gconf_client_get_default ();
error = NULL;
gconf_client_set_list (gconf_client, SLAB_USER_SPECIFIED_APPS_KEY, GCONF_VALUE_STRING,
new_app_list, &error);
if (error)
g_warning (
"error removing %s from %s [%s]\n",
loc, SLAB_USER_SPECIFIED_APPS_KEY, error->message);
tiles = libslab_get_user_app_uris ();
tiles = g_list_remove_link (tiles, g_list_find_custom (tiles, TILE (this)->uri, (GCompareFunc) libslab_strcmp));
libslab_save_app_uris (tiles);
priv->is_in_user_list = FALSE;
g_list_free (tiles);
}
static void
......@@ -742,32 +699,6 @@ application_tile_get_desktop_item (ApplicationTile *tile)
return APPLICATION_TILE_GET_PRIVATE (tile)->desktop_item;
}
static gboolean
is_desktop_item_in_user_list (const gchar *uri)
{
GSList *app_list;
GSList *node;
gint offset;
app_list = get_slab_gconf_slist (SLAB_USER_SPECIFIED_APPS_KEY);
if (! app_list)
return FALSE;
for (node = app_list; node; node = node->next) {
offset = strlen (uri) - strlen ((gchar *) node->data);
if (offset < 0)
offset = 0;
if (! strcmp (& uri [offset], (gchar *) node->data))
return TRUE;
}
return FALSE;
}
static void
update_user_list_menu_item (ApplicationTile *this)
{
......@@ -847,15 +778,17 @@ header_size_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer user_
}
static void
gconf_user_list_change_cb (GConfClient *gconf_client, guint c_id, GConfEntry *entry,
gpointer user_data)
apps_store_monitor_cb (
GnomeVFSMonitorHandle *handle, const gchar *monitor_uri,
const gchar *info_uri, GnomeVFSMonitorEventType type, gpointer user_data)
{
ApplicationTile *this = APPLICATION_TILE (user_data);
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
gboolean is_in_user_list_current;
is_in_user_list_current = is_desktop_item_in_user_list (TILE (this)->uri);
is_in_user_list_current = libslab_user_apps_store_has_uri (TILE (this)->uri);
if (is_in_user_list_current == priv->is_in_user_list)
return;
......
......@@ -56,7 +56,8 @@ typedef struct
GType application_tile_get_type (void);
GtkWidget *application_tile_new (const gchar * desktop_item_id);
GtkWidget *application_tile_new_full (const gchar * desktop_item_id, GtkIconSize icon_size);
GtkWidget *application_tile_new_full (const gchar * desktop_item_id,
GtkIconSize icon_size, gboolean show_generic_name);
GnomeDesktopItem *application_tile_get_desktop_item (ApplicationTile * tile);
......
/*
* This file is part of libtile.
*
* Copyright (c) 2006 Novell, Inc.
*
* Libtile is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* Libtile 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 Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libslab; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "directory-tile.h"
#include <glib/gi18n.h>
#include <string.h>
#include <libgnomeui/gnome-icon-lookup.h>
#include <libgnomevfs/gnome-vfs.h>
#include <unistd.h>
#include "slab-gnome-util.h"
#include "gnome-utils.h"
#include "libslab-utils.h"
#define GCONF_SEND_TO_CMD_KEY "/desktop/gnome/applications/main-menu/file-area/file_send_to_cmd"
#define GCONF_ENABLE_DELETE_KEY_DIR "/apps/nautilus/preferences"
#define GCONF_ENABLE_DELETE_KEY GCONF_ENABLE_DELETE_KEY_DIR "/enable_delete"
G_DEFINE_TYPE (DirectoryTile, directory_tile, NAMEPLATE_TILE_TYPE)
static void directory_tile_finalize (GObject *);
static void directory_tile_style_set (GtkWidget *, GtkStyle *);
static void directory_tile_private_setup (DirectoryTile *);
static void load_image (DirectoryTile *);
static GtkWidget *create_header (const gchar *);
static void header_size_allocate_cb (GtkWidget *, GtkAllocation *, gpointer);
static void open_trigger (Tile *, TileEvent *, TileAction *);
static void rename_trigger (Tile *, TileEvent *, TileAction *);
static void move_to_trash_trigger (Tile *, TileEvent *, TileAction *);
static void delete_trigger (Tile *, TileEvent *, TileAction *);
static void send_to_trigger (Tile *, TileEvent *, TileAction *);
static void rename_entry_activate_cb (GtkEntry *, gpointer);
static gboolean rename_entry_key_release_cb (GtkWidget *, GdkEventKey *, gpointer);
static void gconf_enable_delete_cb (GConfClient *, guint, GConfEntry *, gpointer);
static void disown_spawned_child (gpointer);
typedef struct
{
gchar *basename;
GtkBin *header_bin;
gchar *icon_name;
gboolean renaming;
gboolean image_is_broken;
gboolean delete_enabled;
guint gconf_conn_id;
} DirectoryTilePrivate;
#define DIRECTORY_TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DIRECTORY_TILE_TYPE, DirectoryTilePrivate))
static void directory_tile_class_init (DirectoryTileClass *this_class)
{
GObjectClass *g_obj_class = G_OBJECT_CLASS (this_class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (this_class);
g_obj_class->finalize = directory_tile_finalize;
widget_class->style_set = directory_tile_style_set;
g_type_class_add_private (this_class, sizeof (DirectoryTilePrivate));
}
GtkWidget *
directory_tile_new (const gchar *in_uri, const gchar *title, const gchar *icon_name)
{
DirectoryTile *this;
DirectoryTilePrivate *priv;
gchar *uri;
GtkWidget *image;
GtkWidget *header;
GtkMenu *context_menu;
GtkContainer *menu_ctnr;
GtkWidget *menu_item;
TileAction *action;
gchar *basename;
gchar *markup;
AtkObject *accessible;
gchar *filename;
gchar *tooltip_text;
uri = g_strdup (in_uri);
image = gtk_image_new ();
if (! title) {
markup = g_path_get_basename (uri);
basename = gnome_vfs_unescape_string (markup, NULL);
g_free (markup);
}
else
basename = g_strdup (title);
header = create_header (basename);
filename = g_filename_from_uri (uri, NULL, NULL);
if (filename)
tooltip_text = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
else
tooltip_text = NULL;
g_free (filename);
context_menu = GTK_MENU (gtk_menu_new ());
this = g_object_new (
DIRECTORY_TILE_TYPE,
"tile-uri", uri,
"nameplate-image", image,
"nameplate-header", header,
"nameplate-tooltip", tooltip_text,
"context-menu", context_menu,
NULL);
g_free (uri);
priv = DIRECTORY_TILE_GET_PRIVATE (this);
priv->basename = g_strdup (basename);
priv->header_bin = GTK_BIN (header);
priv->icon_name = g_strdup (icon_name);
directory_tile_private_setup (this);
TILE (this)->actions = g_new0 (TileAction *, 6);
TILE (this)->n_actions = 6;
menu_ctnr = GTK_CONTAINER (TILE (this)->context_menu);
/* make open with default action */
markup = g_markup_printf_escaped (_("<b>Open</b>"));
action = tile_action_new (TILE (this), open_trigger, markup, TILE_ACTION_OPENS_NEW_WINDOW);
g_free (markup);
TILE (this)->default_action = action;
menu_item = GTK_WIDGET (GTK_WIDGET (tile_action_get_menu_item (action)));
TILE (this)->actions [DIRECTORY_TILE_ACTION_OPEN] = action;
gtk_container_add (menu_ctnr, menu_item);
/* insert separator */
menu_item = gtk_separator_menu_item_new ();
gtk_container_add (menu_ctnr, menu_item);
/* make rename action */
action = tile_action_new (TILE (this), rename_trigger, _("Rename..."), 0);
TILE (this)->actions[DIRECTORY_TILE_ACTION_RENAME] = action;
menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
gtk_container_add (menu_ctnr, menu_item);
/* insert separator */
menu_item = gtk_separator_menu_item_new ();
gtk_container_add (menu_ctnr, menu_item);
/* make move to trash action */
action = tile_action_new (TILE (this), move_to_trash_trigger, _("Move to Trash"), 0);
TILE (this)->actions[DIRECTORY_TILE_ACTION_MOVE_TO_TRASH] = action;
menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
gtk_container_add (menu_ctnr, menu_item);
/* make delete action */
if (priv->delete_enabled)
{
action = tile_action_new (TILE (this), delete_trigger, _("Delete"), 0);
TILE (this)->actions[DIRECTORY_TILE_ACTION_DELETE] = action;
menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
gtk_container_add (menu_ctnr, menu_item);
}
/* insert separator */
menu_item = gtk_separator_menu_item_new ();
gtk_container_add (menu_ctnr, menu_item);
/* make send to action */
/* Only allow Send To for local files, ideally this would use something
* equivalent to gnome_vfs_uri_is_local, but that method will stat the file and
* that can hang in some conditions. */
if (!strncmp (TILE (this)->uri, "file://", 7))
{
action = tile_action_new (TILE (this), send_to_trigger, _("Send To..."),
TILE_ACTION_OPENS_NEW_WINDOW);
menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
}
else
{
action = NULL;
menu_item = gtk_menu_item_new_with_label (_("Send To..."));
gtk_widget_set_sensitive (menu_item, FALSE);
}
TILE (this)->actions[DIRECTORY_TILE_ACTION_SEND_TO] = action;
gtk_container_add (menu_ctnr, menu_item);
gtk_widget_show_all (GTK_WIDGET (TILE (this)->context_menu));
load_image (this);
accessible = gtk_widget_get_accessible (GTK_WIDGET (this));
if (basename)
atk_object_set_name (accessible, basename);
g_free (basename);
return GTK_WIDGET (this);
}
static void
directory_tile_private_setup (DirectoryTile *tile)
{
DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
GConfClient *client;
priv->renaming = FALSE;
priv->delete_enabled =
(gboolean) GPOINTER_TO_INT (get_gconf_value (GCONF_ENABLE_DELETE_KEY));
client = gconf_client_get_default ();
gconf_client_add_dir (client, GCONF_ENABLE_DELETE_KEY_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL);
priv->gconf_conn_id =
connect_gconf_notify (GCONF_ENABLE_DELETE_KEY, gconf_enable_delete_cb, tile);
g_object_unref (client);
}
static void
directory_tile_init (DirectoryTile *tile)
{
DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
priv->basename = NULL;
priv->header_bin = NULL;
priv->icon_name = NULL;
priv->renaming = FALSE;
priv->image_is_broken = TRUE;
priv->delete_enabled = FALSE;
priv->gconf_conn_id = 0;
}
static void
directory_tile_finalize (GObject *g_object)
{
DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (g_object);
GConfClient *client;
g_free (priv->basename);
g_free (priv->icon_name);
client = gconf_client_get_default ();
gconf_client_notify_remove (client, priv->gconf_conn_id);
gconf_client_remove_dir (client, GCONF_ENABLE_DELETE_KEY_DIR, NULL);
g_object_unref (client);
(* G_OBJECT_CLASS (directory_tile_parent_class)->finalize) (g_object);
}
static void
directory_tile_style_set (GtkWidget *widget, GtkStyle *prev_style)
{
load_image (DIRECTORY_TILE (widget));
}
static void
load_image (DirectoryTile *tile)
{
DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
gchar *icon_name;
if (priv->icon_name)
icon_name = priv->icon_name;
else
icon_name = "gnome-fs-directory";
priv->image_is_broken = slab_load_image (
GTK_IMAGE (NAMEPLATE_TILE (tile)->image), GTK_ICON_SIZE_DND, icon_name);
}
static GtkWidget *
create_header (const gchar *name)
{
GtkWidget *header_bin;
GtkWidget *header;
header = gtk_label_new (name);
gtk_label_set_ellipsize (GTK_LABEL (header), PANGO_ELLIPSIZE_END);
gtk_misc_set_alignment (GTK_MISC (header), 0.0, 0.5);
header_bin = gtk_alignment_new (0.0, 0.5, 1.0, 0.0);
gtk_container_add (GTK_CONTAINER (header_bin), header);
g_signal_connect (G_OBJECT (header), "size-allocate", G_CALLBACK (header_size_allocate_cb),
NULL);
return header_bin;
}
static void
header_size_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer user_data)
{
gtk_widget_set_size_request (widget, alloc->width, -1);
}
static void
rename_entry_activate_cb (GtkEntry *entry, gpointer user_data)
{
DirectoryTile *tile = DIRECTORY_TILE (user_data);
DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
GnomeVFSURI *src_uri;
GnomeVFSURI *dst_uri;
gchar *dirname;
gchar *dst_path;
gchar *dst_uri_str;
GtkWidget *child;
GtkWidget *header;
GnomeVFSResult retval;
if (strlen (gtk_entry_get_text (entry)) < 1)
return;
src_uri = gnome_vfs_uri_new (TILE (tile)->uri);
dirname = gnome_vfs_uri_extract_dirname (src_uri);
dst_path = g_build_filename (dirname, gtk_entry_get_text (entry), NULL);
dst_uri = gnome_vfs_uri_new (dst_path);
retval = gnome_vfs_xfer_uri (src_uri, dst_uri, GNOME_VFS_XFER_REMOVESOURCE,
GNOME_VFS_XFER_ERROR_MODE_ABORT, GNOME_VFS_XFER_OVERWRITE_MODE_SKIP, NULL, NULL);
dst_uri_str = gnome_vfs_uri_to_string (dst_uri, GNOME_VFS_URI_HIDE_NONE);
if (retval == GNOME_VFS_OK) {
g_free (priv->basename);
priv->basename = g_strdup (gtk_entry_get_text (entry));
}
else
g_warning ("unable to move [%s] to [%s]\n", TILE (tile)->uri, dst_uri_str);
header = gtk_label_new (priv->basename);
gtk_misc_set_alignment (GTK_MISC (header), 0.0, 0.5);
child = gtk_bin_get_child (priv->header_bin);
if (child)
gtk_widget_destroy (child);
gtk_