Skip to content

Commit

Permalink
Add copy from clipboard buttons
Browse files Browse the repository at this point in the history
Fix #23
  • Loading branch information
eliemichel committed Aug 29, 2019
1 parent 09f9c82 commit 879f737
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion blender/LilySurfaceScrapper/frontend.py
Expand Up @@ -95,7 +95,18 @@ def execute(self, context):
cb = get_callback(self.callback_handle)
cb(context)
return {'FINISHED'}


class OBJECT_OT_LilyClipboardSurfaceScrapper(PopupOperator, CallbackProps):
"""Same as lily_surface_import except that it gets the URL from clipboard."""
bl_idname = "object.lily_surface_import_from_clipboard"
bl_label = "Import from clipboard"

def invoke(self, context, event):
return self.execute(context)

def execute(self, context):
bpy.ops.object.lily_surface_import('EXEC_DEFAULT', url=bpy.context.window_manager.clipboard)
return {'FINISHED'}

def list_variant_enum(self, context):
"""Callback filling enum items for OBJECT_OT_LilySurfacePromptVariant"""
Expand Down Expand Up @@ -202,6 +213,17 @@ def execute(self, context):
cb(context)
return {'FINISHED'}

class OBJECT_OT_LilyClipboardWorldScrapper(PopupOperator, CallbackProps):
"""Same as lily_world_import except that it gets the URL from clipboard."""
bl_idname = "object.lily_world_import_from_clipboard"
bl_label = "Import from clipboard"

def invoke(self, context, event):
return self.execute(context)

def execute(self, context):
bpy.ops.object.lily_world_import('EXEC_DEFAULT', url=bpy.context.window_manager.clipboard)
return {'FINISHED'}

def list_variant_enum(self, context):
"""Callback filling enum items for OBJECT_OT_LilySurfacePromptVariant"""
Expand Down Expand Up @@ -271,6 +293,7 @@ def draw(self, context):
layout.label(text="You must save the file to use Lily Surface Scrapper")
else:
layout.operator("object.lily_surface_import")
layout.operator("object.lily_surface_import_from_clipboard")
layout.label(text="Available sources:")
for S in ScrappersManager.getScrappersList():
if 'MATERIAL' in S.scrapped_type:
Expand All @@ -290,6 +313,7 @@ def draw(self, context):
layout.label(text="You must save the file to use Lily Surface Scrapper")
else:
layout.operator("object.lily_world_import")
layout.operator("object.lily_world_import_from_clipboard")
layout.label(text="Available sources:")
for S in ScrappersManager.getScrappersList():
if 'WORLD' in S.scrapped_type:
Expand All @@ -299,16 +323,20 @@ def draw(self, context):

def register():
bpy.utils.register_class(OBJECT_OT_LilySurfaceScrapper)
bpy.utils.register_class(OBJECT_OT_LilyClipboardSurfaceScrapper)
bpy.utils.register_class(OBJECT_OT_LilySurfacePromptVariant)
bpy.utils.register_class(OBJECT_OT_LilyWorldScrapper)
bpy.utils.register_class(OBJECT_OT_LilyClipboardWorldScrapper)
bpy.utils.register_class(OBJECT_OT_LilyWorldPromptVariant)
bpy.utils.register_class(MATERIAL_PT_LilySurfaceScrapper)
bpy.utils.register_class(WORLD_PT_LilySurfaceScrapper)

def unregister():
bpy.utils.unregister_class(OBJECT_OT_LilySurfaceScrapper)
bpy.utils.unregister_class(OBJECT_OT_LilyClipboardSurfaceScrapper)
bpy.utils.unregister_class(OBJECT_OT_LilySurfacePromptVariant)
bpy.utils.unregister_class(OBJECT_OT_LilyWorldScrapper)
bpy.utils.unregister_class(OBJECT_OT_LilyClipboardWorldScrapper)
bpy.utils.unregister_class(OBJECT_OT_LilyWorldPromptVariant)
bpy.utils.unregister_class(MATERIAL_PT_LilySurfaceScrapper)
bpy.utils.unregister_class(WORLD_PT_LilySurfaceScrapper)

0 comments on commit 879f737

Please sign in to comment.