Commit b403d838 authored by Benedikt Meurer's avatar Benedikt Meurer

2006-08-12 Benedikt Meurer <benny@xfce.org>

	* thunar/thunar-history-action.{c,h}, thunar/thunar-history.c,
	  thunar/Makefile.am: Add "back" and "forward" menus to the history
	  support module. Bug #1782.
	* thunar/thunar-create-dialog.c, thunar/thunar-standard-view.c,
	  thunar/thunar-stock.{c,h}: We don't really need stock items for
	  create and rename. Instead use labels with mnemonics.
	* po/Thunar.pot, po/*.po: Merge new strings.
	* po/de.po: Update german translations.




(Old svn revision: 22732)
parent e0706997
2006-08-12 Benedikt Meurer <benny@xfce.org>
* thunar/thunar-history-action.{c,h}, thunar/thunar-history.c,
thunar/Makefile.am: Add "back" and "forward" menus to the history
support module. Bug #1782.
* thunar/thunar-create-dialog.c, thunar/thunar-standard-view.c,
thunar/thunar-stock.{c,h}: We don't really need stock items for
create and rename. Instead use labels with mnemonics.
* po/Thunar.pot, po/*.po: Merge new strings.
* po/de.po: Update german translations.
2006-08-11 Benedikt Meurer <benny@xfce.org>
* thunar/Makefile.am: Fix typo.
......
2006-08-12 Benedikt Meurer <benny@xfce.org>
* Thunar.pot, *.po: Merge new strings.
* de.po: Update german translations.
2006-08-12 Hydonsingore Cia <hydonsingore@educities.edu.tw>
* zh_TW.po: Update traditional Chinese translations.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -78,6 +78,8 @@ Thunar_SOURCES = \
thunar-gobject-extensions.h \
thunar-gtk-extensions.c \
thunar-gtk-extensions.h \
thunar-history-action.c \
thunar-history-action.h \
thunar-history.c \
thunar-history.h \
thunar-ice.c \
......
......@@ -163,7 +163,7 @@ thunar_create_dialog_init (ThunarCreateDialog *dialog)
/* configure the dialog itself */
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
THUNAR_STOCK_CREATE, GTK_RESPONSE_OK,
_("C_reate"), GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
......
/* $Id$ */
/*-
* Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>
*
* 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 <thunar/thunar-history-action.h>
#include <thunar/thunar-private.h>
static void thunar_history_action_class_init (ThunarHistoryActionClass *klass);
static GtkWidget *thunar_history_action_create_tool_item (GtkAction *action);
static void thunar_history_action_show_menu (GtkWidget *tool_item,
ThunarHistoryAction *history_action);
struct _ThunarHistoryActionClass
{
GtkActionClass __parent__;
};
struct _ThunarHistoryAction
{
GtkAction __parent__;
};
GType
thunar_history_action_get_type (void)
{
static GType type = G_TYPE_INVALID;
if (G_UNLIKELY (type == G_TYPE_INVALID))
{
static const GTypeInfo info =
{
sizeof (ThunarHistoryActionClass),
NULL,
NULL,
(GClassInitFunc) thunar_history_action_class_init,
NULL,
NULL,
sizeof (ThunarHistoryAction),
0,
NULL,
NULL,
};
type = g_type_register_static (GTK_TYPE_ACTION, I_("ThunarHistoryAction"), &info, 0);
}
return type;
}
static void
thunar_history_action_class_init (ThunarHistoryActionClass *klass)
{
GtkActionClass *gtkaction_class;
gtkaction_class = GTK_ACTION_CLASS (klass);
gtkaction_class->create_tool_item = thunar_history_action_create_tool_item;
/**
* ThunarHistoryAction::show-menu:
* @history_action : a #ThunarHistoryAction.
* @menu : the #GtkMenu to which to add the items to display.
*
* Emitted by the @history_action right before the @menu is shown.
**/
g_signal_new (I_("show-menu"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, GTK_TYPE_MENU);
}
static GtkWidget*
thunar_history_action_create_tool_item (GtkAction *action)
{
GtkWidget *tool_item;
_thunar_return_val_if_fail (THUNAR_IS_HISTORY_ACTION (action), NULL);
/* allocate the tool item with an empty menu */
tool_item = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON,
"menu", gtk_menu_new (),
NULL);
/* be sure to be informed before the menu is shown */
g_signal_connect (G_OBJECT (tool_item), "show-menu", G_CALLBACK (thunar_history_action_show_menu), action);
return tool_item;
}
static void
thunar_history_action_show_menu (GtkWidget *tool_item,
ThunarHistoryAction *history_action)
{
GtkWidget *menu;
_thunar_return_if_fail (GTK_IS_MENU_TOOL_BUTTON (tool_item));
_thunar_return_if_fail (THUNAR_IS_HISTORY_ACTION (history_action));
/* allocate a new menu for the action */
menu = gtk_menu_new ();
/* setup the appropriate screen for the menu */
gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (tool_item));
/* generate the menu items */
g_signal_emit_by_name (G_OBJECT (history_action), "show-menu", menu);
/* setup the menu for the tool item */
gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (tool_item), menu);
}
/**
* thunar_history_action_new:
* @name : the name for the action.
* @label : the label for the action.
* @tooltip : the tooltip for the action.
* @stock_id : the stock-id for the action.
*
* Allocates a new #ThunarHistoryAction with the specified
* parameters.
*
* Return value: the newly allocated #ThunarHistoryAction.
**/
GtkAction*
thunar_history_action_new (const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *stock_id)
{
_thunar_return_val_if_fail (name != NULL, NULL);
return g_object_new (THUNAR_TYPE_HISTORY_ACTION,
"name", name,
"label", label,
"tooltip", tooltip,
"stock-id", stock_id,
NULL);
}
/* $Id$ */
/*-
* Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>
*
* 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
*/
#ifndef __THUNAR_HISTORY_ACTION_H__
#define __THUNAR_HISTORY_ACTION_H__
#include <exo/exo.h>
G_BEGIN_DECLS;
typedef struct _ThunarHistoryActionClass ThunarHistoryActionClass;
typedef struct _ThunarHistoryAction ThunarHistoryAction;
#define THUNAR_TYPE_HISTORY_ACTION (thunar_history_action_get_type ())
#define THUNAR_HISTORY_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNAR_TYPE_HISTORY_ACTION, ThunarHistoryAction))
#define THUNAR_HISTORY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), THUNAR_TYPE_HISTORY_ACTION, ThunarHistoryActionClass))
#define THUNAR_IS_HISTORY_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNAR_TYPE_HISTORY_ACTION))
#define THUNAR_IS_HISTORY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_HISTORY_ACTION))
#define THUNAR_HISTORY_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_HISTORY_ACTION, ThunarHistoryActionClass))
GType thunar_history_action_get_type (void) G_GNUC_CONST;
GtkAction *thunar_history_action_new (const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *stock_id) G_GNUC_MALLOC;
G_END_DECLS;
#endif /* !__THUNAR_HISTORY_ACTION_H__ */
......@@ -22,7 +22,9 @@
#endif
#include <thunar/thunar-gobject-extensions.h>
#include <thunar/thunar-history-action.h>
#include <thunar/thunar-history.h>
#include <thunar/thunar-icon-factory.h>
#include <thunar/thunar-navigator.h>
#include <thunar/thunar-private.h>
......@@ -54,10 +56,21 @@ static void thunar_history_set_property (GObject
static ThunarFile *thunar_history_get_current_directory (ThunarNavigator *navigator);
static void thunar_history_set_current_directory (ThunarNavigator *navigator,
ThunarFile *current_directory);
static void thunar_history_go_back (ThunarHistory *history,
guint n);
static void thunar_history_go_forward (ThunarHistory *history,
guint n);
static void thunar_history_action_back (GtkAction *action,
ThunarHistory *history);
static void thunar_history_action_back_nth (GtkWidget *item,
ThunarHistory *history);
static void thunar_history_action_forward (GtkAction *action,
ThunarHistory *history);
static void thunar_history_action_forward_nth (GtkWidget *item,
ThunarHistory *history);
static void thunar_history_show_menu (GtkAction *action,
GtkWidget *menu,
ThunarHistory *history);
......@@ -177,13 +190,15 @@ static void
thunar_history_init (ThunarHistory *history)
{
/* create the "back" action */
history->action_back = gtk_action_new ("back", _("Back"), _("Go to the previous visited folder"), GTK_STOCK_GO_BACK);
history->action_back = thunar_history_action_new ("back", _("Back"), _("Go to the previous visited folder"), GTK_STOCK_GO_BACK);
g_signal_connect (G_OBJECT (history->action_back), "activate", G_CALLBACK (thunar_history_action_back), history);
g_signal_connect (G_OBJECT (history->action_back), "show-menu", G_CALLBACK (thunar_history_show_menu), history);
gtk_action_set_sensitive (history->action_back, FALSE);
/* create the "forward" action */
history->action_forward = gtk_action_new ("forward", _("Forward"), _("Go to the next visited folder"), GTK_STOCK_GO_FORWARD);
history->action_forward = thunar_history_action_new ("forward", _("Forward"), _("Go to the next visited folder"), GTK_STOCK_GO_FORWARD);
g_signal_connect (G_OBJECT (history->action_forward), "activate", G_CALLBACK (thunar_history_action_forward), history);
g_signal_connect (G_OBJECT (history->action_forward), "show-menu", G_CALLBACK (thunar_history_show_menu), history);
gtk_action_set_sensitive (history->action_forward, FALSE);
}
......@@ -211,11 +226,11 @@ thunar_history_finalize (GObject *object)
ThunarHistory *history = THUNAR_HISTORY (object);
/* disconnect from the "forward" action */
g_signal_handlers_disconnect_by_func (G_OBJECT (history->action_forward), thunar_history_action_forward, history);
g_signal_handlers_disconnect_matched (G_OBJECT (history->action_forward), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, history);
g_object_unref (G_OBJECT (history->action_forward));
/* disconnect from the "back" action */
g_signal_handlers_disconnect_by_func (G_OBJECT (history->action_back), thunar_history_action_back, history);
g_signal_handlers_disconnect_matched (G_OBJECT (history->action_back), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, history);
g_object_unref (G_OBJECT (history->action_back));
/* release the "forward" and "back" lists */
......@@ -282,8 +297,7 @@ thunar_history_set_property (GObject *object,
static ThunarFile*
thunar_history_get_current_directory (ThunarNavigator *navigator)
{
ThunarHistory *history = THUNAR_HISTORY (navigator);
return history->current_directory;
return THUNAR_HISTORY (navigator)->current_directory;
}
......@@ -304,11 +318,13 @@ thunar_history_set_current_directory (ThunarNavigator *navigator,
*/
if (history->back_list != NULL && history->back_list->data == current_directory)
{
thunar_history_action_back (history->action_back, history);
/* go back one step */
thunar_history_go_back (history, 1);
}
else if (history->forward_list != NULL && history->forward_list->data == current_directory)
{
thunar_history_action_forward (history->action_forward, history);
/* go forward one step */
thunar_history_go_forward (history, 1);
}
else
{
......@@ -339,32 +355,90 @@ thunar_history_set_current_directory (ThunarNavigator *navigator,
static void
thunar_history_action_back (GtkAction *action,
ThunarHistory *history)
thunar_history_go_back (ThunarHistory *history,
guint n)
{
_thunar_return_if_fail (GTK_IS_ACTION (action));
_thunar_return_if_fail (THUNAR_IS_HISTORY (history));
_thunar_return_if_fail (n > 0);
/* make sure the "back" list isn't empty */
if (G_UNLIKELY (history->back_list == NULL))
return;
/* go back up to n steps */
for (; n > 0 && history->back_list != NULL; --n)
{
/* prepend the previous current directory to the "forward" list */
if (G_LIKELY (history->current_directory != NULL))
history->forward_list = g_list_prepend (history->forward_list, history->current_directory);
/* prepend the previous current directory to the "forward" list */
/* remove the first directory from the "back" list and make it the current directory */
history->current_directory = history->back_list->data;
history->back_list = g_list_delete_link (history->back_list, history->back_list);
}
/* tell the other modules to change the current directory */
if (G_LIKELY (history->current_directory != NULL))
thunar_navigator_change_directory (THUNAR_NAVIGATOR (history), history->current_directory);
/* update the sensitivity of the actions */
gtk_action_set_sensitive (history->action_back, (history->back_list != NULL));
gtk_action_set_sensitive (history->action_forward, (history->forward_list != NULL));
}
static void
thunar_history_go_forward (ThunarHistory *history,
guint n)
{
_thunar_return_if_fail (THUNAR_IS_HISTORY (history));
_thunar_return_if_fail (n > 0);
/* go forward up to n steps */
for (; n > 0 && history->forward_list != NULL; --n)
{
history->forward_list = g_list_prepend (history->forward_list, history->current_directory);
gtk_action_set_sensitive (history->action_forward, TRUE);
/* prepend the previous current directory to the "back" list */
if (G_LIKELY (history->current_directory != NULL))
history->back_list = g_list_prepend (history->back_list, history->current_directory);
/* remove the first directory from the "forward" list and make it the current directory */
history->current_directory = history->forward_list->data;
history->forward_list = g_list_delete_link (history->forward_list, history->forward_list);
}
/* remove the first directory from the "back" list
* and make it the current directory.
*/
history->current_directory = history->back_list->data;
history->back_list = g_list_delete_link (history->back_list, history->back_list);
/* tell the other modules to change the current directory */
if (G_LIKELY (history->current_directory != NULL))
thunar_navigator_change_directory (THUNAR_NAVIGATOR (history), history->current_directory);
/* update the sensitivity of the actions */
gtk_action_set_sensitive (history->action_back, (history->back_list != NULL));
gtk_action_set_sensitive (history->action_forward, (history->forward_list != NULL));
}
/* tell the other modules to change the current directory */
thunar_navigator_change_directory (THUNAR_NAVIGATOR (history), history->current_directory);
static void
thunar_history_action_back (GtkAction *action,
ThunarHistory *history)
{
_thunar_return_if_fail (GTK_IS_ACTION (action));
_thunar_return_if_fail (THUNAR_IS_HISTORY (history));
/* go back one step */
thunar_history_go_back (history, 1);
}
static void
thunar_history_action_back_nth (GtkWidget *item,
ThunarHistory *history)
{
guint n;
_thunar_return_if_fail (GTK_IS_MENU_ITEM (item));
_thunar_return_if_fail (THUNAR_IS_HISTORY (history));
n = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (item), "thunar-history-index"));
if (G_LIKELY (n > 0))
thunar_history_go_back (history, n);
}
......@@ -376,26 +450,88 @@ thunar_history_action_forward (GtkAction *action,
_thunar_return_if_fail (GTK_IS_ACTION (action));
_thunar_return_if_fail (THUNAR_IS_HISTORY (history));
/* make sure the "forward" list isn't empty */
if (G_UNLIKELY (history->forward_list == NULL))
return;
/* go forward one step */
thunar_history_go_forward (history, 1);
}
/* prepend the previous current directory to the "back" list */
if (G_LIKELY (history->current_directory != NULL))
static void
thunar_history_action_forward_nth (GtkWidget *item,
ThunarHistory *history)
{
guint n;
_thunar_return_if_fail (GTK_IS_MENU_ITEM (item));
_thunar_return_if_fail (THUNAR_IS_HISTORY (history));
n = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (item), "thunar-history-index"));
if (G_LIKELY (n > 0))
thunar_history_go_forward (history, n);
}
static void
thunar_history_show_menu (GtkAction *action,
GtkWidget *menu,
ThunarHistory *history)
{
ThunarIconFactory *icon_factory;
GtkIconTheme *icon_theme;
GCallback handler;
GtkWidget *image;
GtkWidget *item;
GdkPixbuf *icon;
GList *lp;
guint n;
_thunar_return_if_fail (GTK_IS_ACTION (action));
_thunar_return_if_fail (GTK_IS_MENU_SHELL (menu));
_thunar_return_if_fail (THUNAR_IS_HISTORY (history));
/* determine the icon factory to use to load the icons */
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (menu));
icon_factory = thunar_icon_factory_get_for_icon_theme (icon_theme);
/* check if we have "Back" or "Forward" here */
if (action == history->action_back)
{
/* display the "back" list */
lp = history->back_list;
handler = G_CALLBACK (thunar_history_action_back_nth);
}
else
{
history->back_list = g_list_prepend (history->back_list, history->current_directory);
gtk_action_set_sensitive (history->action_back, TRUE);
/* display the "forward" list */
lp = history->forward_list;
handler = G_CALLBACK (thunar_history_action_forward_nth);
}
/* remove the first directory from the "forward" list
* and make it the current directory.
*/
history->current_directory = history->forward_list->data;
history->forward_list = g_list_delete_link (history->forward_list, history->forward_list);
gtk_action_set_sensitive (history->action_forward, (history->forward_list != NULL));
/* add menu items for all list items */
for (n = 1; lp != NULL; lp = lp->next, ++n)
{
/* load the icon for the file */
icon = thunar_icon_factory_load_file_icon (icon_factory, lp->data, THUNAR_FILE_ICON_STATE_DEFAULT, 16);
/* add an item for this file */
item = gtk_image_menu_item_new_with_label (thunar_file_get_display_name (lp->data));
g_object_set_data (G_OBJECT (item), I_("thunar-history-index"), GUINT_TO_POINTER (n));
g_signal_connect_object (G_OBJECT (item), "activate", handler, history, 0);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* setup the image for the file */
image = gtk_image_new_from_pixbuf (icon);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
/* release the icon */
g_object_unref (G_OBJECT (icon));
}
/* tell the other modules to change the current directory */
thunar_navigator_change_directory (THUNAR_NAVIGATOR (history), history->current_directory);
/* release the icon factory */
g_object_unref (G_OBJECT (icon_factory));
}
......
......@@ -2183,7 +2183,7 @@ thunar_standard_view_action_rename (GtkAction *action,
| GTK_DIALOG_NO_SEPARATOR
| GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
THUNAR_STOCK_RENAME, GTK_RESPONSE_OK,
_("_Rename"), GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1);
......
......@@ -45,19 +45,11 @@ typedef struct
/* keep in sync with thunar-stock.h */
static const ThunarStockIcon thunar_stock_icons[] =
{
{ THUNAR_STOCK_CREATE, "gtk-ok", },
{ THUNAR_STOCK_RENAME, "gtk-ok", },
{ THUNAR_STOCK_DESKTOP, "gnome-fs-desktop", },
{ THUNAR_STOCK_SHORTCUTS, "stock_thunar-shortcuts", },
{ THUNAR_STOCK_TEMPLATES, "stock_thunar-templates", },
};
static const GtkStockItem thunar_stock_items[] =
{
{ THUNAR_STOCK_CREATE, N_ ("Create"), 0, 0, GETTEXT_PACKAGE, },
{ THUNAR_STOCK_RENAME, N_ ("Rename"), 0, 0, GETTEXT_PACKAGE, },
};
/**
......@@ -94,9 +86,6 @@ thunar_stock_init (void)
/* register our icon factory as default */
gtk_icon_factory_add_default (icon_factory);
/* register our stock items */
gtk_stock_add_static (thunar_stock_items, G_N_ELEMENTS (thunar_stock_items));
/* cleanup */
g_object_unref (G_OBJECT (icon_factory));