void
egg_toolbar_editor_set_model (EggToolbarEditor *t,
			      EggToolbarsModel *model)
{
  EggToolbarEditorPrivate *priv;

  g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (t));
  g_return_if_fail (model != NULL);

  priv = t->priv;

  if (priv->model)
    {
      if (G_UNLIKELY (priv->model == model)) return;

      egg_toolbar_editor_disconnect_model (t);
      g_object_unref (priv->model);
    }

  priv->model = g_object_ref (model);

  update_editor_sheet (t);

  priv->sig_handlers[SIGNAL_HANDLER_ITEM_ADDED] =
    g_signal_connect_object (model, "item_added",
			     G_CALLBACK (item_added_or_removed_cb), t, 0);
  priv->sig_handlers[SIGNAL_HANDLER_ITEM_REMOVED] =
    g_signal_connect_object (model, "item_removed",
			     G_CALLBACK (item_added_or_removed_cb), t, 0);
  priv->sig_handlers[SIGNAL_HANDLER_TOOLBAR_REMOVED] =
    g_signal_connect_object (model, "toolbar_removed",
			     G_CALLBACK (toolbar_removed_cb), t, 0);
}
static void
toolbar_removed_cb (EggToolbarsModel   *model,
	            int                 position,
	            EggToolbarEditor   *editor)
{
  update_editor_sheet (editor);
}
Example #3
0
void
egg_toolbar_editor_load_actions (EggToolbarEditor *editor,
				 const char       *xml_file)
{
  xmlDocPtr doc;
  xmlNodePtr root;
  xmlNodePtr child;

  doc = xmlParseFile (xml_file);
  root = xmlDocGetRootElement (doc);
  child = root->children;

  while (child)
    {
      if (xmlStrEqual (child->name, BAD_CAST "available"))
	{
	  parse_item_list (editor, child->children);
	}
      child = child->next;
    }

  xmlFreeDoc (doc);

  update_actions_list (editor);
  update_editor_sheet (editor);
}
Example #4
0
static void
editor_drag_data_received_cb (GtkWidget          *widget,
			      GdkDragContext     *context,
			      gint                x,
			      gint                y,
			      GtkSelectionData   *selection_data,
			      guint               info,
			      guint               time_,
			      EggToolbarEditor *editor)
{
  GtkAction *action;
  const char *data;

  g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (editor));
  g_return_if_fail (selection_data != NULL);

  if (selection_data->length <= 0 || selection_data->data == NULL) return;

  data = (const char *) selection_data->data;

  if (strcmp (data, "separator") == 0) return;

  action = find_action (editor, data);
  g_return_if_fail (action != NULL);

  if (g_list_find (editor->priv->default_actions_list, action))
    {
      editor->priv->actions_list = g_list_insert_sorted
	    (editor->priv->actions_list, action, compare_actions);
    }

  update_editor_sheet (editor);
}
static void
item_added_or_removed_cb (EggToolbarsModel   *model,
                          int                 tpos,
                          int                 ipos,
                          EggToolbarEditor   *editor)
{
  update_editor_sheet (editor);
}
Example #6
0
static void
editor_drag_data_delete_cb (GtkWidget          *widget,
			    GdkDragContext     *context,
			    EggToolbarEditor *editor)
{
  GtkAction *action;
  g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (editor));

  action = GTK_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action"));
  if (action)
    {
      editor->priv->actions_list = g_list_remove
	    (editor->priv->actions_list, action);
    }

  update_editor_sheet (editor);
}