nautilus-application.c 1.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#include "nautilus.h"
#include <file-manager/fm-public-api.h>

static int window_count = 0;

static GnomeObject *
nautilus_make_object(GnomeGenericFactory *gfact, const char *goad_id, gpointer closure)
{
  GtkObject *theobj = NULL;

  if(!strcmp(goad_id, "ntl_file_manager"))
    theobj = gtk_object_new(fm_directory_view_get_type(), NULL);

  if(!theobj)
    return NULL;

  if(GNOME_IS_OBJECT(theobj))
    return GNOME_OBJECT(theobj);

  if(NAUTILUS_IS_VIEW_CLIENT(theobj))
    {
      gtk_widget_show(GTK_WIDGET(theobj));
      return nautilus_view_client_get_gnome_object(NAUTILUS_VIEW_CLIENT(theobj));
    }

  gtk_object_destroy(theobj);

  return NULL;
}

void
32
nautilus_app_init(const char *initial_url)
33 34 35
{
  NautilusWindow *mainwin;

36
  nautilus_navinfo_init();
37
  nautilus_prefs_load();
38

39 40 41 42 43 44
  /* Create our CORBA objects */
  gnome_generic_factory_new_multi("nautilus_factory", nautilus_make_object, NULL);

  /* Set default configuration */
  mainwin = nautilus_app_create_window();
  bonobo_activate();
45
  nautilus_window_set_initial_state(mainwin, initial_url);
46 47 48 49 50 51 52 53
}

static void
nautilus_app_destroy_window(GtkObject *obj)
{
  window_count--;

  if(window_count <= 0)
54 55 56 57
    {
      gtk_main_quit();
      nautilus_prefs_save();
    }
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
}

NautilusWindow *
nautilus_app_create_window(void)
{
  GtkWidget *win = gtk_widget_new(nautilus_window_get_type(), "app_id", "nautilus", NULL);

  window_count++;

  gtk_signal_connect(GTK_OBJECT(win), "destroy", nautilus_app_destroy_window, NULL);

  gtk_widget_show(win);

  return NAUTILUS_WINDOW(win);
}