Commit fd8a5da2 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

Use application_clipboar_unant here. (gnumeric_sheet_key_mode_object):

2000-01-01  Miguel de Icaza  <miguel@gnu.org>

	* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Use
	application_clipboar_unant here.
	(gnumeric_sheet_key_mode_object): ditto.

	* src/sheet.c (sheet_start_editing_at_cursor): ditto.

	* src/workbook-format-toolbar.c (change_selection_font): ditto
	(set_selection_halign): ditto

	* src/application.c (application_clipboard_copy): Use defines.
	(application_clipboard_cut): Use defines.
	(application_clipboard_unant): New function, less agressive
	marking of unanting.

	* src/workbook-view.c (workbook_view_set_paste_state): Use
	named defines instead of arbitrary constants.  Please, no magic
	constants ever in Gnumeric guys.

	* src/application.c:

	* src/workbook-private.h: Move the menu_item fields to
	workbook_private.
parent 18bfab0e
......@@ -48,12 +48,20 @@ application_clipboard_clear (void)
}
if (app.clipboard_sheet != NULL) {
Sheet *sheet = app.clipboard_sheet;
sheet_selection_unant (sheet);
workbook_view_set_paste_state (sheet->workbook, 0);
app.clipboard_sheet = NULL;
}
}
void
application_clipboard_unant (void)
{
if (app.clipboard_sheet != NULL)
sheet_selection_unant (app.clipboard_sheet);
}
/**
* application_clipboard_copy:
*
......@@ -75,7 +83,9 @@ application_clipboard_copy (Sheet *sheet, Range const *area)
area->start.col, area->start.row,
area->end.col, area->end.row);
workbook_view_set_paste_state (sheet->workbook, 2);
workbook_view_set_paste_state (sheet->workbook,
WORKBOOK_VIEW_PASTE_ITEM |
WORKBOOK_VIEW_PASTE_SPECIAL_ITEM);
sheet_selection_ant (sheet);
}
......@@ -99,7 +109,7 @@ application_clipboard_cut (Sheet *sheet, Range const *area)
app.clipboard_cut_range = *area;
/* No paste special for copies */
workbook_view_set_paste_state (sheet->workbook, 1);
workbook_view_set_paste_state (sheet->workbook, WORKBOOK_VIEW_PASTE_SPECIAL_ITEM);
sheet_selection_ant (sheet);
}
......
......@@ -826,7 +826,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
case GDK_Escape:
sheet_cancel_pending_input (sheet);
application_clipboard_clear ();
application_clipboard_unant ();
break;
case GDK_F2:
......@@ -860,7 +860,7 @@ gnumeric_sheet_key_mode_object (GnumericSheet *gsheet, GdkEventKey *event)
switch (event->keyval){
case GDK_Escape:
sheet_set_mode_type (sheet, SHEET_MODE_SHEET);
application_clipboard_clear ();
application_clipboard_unant ();
break;
case GDK_BackSpace:
......
......@@ -826,7 +826,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
case GDK_Escape:
sheet_cancel_pending_input (sheet);
application_clipboard_clear ();
application_clipboard_unant ();
break;
case GDK_F2:
......@@ -860,7 +860,7 @@ gnumeric_sheet_key_mode_object (GnumericSheet *gsheet, GdkEventKey *event)
switch (event->keyval){
case GDK_Escape:
sheet_set_mode_type (sheet, SHEET_MODE_SHEET);
application_clipboard_clear ();
application_clipboard_unant ();
break;
case GDK_BackSpace:
......
......@@ -1420,7 +1420,7 @@ sheet_start_editing_at_cursor (Sheet *sheet, gboolean blankp, gboolean cursorp)
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
application_clipboard_clear ();
application_clipboard_unant ();
if (blankp)
gtk_entry_set_text (GTK_ENTRY (sheet->workbook->ea_input), "");
......
......@@ -42,7 +42,7 @@ set_selection_halign (Workbook *wb, StyleHAlignFlags align)
Sheet *sheet;
sheet = workbook_get_current_sheet (wb);
application_clipboard_clear ();
application_clipboard_unant ();
mstyle = mstyle_new ();
mstyle_set_align_h (mstyle, align);
......@@ -82,7 +82,7 @@ change_selection_font (Workbook *wb, int bold, int italic)
Sheet *sheet;
sheet = workbook_get_current_sheet (wb);
application_clipboard_clear ();
application_clipboard_unant ();
if (bold >= 0) {
mstyle = mstyle_new ();
......
......@@ -57,11 +57,6 @@ struct _Workbook {
#else
GtkObject gtk_object;
/* Menu items that get toggled */
GtkWidget *menu_item_undo;
GtkWidget *menu_item_redo;
GtkWidget *menu_item_paste;
GtkWidget *menu_item_paste_special;
#endif
/* { Start view specific elements */;
......
......@@ -38,6 +38,15 @@ struct _WorkbookPrivate {
* GUI command context
*/
CommandContext *gui_context, *corba_context;
#ifdef ENABLE_BONOBO
#else
/* Menu items that get toggled */
GtkWidget *menu_item_undo;
GtkWidget *menu_item_redo;
GtkWidget *menu_item_paste;
GtkWidget *menu_item_paste_special;
#endif
};
#endif /* GNUMERIC_WORKBOOK_PRIVATE_H */
/*
* workbook-view.c: View functions for the workbook
*
* This is actually broken, as there is no such separation right now
*
* Authors:
* Jody Goldberg
* Miguel de Icaza
*/
#include <config.h>
#include "workbook-view.h"
#include "command-context.h"
#include "command-context-gui.h"
#include "workbook.h"
#include "workbook-private.h"
#include "gnumeric-util.h"
/* enable/disable paste/paste_special
* 0 = both disabled
* 1 = paste enabled
* 2 = both enabled
*/
void
workbook_view_set_paste_state (Workbook *wb, int const state)
workbook_view_set_paste_state (Workbook *wb, int flags)
{
g_return_if_fail (wb != NULL);
g_return_if_fail (state >= 0);
g_return_if_fail (state <= 2);
#ifndef ENABLE_BONOBO
gtk_widget_set_sensitive (wb->menu_item_paste, state > 0);
gtk_widget_set_sensitive (wb->menu_item_paste_special, state > 1);
gtk_widget_set_sensitive (
wb->priv->menu_item_paste,
flags & WORKBOOK_VIEW_PASTE_ITEM);
gtk_widget_set_sensitive (
wb->priv->menu_item_paste_special,
flags & WORKBOOK_VIEW_PASTE_SPECIAL_ITEM);
#else
/* gnome_ui_handler_menu_set_sensitivity (); */
#endif
......@@ -33,8 +40,8 @@ workbook_view_set_undo_redo_state (Workbook const * const wb,
g_return_if_fail (wb != NULL);
#ifndef ENABLE_BONOBO
gtk_widget_set_sensitive (wb->menu_item_undo, has_undos);
gtk_widget_set_sensitive (wb->menu_item_redo, has_redos);
gtk_widget_set_sensitive (wb->priv->menu_item_undo, has_undos);
gtk_widget_set_sensitive (wb->priv->menu_item_redo, has_redos);
#else
/* gnome_ui_handler_menu_set_sensitivity (); */
#endif
......
......@@ -3,14 +3,18 @@
#include "gnumeric.h"
/* Actions on the workbooks UI
#define WORKBOOK_VIEW_PASTE_ITEM (1 << 0)
#define WORKBOOK_VIEW_PASTE_SPECIAL_ITEM (1 << 1)
/*
* Actions on the workbooks UI
*
* These are the embryonic form of signals that will change the
* workbook-view. I amsure that this is the wrong place and interface
* but it is a starting point of the list.
*
*/
void workbook_view_set_paste_state (Workbook *wb, int const state);
void workbook_view_set_paste_state (Workbook *wb, int flags);
void workbook_view_set_undo_redo_state (Workbook const * const wb,
gboolean const has_undos,
......
......@@ -2171,10 +2171,10 @@ workbook_new (void)
/* Get the menu items that will be enabled disabled based on
* workbook state.
*/
wb->menu_item_undo = workbook_menu_edit[0].widget;
wb->menu_item_redo = workbook_menu_edit[1].widget;
wb->menu_item_paste = workbook_menu_edit[5].widget;
wb->menu_item_paste_special = workbook_menu_edit[6].widget;
wb->priv->menu_item_undo = workbook_menu_edit[0].widget;
wb->priv->menu_item_redo = workbook_menu_edit[1].widget;
wb->priv->menu_item_paste = workbook_menu_edit[5].widget;
wb->priv->menu_item_paste_special = workbook_menu_edit[6].widget;
#else
{
GnomeUIHandlerMenuItem *list;
......@@ -2193,8 +2193,10 @@ workbook_new (void)
/* Disable undo/redo for now */
workbook_view_set_undo_redo_state (wb, FALSE, FALSE);
/* Disable paste & paste special, they will be enabled when
* there is something to paste */
/*
* Disable paste & paste special, they will be enabled when
* there is something to paste
*/
workbook_view_set_paste_state (wb, 0);
workbook_create_toolbars (wb);
......
......@@ -57,11 +57,6 @@ struct _Workbook {
#else
GtkObject gtk_object;
/* Menu items that get toggled */
GtkWidget *menu_item_undo;
GtkWidget *menu_item_redo;
GtkWidget *menu_item_paste;
GtkWidget *menu_item_paste_special;
#endif
/* { Start view specific elements */;
......
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