Commit 1e4a571e authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

init the hyperlink to NULL. (mstyle_set_hlink) : relax restrictions.


2002-09-02  Jody Goldberg <jody@gnome.org>

	* src/mstyle.c (mstyle_new_default) : init the hyperlink to NULL.
	(mstyle_set_hlink) : relax restrictions.

	* src/sheet-control-gui.c (scg_context_menu) : implement the
	  conditions on the hyperlink context menu items.

	* src/sheet-style.c (sheet_style_region_contains_link) : new.
	(cb_find_link) : new.
parent f802ab92
2002-09-02 Jody Goldberg <jody@gnome.org>
* src/mstyle.c (mstyle_new_default) : init the hyperlink to NULL.
(mstyle_set_hlink) : relax restrictions.
* src/sheet-control-gui.c (scg_context_menu) : implement the
conditions on the hyperlink context menu items.
* src/sheet-style.c (sheet_style_region_contains_link) : new.
(cb_find_link) : new.
2002-09-02 Jody Goldberg <jody@gnome.org>
* src/gui-util.c (gnumeric_load_pixbuf) : new.
......
2002-09-02 Jody Goldberg <jody@gnome.org>
* src/mstyle.c (mstyle_new_default) : init the hyperlink to NULL.
(mstyle_set_hlink) : relax restrictions.
* src/sheet-control-gui.c (scg_context_menu) : implement the
conditions on the hyperlink context menu items.
* src/sheet-style.c (sheet_style_region_contains_link) : new.
(cb_find_link) : new.
2002-09-02 Jody Goldberg <jody@gnome.org>
* src/gui-util.c (gnumeric_load_pixbuf) : new.
......
2002-09-02 Jody Goldberg <jody@gnome.org>
* src/mstyle.c (mstyle_new_default) : init the hyperlink to NULL.
(mstyle_set_hlink) : relax restrictions.
* src/sheet-control-gui.c (scg_context_menu) : implement the
conditions on the hyperlink context menu items.
* src/sheet-style.c (sheet_style_region_contains_link) : new.
(cb_find_link) : new.
2002-09-02 Jody Goldberg <jody@gnome.org>
* src/gui-util.c (gnumeric_load_pixbuf) : new.
......
......@@ -65,8 +65,7 @@ GnmHLink *
sheet_hlink_find (Sheet const *sheet, CellPos const *pos)
{
MStyle const *style = sheet_style_get (sheet, pos->col, pos->row);
return mstyle_is_element_set (style, MSTYLE_HLINK)
? mstyle_get_hlink (style) : NULL;
return mstyle_get_hlink (style);
}
static void
......
......@@ -598,6 +598,8 @@ mstyle_new_default (void)
mstyle_set_font_uline (mstyle, UNDERLINE_NONE);
mstyle_set_font_strike (mstyle, FALSE);
mstyle_set_hlink (mstyle, NULL);
mstyle_set_color (mstyle, MSTYLE_COLOR_FORE,
style_color_black ());
mstyle_set_color (mstyle, MSTYLE_COLOR_BACK,
......@@ -1417,7 +1419,6 @@ void
mstyle_set_hlink (MStyle *style, GnmHLink *link)
{
g_return_if_fail (style != NULL);
g_return_if_fail (link != NULL);
mstyle_element_unref (style->elements[MSTYLE_HLINK]);
style->elements[MSTYLE_HLINK].type = MSTYLE_HLINK;
......
......@@ -23,6 +23,7 @@
#include "cell.h"
#include "selection.h"
#include "style.h"
#include "sheet-style.h"
#include "sheet-object-impl.h"
#include "sheet-object-cell-comment.h"
#include "gui-util.h"
......@@ -1303,7 +1304,10 @@ enum {
CONTEXT_ROW_HEIGHT,
CONTEXT_ROW_HIDE,
CONTEXT_ROW_UNHIDE,
CONTEXT_COMMENT_EDIT
CONTEXT_COMMENT_EDIT,
CONTEXT_HYPERLINK_ADD,
CONTEXT_HYPERLINK_EDIT,
CONTEXT_HYPERLINK_REMOVE
};
static gboolean
context_menu_handler (GnumericPopupMenuElement const *element,
......@@ -1368,6 +1372,9 @@ context_menu_handler (GnumericPopupMenuElement const *element,
case CONTEXT_COMMENT_EDIT:
dialog_cell_comment (wbcg, sheet, &sv->edit_pos);
break;
case CONTEXT_HYPERLINK_ADD:
case CONTEXT_HYPERLINK_EDIT:
case CONTEXT_HYPERLINK_REMOVE:
default :
break;
};
......@@ -1378,19 +1385,20 @@ void
scg_context_menu (SheetControlGUI *scg, GdkEventButton *event,
gboolean is_col, gboolean is_row)
{
SheetControl *sc = (SheetControl *) scg;
SheetControl *sc = SHEET_CONTROL (scg);
Sheet *sheet = sc_sheet (sc);
enum {
CONTEXT_DISPLAY_FOR_CELLS = 1,
CONTEXT_DISPLAY_FOR_ROWS = 2,
CONTEXT_DISPLAY_FOR_COLS = 4
CONTEXT_DISPLAY_FOR_COLS = 4,
CONTEXT_DISPLAY_WITH_HYPERLINK = 8,
CONTEXT_DISPLAY_WITHOUT_HYPERLINK = 16
};
enum {
CONTEXT_DISABLE_PASTE_SPECIAL = 1,
CONTEXT_DISABLE_FOR_ROWS = 2,
CONTEXT_DISABLE_FOR_COLS = 4,
CONTEXT_DISABLE_WITH_HYPERLINK = 8,
CONTEXT_DISABLE_WITHOUT_HYPERLINK = 16
CONTEXT_DISABLE_FOR_COLS = 4
};
static GnumericPopupMenuElement const popup_elements[] = {
......@@ -1453,17 +1461,20 @@ scg_context_menu (SheetControlGUI *scg, GdkEventButton *event,
CONTEXT_DISPLAY_FOR_ROWS, 0, CONTEXT_ROW_UNHIDE },
{ N_("_Hyperlink"), NULL,
CONTEXT_DISPLAY_FOR_CELLS, 0, CONTEXT_DISABLE_WITH_HYPERLINK },
CONTEXT_DISPLAY_WITHOUT_HYPERLINK, 0,
CONTEXT_HYPERLINK_ADD },
{ N_("Edit _Hyperlink"), NULL,
CONTEXT_DISPLAY_FOR_CELLS, 0, CONTEXT_DISABLE_WITHOUT_HYPERLINK },
{ N_("_Remove _Hyperlink"), NULL,
CONTEXT_DISPLAY_FOR_CELLS, 0, CONTEXT_DISABLE_WITHOUT_HYPERLINK },
CONTEXT_DISPLAY_WITH_HYPERLINK, 0,
CONTEXT_HYPERLINK_EDIT },
{ N_("_Remove Hyperlink"), NULL,
CONTEXT_DISPLAY_WITH_HYPERLINK, 0,
CONTEXT_HYPERLINK_REMOVE },
{ NULL, NULL, 0, 0, 0 },
};
/* row and column specific operations */
int const display_filter =
int display_filter =
((!is_col && !is_row) ? CONTEXT_DISPLAY_FOR_CELLS : 0) |
(is_col ? CONTEXT_DISPLAY_FOR_COLS : 0) |
(is_row ? CONTEXT_DISPLAY_FOR_ROWS : 0);
......@@ -1477,6 +1488,7 @@ scg_context_menu (SheetControlGUI *scg, GdkEventButton *event,
? 0 : CONTEXT_DISABLE_PASTE_SPECIAL;
GList *l;
gboolean has_link = FALSE;
wbcg_edit_finish (scg->wbcg, FALSE);
......@@ -1493,8 +1505,15 @@ scg_context_menu (SheetControlGUI *scg, GdkEventButton *event,
if (r->start.col == 0 && r->end.col == SHEET_MAX_COLS - 1)
sensitivity_filter |= CONTEXT_DISABLE_FOR_COLS;
if (!has_link && sheet_style_region_contains_link (sheet, r))
has_link = TRUE;
}
if (display_filter & CONTEXT_DISPLAY_FOR_CELLS)
display_filter |= ((has_link) ?
CONTEXT_DISPLAY_WITH_HYPERLINK : CONTEXT_DISPLAY_WITHOUT_HYPERLINK);
gnumeric_create_popup_menu (popup_elements, &context_menu_handler,
scg, display_filter,
sensitivity_filter, event);
......
......@@ -1983,6 +1983,38 @@ sheet_style_most_common_in_col (Sheet const *sheet, int col)
return res.style;
}
static void
cb_find_link (MStyle *style,
int corner_col, int corner_row, int width, int height,
Range const *apply_to, gpointer user)
{
GnmHLink **link = user;
if (*link == NULL)
*link = mstyle_get_hlink (style);
}
/**
* sheet_style_region_contains_link :
* @sheet :
* @r :
*
* Utility routine that checks to see if a region contains at least 1 hyper link
* and returns the 1st one it finds.
**/
GnmHLink *
sheet_style_region_contains_link (Sheet const *sheet, Range const *r)
{
GnmHLink *res = NULL;
g_return_val_if_fail (IS_SHEET (sheet), NULL);
g_return_val_if_fail (r != NULL, NULL);
foreach_tile (sheet->style_data->styles,
TILE_TOP_LEVEL, 0, 0, r,
cb_find_link, &res);
return res;
}
void
sheet_style_foreach (Sheet const *sheet, GHFunc func, gpointer user_data)
{
......
......@@ -39,7 +39,8 @@ void style_row_init (StyleBorder const * * *prev_vert,
StyleRow *sr, StyleRow *next_sr,
int start_col, int end_col,
gpointer mem, gboolean hide_grid);
MStyle *sheet_style_most_common_in_col (Sheet const *sheet, int col);
MStyle *sheet_style_most_common_in_col (Sheet const *sheet, int col);
GnmHLink*sheet_style_region_contains_link (Sheet const *sheet, Range const *r);
void sheet_style_foreach (Sheet const *sheet,
GHFunc func,
gpointer user_data);
......
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