Distinguish a view that can be saved, view source
Looking at the data source determines if there's a way to save the data. The prime use case is having images in tabs. Fixes: https://bugs.launchpad.net/midori/+bug/903499
This commit is contained in:
parent
7e50bb18f8
commit
9a45f8976e
3 changed files with 41 additions and 7 deletions
|
@ -305,9 +305,7 @@ _midori_browser_update_interface (MidoriBrowser* browser)
|
||||||
|
|
||||||
gtk_action_set_visible (_action_by_name (browser, "AddSpeedDial"),
|
gtk_action_set_visible (_action_by_name (browser, "AddSpeedDial"),
|
||||||
!midori_view_is_blank (view));
|
!midori_view_is_blank (view));
|
||||||
/* Currently views that don't support source, don't support
|
_action_set_sensitive (browser, "SaveAs", midori_view_can_save (view));
|
||||||
saving either. If that changes, we need to think of something. */
|
|
||||||
_action_set_sensitive (browser, "SaveAs", midori_view_can_view_source (view));
|
|
||||||
_action_set_sensitive (browser, "Print", midori_view_can_print (view));
|
_action_set_sensitive (browser, "Print", midori_view_can_print (view));
|
||||||
_action_set_sensitive (browser, "ZoomIn", midori_view_can_zoom_in (view));
|
_action_set_sensitive (browser, "ZoomIn", midori_view_can_zoom_in (view));
|
||||||
_action_set_sensitive (browser, "ZoomOut", midori_view_can_zoom_out (view));
|
_action_set_sensitive (browser, "ZoomOut", midori_view_can_zoom_out (view));
|
||||||
|
|
|
@ -2587,10 +2587,6 @@ midori_view_populate_popup (MidoriView* view,
|
||||||
menuitem = sokoke_action_create_popup_menu_item (
|
menuitem = sokoke_action_create_popup_menu_item (
|
||||||
gtk_action_group_get_action (actions, "SaveAs"));
|
gtk_action_group_get_action (actions, "SaveAs"));
|
||||||
gtk_menu_shell_append (menu_shell, menuitem);
|
gtk_menu_shell_append (menu_shell, menuitem);
|
||||||
/* Currently views that don't support source, don't support
|
|
||||||
saving either. If that changes, we need to think of something. */
|
|
||||||
if (!midori_view_can_view_source (view))
|
|
||||||
gtk_widget_set_sensitive (menuitem, FALSE);
|
|
||||||
menuitem = sokoke_action_create_popup_menu_item (
|
menuitem = sokoke_action_create_popup_menu_item (
|
||||||
gtk_action_group_get_action (actions, "SourceView"));
|
gtk_action_group_get_action (actions, "SourceView"));
|
||||||
gtk_menu_shell_append (menu_shell, menuitem);
|
gtk_menu_shell_append (menu_shell, menuitem);
|
||||||
|
@ -4835,6 +4831,43 @@ midori_view_can_view_source (MidoriView* view)
|
||||||
return is_text;
|
return is_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* midori_view_can_save:
|
||||||
|
* @view: a #MidoriView
|
||||||
|
*
|
||||||
|
* Determines if the view can be saved to disk.
|
||||||
|
*
|
||||||
|
* Return value: %TRUE if the website or image can be saved
|
||||||
|
*
|
||||||
|
* Since: 0.4.3
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
midori_view_can_save (MidoriView* view)
|
||||||
|
{
|
||||||
|
GtkWidget* web_view;
|
||||||
|
WebKitWebDataSource *data_source;
|
||||||
|
WebKitWebFrame *frame;
|
||||||
|
const GString *data;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
|
||||||
|
|
||||||
|
if (midori_view_is_blank (view) || view->mime_type == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
web_view = midori_view_get_web_view (view);
|
||||||
|
if (webkit_web_view_get_view_source_mode (WEBKIT_WEB_VIEW (web_view)))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
|
||||||
|
data_source = webkit_web_frame_get_data_source (frame);
|
||||||
|
data = webkit_web_data_source_get_data (data_source);
|
||||||
|
|
||||||
|
if (data != NULL)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
#define can_do(what) \
|
#define can_do(what) \
|
||||||
gboolean \
|
gboolean \
|
||||||
midori_view_can_##what (MidoriView* view) \
|
midori_view_can_##what (MidoriView* view) \
|
||||||
|
|
|
@ -194,6 +194,9 @@ midori_view_print (MidoriView* view);
|
||||||
gboolean
|
gboolean
|
||||||
midori_view_can_view_source (MidoriView* view);
|
midori_view_can_view_source (MidoriView* view);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
midori_view_can_save (MidoriView* view);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
midori_view_can_find (MidoriView* view);
|
midori_view_can_find (MidoriView* view);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue