Logo Search packages:      
Sourcecode: wallpaper-tray version File versions  Download package

Applet::Applet ( PanelApplet *  _pPanelApplet  ) 

Contruct a new Applet object.

<Applet::Applet>

Date:
12-11-2006 GAF Written

Definition at line 142 of file Applet.cc.

References CreateTooltip(), OnClicked(), OnDropDragDataReceived(), RenderThumbnail(), and SetThumbnailOnPanel().

  :
      m_pPanelApplet(_pPanelApplet),
      m_pPreferencesDialog(NULL),
      m_pSearchDialog(NULL),
      m_Wallpapers(this)
{
      // set up drag and drop targets:
      std::list<Gtk::TargetEntry> ls_DropTarget;
      ls_DropTarget.push_back(Gtk::TargetEntry("STRING"));
      ls_DropTarget.push_back(Gtk::TargetEntry("text/plain"));

      // make the image a dnd drop destination
      m_GtkImage.drag_dest_set(Gtk::DEST_DEFAULT_ALL, Gdk::DragAction(GDK_ACTION_COPY));
      m_GtkImage.drag_dest_add_image_targets();
      m_GtkImage.drag_dest_add_text_targets();
      m_GtkImage.drag_dest_add_uri_targets();

      // connect dnd signals
      m_GtkImage.signal_drag_data_received().connect(sigc::mem_fun(*this, &Applet::OnDropDragDataReceived));

      // set up the gconf client
      m_pGconfClient = Gnome::Conf::Client::get_default_client();

      m_pGconfClient->add_dir("/apps/wp_tray");

      // add our directory to the list of directories the GConfClient will watch
      m_pGconfClient->add_dir("/desktop/gnome/background");

      // listen to changes to our key
      m_nCnxnUpdateTooltip = m_pGconfClient->notify_add     (
                  "/desktop/gnome/background/picture_filename",
                  sigc::mem_fun(*this, &Applet::CreateTooltip)
            );

      // set a random wallpaper if we have been told to at logon
      if(m_pGconfClient->get_bool("/apps/wp_tray/b_wp_logon") == true)
      {
            Applet::RenderThumbnail(m_pGconfClient->get_string("/desktop/gnome/background/picture_filename"));

            Applet::SetThumbnailOnPanel();

            m_Wallpapers.SetRandom(false);
      }// end if
      else
      {
            Applet::RenderThumbnail(m_pGconfClient->get_string("/desktop/gnome/background/picture_filename"));

            Applet::SetThumbnailOnPanel();
      }// end else

      // create app icon (for help dialog)
      try
      {
            m_pGdkIcon = Gdk::Pixbuf::create_from_file(GNOMEICONDIR"/wp_tray-applet.png");
      }// end try
      catch(...)
      {
            // it's a minor problem if we can't find the icon
            m_pGdkIcon = Glib::RefPtr<Gdk::Pixbuf>();
      }// end catch

      // enable and create tooltips
      m_GtkTooltips.enable();
      Applet::CreateTooltip(m_nCnxnUpdateTooltip, m_pGconfClient->get_entry("/desktop/gnome/background/picture_filename"));

      m_GtkEventBox.add_events(Gdk::BUTTON_PRESS_MASK);

      m_GtkEventBox.signal_button_press_event().connect(sigc::mem_fun(*this, &Applet::OnClicked));

      m_GtkEventBox.add(m_GtkImage);
      Applet::add(m_GtkEventBox);

      Applet::show_all();
      
      // setup menu
      static const char str_MenuXml[] =
            "<popup name=\"button3\">\n"
            "   <menuitem name=\"Forward Item\"\n"
            "             verb=\"WpTrayForward\" _label=\"_Forward\"\n"
            "             pixtype=\"stock\" pixname=\"gtk-go-forward\"/>\n"
            "   <menuitem name=\"Search Item\"\n"
            "             verb=\"WpTraySearch\" _label=\"_Search\"\n"
            "             pixtype=\"stock\" pixname=\"gtk-find\"/>\n"
            "   <menuitem name=\"Delete Item\"\n"
            "             verb=\"WpTrayDelete\" _label=\"_Delete\"\n"
            "             pixtype=\"stock\" pixname=\"gtk-delete\"/>\n"
            "   <menuitem name=\"Properties Item\"\n"
            "             verb=\"WpTrayPreferences\" _label=\"_Preferences\"\n"
            "             pixtype=\"stock\" pixname=\"gtk-properties\"/>\n"
            "   <menuitem name=\"Help Item\"\n"
            "             verb=\"WpTrayHelp\" _label=\"_Help\"\n"
            "             pixtype=\"stock\" pixname=\"gtk-help\"/>\n"
            "   <menuitem name=\"About Item\"\n"
            "             verb=\"WpTrayAbout\" _label=\"_About\"\n"
            "             pixtype=\"stock\" pixname=\"gnome-stock-about\"/>\n"
            "</popup>\n";

      static const BonoboUIVerb ar_MenuVerbs[] =
      {
            BONOBO_UI_VERB("WpTrayForward", &DisplayForward),
            BONOBO_UI_VERB("WpTraySearch", &DisplaySearch),
            BONOBO_UI_VERB("WpTrayDelete", &DisplayDelete),
            BONOBO_UI_VERB("WpTrayPreferences", &DisplayPreferences),
            BONOBO_UI_VERB("WpTrayHelp", &DisplayHelp),
            BONOBO_UI_VERB("WpTrayAbout", &DisplayAbout),    
            BONOBO_UI_VERB_END
      };

      panel_applet_setup_menu(m_pPanelApplet, str_MenuXml, ar_MenuVerbs, this);
}// end Applet::Applet


Generated by  Doxygen 1.6.0   Back to index