// Plugin Interface
void
dmz::RenderModulePickBasic::discover_plugin (
      const PluginDiscoverEnum Mode,
      const Plugin *PluginPtr) {

   RenderPick *pick (RenderPick::cast (PluginPtr));

   if (Mode == PluginDiscoverAdd) {

      if (pick) { pick->store_render_module_pick (get_plugin_name (), *this); }
   }
   else if (Mode == PluginDiscoverRemove) {

      if (pick) { pick->remove_render_module_pick (get_plugin_name (), *this); }
   }
}
void
dmz::QtPluginAppUpdater::_slot_handle_downloaded_file () {

    const QString FileName (_downloadFile.fileName ());

#if defined (Q_WS_WIN)
    QString command (tr ("\"%1\"").arg (FileName));
#elif defined (Q_WS_MAC)
    QString command (tr ("hdiutil attach \"%1\" -autoopen -quiet").arg (FileName));
#else
    QString command (tr ("unzip \"%1\"").arg (FileName));
#endif

    if (!FileName.isEmpty ()) {

        _log.info << "Running: " << qPrintable (command) << endl;
        if (QProcess::startDetached (command)) {

            _exit.request_exit (dmz::ExitStatusForced, get_plugin_name () + " Closed");
        }
        else {

            QString msg (tr ("Update has been downloaded to: %1").arg (FileName));
            QMessageBox::information (_updateDialog->parentWidget (), "Update Downloaded", msg);
        }
    }
}
// Plugin Interface
void
dmz::QtPluginIconPalletTool::update_plugin_state (
      const PluginStateEnum State,
      const UInt32 Level) {

   if (State == PluginStateInit) {

   }
   else if (State == PluginStateStart) {

   }
   else if (State == PluginStateStop) {

   }
   else if (State == PluginStateShutdown) {

      RuntimeContext *context (get_plugin_runtime_context ());

      if (context && _useSession) {

         Config session (get_plugin_name ());

         session.add_config (qbytearray_to_config ("geometry", saveGeometry ()));

         session.add_config (
            boolean_to_config ("window", "visible", isVisible () ? True : False));

         set_session_config (context, session);
      }
   }
}
void
dmz::QtPluginIconPalletTool::_init (Config &local) {

   RuntimeContext *context (get_plugin_runtime_context ());

   _showMsg = config_create_message (
      "show.name",
      local,
      "DMZ_Show_Icon_Pallet_Tool",
      context);

   subscribe_to_message (_showMsg);

   _useSession = config_to_boolean ("use-session.value", local, _useSession);

   if (_useSession && context) {

      Config session (get_session_config (get_plugin_name (), context));

      QByteArray geometry (config_to_qbytearray ("geometry", session, saveGeometry ()));
      restoreGeometry (geometry);

      if (config_to_boolean ("window.visible", session, False)) { show (); }
   }

   _ui.iconView->setModel (&_model);

   _add_type (Definitions (context).get_root_object_type ());
}
// QtPluginIconPalletTool Interface
void
dmz::QtPluginIconPalletTool::_add_type (const ObjectType &Type) {

   const String IconResource = config_to_string (
      get_plugin_name () + ".resource",
      Type.get_config());

   const String IconName = _rc.find_file (IconResource);

   if (IconName) {

      const String Name = Type.get_name ();

      if (Name) {

         QImage back (
            (int)_iconExtent,
            (int)_iconExtent,
            QImage::Format_ARGB32_Premultiplied);
         QPainter painter (&back);
         painter.setCompositionMode (QPainter::CompositionMode_Source);
         painter.fillRect (back.rect (), Qt::transparent);
         painter.setCompositionMode (QPainter::CompositionMode_SourceOver);
         QSvgRenderer qsr (QString (IconName.get_buffer ()));
         QRectF size = qsr.viewBoxF ();
         qreal width = size.width ();
         qreal height = size.height ();
         qreal scale = (width > height) ? width : height;
         if (scale <= 0.0f) { scale = 1.0f; }
         scale = _iconExtent / scale;
         width *= scale;
         height *= scale;
         size.setWidth (width);
         size.setHeight (height);
         if (height < _iconExtent) { size.moveTop ((_iconExtent - height) * 0.5f); }
         if (width < _iconExtent) { size.moveLeft ((_iconExtent - width) * 0.5f); }
         qsr.render (&painter, size);
         painter.end ();
         QIcon icon;
         icon.addPixmap (QPixmap::fromImage (back));
         QStandardItem *item = new QStandardItem (icon, Name.get_buffer ());
         item->setEditable (false);
         _model.appendRow (item);
      }
   }
   else if (IconResource) {

      _log.error << "Unable to find icon resource: " << IconResource
          << " for object type: " << Type.get_name () << endl;
   }

   RuntimeIterator it;
   ObjectType next;

   while (Type.get_next_child (it, next)) { _add_type (next); }
}
void
dmz::QtPluginPreferences::_init (Config &local) {
   
   RuntimeContext *context (get_plugin_runtime_context ());
      
   setObjectName (get_plugin_name ().get_buffer ());
   
   qframe_config_read ("frame", local, this);
   
   _mainWindowModuleName = config_to_string (
      "module.mainWindow.name",
      local,
      "dmzQtModuleMainWindowBasic");
      
   _preferencesAction = new QAction (this),

   _preferencesAction->setMenuRole (QAction::PreferencesRole);

   _preferencesAction->setText (
      config_to_string ("preferences-menu.text", local, "&Preferences...").get_buffer ());

   connect (
      _preferencesAction, SIGNAL (triggered ()),
      this, SLOT (show ()));

   _menuName = config_to_string ("edit-menu.text", local, _menuName);
   
   _ui.tabWidget->removeTab (0);
   
   Config widgetList;

   if (local.lookup_all_config ("widget", widgetList)) {

      ConfigIterator it;
      Config widget;

      while (widgetList.get_next_config (it, widget)) {

         const String WidgetName (config_to_string ("name", widget));
         
         if (WidgetName && !_widgetTable.lookup (WidgetName)) {

            WidgetStruct *ws (new WidgetStruct);
            
            if (ws) {
               
               ws->title = config_to_string ("title", widget);
            }

            if (!_widgetTable.store (WidgetName, ws)) { delete ws; ws = 0; }
         }
      }
   }
}
void
dmz::QtPluginAppUpdater::_init (Config &local) {

    setObjectName (get_plugin_name ().get_buffer ());
    RuntimeContext *context (get_plugin_runtime_context ());

    _mainWindowModuleName = config_to_string ("module.mainWindow.name", local);
    _forceUpdate = config_to_boolean ("force-update.value", local, _forceUpdate);
    _downloadToTemp = config_to_boolean ("download-to-temp.value", local, _downloadToTemp);
    _releaseChannel = config_to_string ("release.channel", local, _releaseChannel);

    // _updateUrl = "latest/{system_name}-{release_channel}/{app_name}.xml";
    // _downloadUrl = "downloads/{app_name}-{major}-{minor}-{bug}-{build_number}";

    String host = config_to_string ("update.host", local);
    String path = config_to_string ("update.path", local);

    if (host && path) {

        _updateUrl = host + path;

        host = config_to_string ("download.host", local, host);
        path = config_to_string ("download.path", local);

        if (host && path) {
            _downloadUrl = host + path;
        }
    }

    if (_updateUrl) {
        _log.debug << "Update URL: " << _updateUrl << endl;
    }
    else {
        _log.debug << "Update URL not specified." << endl;
    }

    if (_downloadUrl) {
        _log.debug << "Download URL: " << _downloadUrl << endl;
    }
    else {
        _log.debug << "Download URL not specified." << endl;
    }

    _valueAttrHandle = config_to_named_handle (
                           "attribute.value.name",
                           local,
                           "value",
                           context);

    _updateMessageName = config_to_string ("update.message", local, _updateMessageName);
    _channelMessageName = config_to_string ("channel.message", local, _channelMessageName);
}
void PythonCompletionFramework::load_preferences()
{
    JediCompletePluginPref* pref = JediCompletePluginPref::instance();

    std::string config_file = get_config_file();

    // Initialising options from config file
    GKeyFile* keyfile = g_key_file_new();
    if (g_key_file_load_from_file(keyfile, config_file.c_str(), G_KEY_FILE_NONE, NULL)) {
	const char* group = get_plugin_name();

	pref->row_text_max =
	    g_key_file_get_integer(keyfile, group, "maximum_char_in_row", NULL);
	pref->suggestion_window_height_max =
	    g_key_file_get_integer(keyfile, group, "maximum_sug_window_height", NULL);
	pref->page_up_down_skip_amount =
	    g_key_file_get_integer(keyfile, group, "page_up_down_skip_amount", NULL);
	pref->start_completion_with_dot =
	    g_key_file_get_boolean(keyfile, group, "start_completion_with_dot", NULL);
	pref->jedi_server_port =
	    g_key_file_get_integer(keyfile, group, "server_port", NULL);
	gchar* temp;
	temp = g_key_file_get_string(keyfile, group, "python_path", NULL);
	pref->python_path = temp;
	g_free(temp);
    } else {
	pref->row_text_max = 120;
	pref->suggestion_window_height_max = 300;
	pref->page_up_down_skip_amount = 4;
	pref->start_completion_with_dot = true;
	pref->jedi_server_port = 8080;
	pref->python_path = "/usr/bin/python";
    }
    // hidden preference "server_script_dir"
    gchar* dirname = g_path_get_dirname(config_file.c_str());
    pref->server_script_dir = dirname;
    g_free(dirname);

    g_key_file_free(keyfile);

    this->updated_preferences();
}
dmz::RenderModulePickBasic::~RenderModulePickBasic () {

   HashTableHandleIterator it;

   RuntimeContext *context (_PluginInfoData.get_context ());

   RenderPick *pick (_pickTable.get_first (it));

   while (pick) {

      if (RenderPick::is_valid (pick->get_pick_handle (), context)) {

         pick->remove_render_module_pick (get_plugin_name (), *this);
      }

      pick = _pickTable.get_next (it);
   }

   _pickTable.clear ();
}
Beispiel #10
0
void View::do_save(OutputArchive& stream, const ReadableLock& lock) const
{
	lock.check_read(get_local_mutex());

	stream << get_plugin_name(lock);

	unsigned int i;
	double d;
	ExtraNodeAction a;
	bool b;

	i = get_update_interval(lock);			stream << i;
	a = get_extra_node_action(lock);		stream << a;
	d = get_default_intrapid_pdistance(lock);	stream << d;
	d = get_default_interpid_pdistance(lock);	stream << d;
	d = get_default_interdomain_pdistance(lock);	stream << d;
	d = get_default_pidlink_pdistance(lock);	stream << d;
	b = get_interdomain_includes_intradomain(lock);	stream << b;
	i = get_pid_ttl(lock);				stream << i;
	i = get_pdistance_ttl(lock);			stream << i;
}
Beispiel #11
0
void add_plugin_to_menu (gpointer data, gpointer user_data)
{
    static int i=1;
    GtkPluginManagerMenu *menu=(GtkPluginManagerMenu *) user_data;
    GtkWidget *item;
    Plugin *plugin;
    plugin = PLUGIN(data);
    /*
    * Syntax plugins are automatically incorporate to the syntax check system so don't show that plugins here.
    * TODO: maybe configure this in preferences??
    */
    if (get_plugin_syntax_type(plugin)==-1){ 
    item =  gtk_menu_item_new_image_item(GTK_STOCK_EXECUTE, get_plugin_name(plugin));
    gtk_widget_show(item);
    install_menu_hint(item, (gchar *)get_plugin_description(plugin), &main_window);
    g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(plugin_exec), (gpointer) menu);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
    if (i<10) gtk_widget_add_accelerator(item, "activate", menu->priv->accel_group, parse_shortcut(i), GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
    i++;
    }
}
void PythonCompletionFramework::save_preferences()
{
    std::string config_file = get_config_file();
    GKeyFile* keyfile = g_key_file_new();
    const char* group = get_plugin_name();
    JediCompletePluginPref* pref = JediCompletePluginPref::instance();

    g_key_file_set_integer(keyfile, group, "maximum_char_in_row", pref->row_text_max);
    g_key_file_set_integer(keyfile, group, "maximum_sug_window_height",
			   pref->suggestion_window_height_max);
    g_key_file_set_integer(keyfile, group, "page_up_down_skip_amount",
			   pref->page_up_down_skip_amount);
    g_key_file_set_boolean(keyfile, group, "start_completion_with_dot",
			   pref->start_completion_with_dot);
    g_key_file_set_integer(keyfile, group, "server_port", pref->jedi_server_port);
    g_key_file_set_string(keyfile, group, "python_path", pref->python_path.c_str());

    geanycc::util::save_keyfile(keyfile, config_file.c_str());

    g_key_file_free(keyfile);
}
Beispiel #13
0
void
dmz::QtModuleCanvasBasic::_init (Config &local) {

   qwidget_config_read ("widget", local, this);

   const Int32 MinX = config_to_int32 ("scene.min.x", local, -50000);
   const Int32 MinY = config_to_int32 ("scene.min.y", local, -50000);
   const Int32 MaxX = config_to_int32 ("scene.max.x", local, 100000);
   const Int32 MaxY = config_to_int32 ("scene.max.y", local, 100000);

   _scene.setSceneRect (QRectF (MinX, MinY, MaxX - MinX, MaxY - MinY));
   //_scene.setItemIndexMethod (QGraphicsScene::NoIndex);

   _canvas = new QtCanvasView (this);
   _canvas->setTransformationAnchor (QGraphicsView::AnchorViewCenter);
   _canvas->setResizeAnchor (QGraphicsView::AnchorViewCenter);

   const Boolean ScrollBars = config_to_boolean ("scrollbars.value", local, False);

   if (!ScrollBars) {

      _canvas->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
      _canvas->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
   }

   _canvas->setMouseTracking (true);
   //_canvas->setDragMode (QGraphicsView::ScrollHandDrag);

   setObjectName (get_plugin_name ().get_buffer ());
   _scene.setObjectName (objectName () + "Scene");
   _canvas->setObjectName (objectName () + "View");

   _canvas->setScene (&_scene);

   //_canvas->setBackgroundBrush (QPixmap ("/assets/images/background1.png"));

   QVBoxLayout *layout (new QVBoxLayout ());
   layout->addWidget (_canvas);

   setLayout (layout);
   setMouseTracking (true);
   _inputModuleName = config_to_string ("module.input.name", local);

   if (_canvas) {

      _keyEvent.set_source_handle (get_plugin_handle ());
      _mouseEvent.set_source_handle (get_plugin_handle ());

      String value;

      Boolean enableOpenGL (False);

      if (local.lookup_attribute ("canvas.opengl", value)) {

         if (value.to_lower () == "true") { enableOpenGL = True; }
      }

      Boolean enableAntialiasing (False);
      if (local.lookup_attribute ("canvas.antialiasing", value)) {

         if (value.to_lower () == "true") { enableAntialiasing = True; }
      }

      if (enableOpenGL) {

         _canvas->setViewport (new QGLWidget (QGLFormat  (QGL::SampleBuffers)));
         _log.info << "OpenGL enabled" << endl;
      }

      if (enableAntialiasing) {

         if (enableOpenGL) {

            _canvas->setRenderHint (QPainter::HighQualityAntialiasing, true);
            _log.info << "High Quality Antialiasing enabled" << endl;
         }
         else {

            _canvas->setRenderHint (QPainter::Antialiasing, true);
            _log.info << "Antialiasing enabled" << endl;
         }
      }

      if (local.lookup_attribute ("canvas.textantialiasing", value)) {

         if (value.to_lower () == "true") {

            _canvas->setRenderHint (QPainter::TextAntialiasing, true);
            _log.info << "Test Antialiasing enabled" << endl;
         }
      }

      _canvas->setRenderHint (QPainter::SmoothPixmapTransform, true);

      set_zoom_min_value (config_to_float32 ("canvas.zoom.min", local, _zoomMin));
      set_zoom_max_value (config_to_float32 ("canvas.zoom.max", local, _zoomMax));
      set_zoom_step_value (config_to_float32 ("canvas.zoom.step", local, _zoomStep));
      set_zoom (config_to_float32 ("canvas.zoom.default", local, _zoomDefault));
   }
}