Exemplo n.º 1
0
static void show_desktop_applet_realized(MatePanelApplet* applet, gpointer data)
{
    ShowDesktopData* sdd;
    GdkScreen* screen;

    sdd = (ShowDesktopData*) data;

    if (sdd->wnck_screen != NULL)
        g_signal_handlers_disconnect_by_func(sdd->wnck_screen, show_desktop_changed_callback, sdd);

    if (sdd->icon_theme != NULL)
        g_signal_handlers_disconnect_by_func(sdd->icon_theme, theme_changed_callback, sdd);

    screen = gtk_widget_get_screen(sdd->applet);
    sdd->wnck_screen = wnck_screen_get(gdk_screen_get_number (screen));

    if (sdd->wnck_screen != NULL)
        wncklet_connect_while_alive(sdd->wnck_screen, "showing_desktop_changed", G_CALLBACK(show_desktop_changed_callback), sdd, sdd->applet);
    else
        g_warning("Could not get WnckScreen!");

    show_desktop_changed_callback(sdd->wnck_screen, sdd);

    sdd->icon_theme = gtk_icon_theme_get_for_screen (screen);
    wncklet_connect_while_alive(sdd->icon_theme, "changed", G_CALLBACK(theme_changed_callback), sdd, sdd->applet);

    update_icon (sdd);
}
Exemplo n.º 2
0
static void
dh_base_init (DhBase *base)
{
        DhBasePriv *priv = GET_PRIVATE (base);
        IgeConf    *conf;
        gchar      *path;

        conf = ige_conf_get ();
        path = dh_util_build_data_filename ("devhelp", "devhelp.defaults", NULL);
        ige_conf_add_defaults (conf, path);
        g_free (path);

        priv->book_manager = dh_book_manager_new ();
        dh_book_manager_populate (priv->book_manager);

#ifdef GDK_WINDOWING_X11
        {
                gint n_screens, i;

                /* For some reason, libwnck doesn't seem to update its list of
                 * workspaces etc if we don't do this.
                 */
                n_screens = gdk_display_get_n_screens (gdk_display_get_default ());
                for (i = 0; i < n_screens; i++)
                        wnck_screen_get (i);
        }
#endif
}
Exemplo n.º 3
0
/**
 * initialize the window
 * @param location
 * @return 0 or -1 is an error
 */
int AppWindow::Init(panel_locationType location)
{
    this->set_title(PACKAGE_NAME);
    
    // The App Logo
    std::string iconFile = Utilities::getExecPath(DEF_LOGONAME);
    this->set_icon_from_file(iconFile);

    // A window to implement a docking bar.
    // Used for creating the dock panel.         
    this->set_skip_taskbar_hint(true);
    this->set_skip_pager_hint(true);
    this->set_type_hint(Gdk::WindowTypeHint::WINDOW_TYPE_HINT_DOCK);


    // Add the dock panel
    this->add(m_dockpanel);

    // it must be shown before changing properties. 
    // also need to call show to get a valid gdk_window
    this->show_all();

    GdkScreen *screen = gdk_screen_get_default();
    WnckScreen *wnckscreen = wnck_screen_get(0);

    // needed for "configure-event"
    this->add_events(Gdk::STRUCTURE_MASK);

    g_signal_connect(G_OBJECT(wnckscreen), "window_opened",
            G_CALLBACK(window_opened_callback), NULL);

    g_signal_connect(G_OBJECT(wnckscreen), "application_opened",
            G_CALLBACK(application_opened_callback), NULL);

    // The monitors-changed signal is emitted when the number, 
    // size or position of the monitors attached to the screen change.
    g_signal_connect(screen, "monitors-changed",
            G_CALLBACK(monitor_size_changed_callback), (gpointer) this);


    // Initialize the dock Panel
    if (m_dockpanel.preInit(this) != 0)
        return -1;

    // read the monitor geometry and repositioning the window
    if (MonitorGeometry::update(this) == 0) {
        
        m_dockpanel.postInit();
        
        Glib::signal_timeout().connect(sigc::mem_fun(*this,
                &AppWindow::on_timeout), 1000 / 60);

    }
    return 0;

}
Exemplo n.º 4
0
void curfirst(void)
{
	WnckScreen *screen = wnck_screen_get(0);
	WnckWindow *window = wnck_screen_get_active_window(screen);
	int curid = workspace_get_active();

	if (workspace_change_first_window(curid, window)) {
		tile(curid);
	}
}
Exemplo n.º 5
0
static WnckScreen *
wnck_selector_get_screen (WnckSelector *selector)
{
  GdkScreen *screen;

  g_assert (gtk_widget_has_screen (GTK_WIDGET (selector)));

  screen = gtk_widget_get_screen (GTK_WIDGET (selector));

  return wnck_screen_get (gdk_screen_get_number (screen));
}
Exemplo n.º 6
0
void init_screens()
{
	int i;
	int num_screens = 1;

#ifndef GDK_VERSION_3_10
	num_screens = gdk_display_get_n_screens(gdk_display_get_default());
#endif

	for (i=0; i<num_screens; i++) {
		WnckScreen *screen = wnck_screen_get(i);

		g_signal_connect(screen, "window-opened",
								(GCallback)window_opened_cb, NULL);
		g_signal_connect(screen, "window-closed",
								(GCallback)window_closed_cb, NULL);
	}
}
Exemplo n.º 7
0
int main(int argc, char *argv[])
{
    //Gtk takes a whole forrest of init's
    g_thread_init(NULL);
    gdk_threads_init();
    gtk_init(&argc, &argv);
    gnome_vfs_init();//This is suppose to be defunct but something demands it

    WnckScreen *screen;

    screen = wnck_screen_get (0);

    g_signal_connect (G_OBJECT (screen), "active_window_changed",
                    G_CALLBACK (active_window_changed_callback), NULL);
    g_signal_connect (G_OBJECT (screen), "active_workspace_changed",
                    G_CALLBACK (active_workspace_changed_callback), NULL);

    g_signal_connect (G_OBJECT (screen), "window_stacking_changed",
                    G_CALLBACK (window_stacking_changed_callback), NULL);
    g_signal_connect (G_OBJECT (screen), "window_opened",
                    G_CALLBACK (window_opened_callback), NULL);
    g_signal_connect (G_OBJECT (screen), "window_closed",
                    G_CALLBACK (window_closed_callback), NULL);
    g_signal_connect (G_OBJECT (screen), "workspace_created",
                    G_CALLBACK (workspace_created_callback), NULL);
    g_signal_connect (G_OBJECT (screen), "workspace_destroyed",
                    G_CALLBACK (workspace_destroyed_callback), NULL);
    g_signal_connect (G_OBJECT (screen), "application_opened",
                    G_CALLBACK (application_opened_callback), NULL);
    g_signal_connect (G_OBJECT (screen), "application_closed",
                    G_CALLBACK (application_closed_callback), NULL);
    g_signal_connect (G_OBJECT (screen), "showing_desktop_changed",
                    G_CALLBACK (showing_desktop_changed_callback), NULL);

    g_gsr = new GnomeSignalReceiver();

    QApplication a(argc, argv);
    EditTestMainWindow w;
    w.show();
    return a.exec();
}
Exemplo n.º 8
0
static void
wnck_pid_read_resource_usage_no_cache (GdkDisplay        *gdisplay,
                                       gulong             pid,
                                       WnckResourceUsage *usage)
{
  Display *xdisplay;
  int i;

  xdisplay = GDK_DISPLAY_XDISPLAY (gdisplay);

  i = 0;
  while (i < ScreenCount (xdisplay))
    {
      WnckScreen *screen;
      GList *windows;
      GList *tmp;

      screen = wnck_screen_get (i);

      g_assert (screen != NULL);

      windows = wnck_screen_get_windows (screen);
      tmp = windows;
      while (tmp != NULL)
        {
          if (wnck_window_get_pid (tmp->data) == pid)
            {
              wnck_xid_read_resource_usage (gdisplay,
                                            wnck_window_get_xid (tmp->data),
                                            usage);

              /* stop on first window found */
              return;
            }

          tmp = tmp->next;
        }

      ++i;
    }
}
Exemplo n.º 9
0
WnckWindow *window_get_active(void)
{
	WnckScreen *screen = wnck_screen_get(0);
	return wnck_screen_get_active_window(screen);
}
Exemplo n.º 10
0
static void macmenu_construct(AppletType* applet)
{
  MacMenu *mmb = g_slice_new0(MacMenu);
  mmb->applet = applet;
  mmb->screen = wnck_screen_get(gdk_screen_get_number(
      gtk_widget_get_screen(GTK_WIDGET(applet))
      ));
  mmb->mbars_scks = g_hash_table_new(NULL, NULL);
  mmb->title_subs = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
  mmb->ts_mtime = 0;

  mmb->basebox = GTK_BOX(gtk_hbox_new(FALSE, 0));
  gtk_container_set_border_width(GTK_CONTAINER(mmb->basebox), 0);
  gtk_container_add(GTK_CONTAINER(applet), GTK_WIDGET(mmb->basebox));

  mmb->label = GTK_LABEL(gtk_label_new(MAIN_LABEL_TEXT));
  PangoAttrList *pattr = pango_attr_list_new();
  PangoAttribute *pa = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
  pa->start_index = 0; pa->end_index = 1024;
  pango_attr_list_insert(pattr, pa);
  gtk_label_set_attributes(mmb->label, pattr);
  pango_attr_list_unref(pattr);
  gtk_label_set_ellipsize(mmb->label, PANGO_ELLIPSIZE_END);
  gtk_label_set_max_width_chars(mmb->label, MAX_LABEL_WIDTH_N_CHARS * 10);
  gtk_label_set_single_line_mode(mmb->label, TRUE);
  gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->label), FALSE, FALSE, 0);

  mmb->label_space = gtk_event_box_new();
  gtk_widget_set_size_request(mmb->label_space, 8, 1);
  gtk_box_pack_start(mmb->basebox, mmb->label_space, FALSE, FALSE, 0);

  mmb->notebook = GTK_NOTEBOOK(gtk_notebook_new());
  gtk_notebook_set_show_tabs(mmb->notebook, FALSE);
  gtk_notebook_set_show_border(mmb->notebook, FALSE);
  gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->notebook), TRUE, TRUE, 0);

  mmb->dummysck = gtk_hbox_new(FALSE, 0);
  gtk_notebook_append_page(mmb->notebook, mmb->dummysck, NULL);

  mmb->mainsck = gtk_hbox_new(FALSE, SHORTCUT_SPACING);
  gtk_notebook_append_page(mmb->notebook, mmb->mainsck, NULL);
  //initialize_mainsck(mmb);

  mmb->button = GTK_BUTTON(gtk_button_new());
  gtk_button_set_relief(mmb->button, GTK_RELIEF_NONE);
  gtk_button_set_focus_on_click(GTK_BUTTON(mmb->button), FALSE);
  gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->button),
                     FALSE, FALSE, 0);

  g_signal_connect(mmb->screen, "active-window-changed",
                   G_CALLBACK(desktop_active_window_changed), mmb);
  g_signal_connect(mmb->screen, "window-opened",
                   G_CALLBACK(desktop_window_opened), mmb);

#ifdef FOR_XFCE
  g_signal_connect(applet, "free-data",
                   G_CALLBACK(macmenu_free_data), mmb);
  g_signal_connect(applet, "size-changed",
                   G_CALLBACK(macmenu_set_size), mmb);
  // setup panel applet
  gtk_widget_show_all(GTK_WIDGET(mmb->basebox));
  xfce_panel_plugin_add_action_widget (applet, GTK_WIDGET(mmb->button));
  xfce_panel_plugin_set_expand(applet, TRUE);
  macmenu_set_size(applet, xfce_panel_plugin_get_size(applet), mmb);
  // load config, set popup
  macmenu_load_from_rc(mmb);
  GtkWidget* label_toggle = gtk_check_menu_item_new_with_label("Hide Label");
  g_signal_connect(label_toggle, "toggled", G_CALLBACK(on_label_toggled), mmb);
  gtk_widget_show(label_toggle);
  gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(label_toggle), mmb->hide_label);
  gtk_check_menu_item_toggled(GTK_CHECK_MENU_ITEM(label_toggle));
  xfce_panel_plugin_menu_insert_item(mmb->applet, GTK_MENU_ITEM(label_toggle));

#elif FOR_GNOME
  g_signal_connect(applet, "destroy", G_CALLBACK(macmenu_free_data), mmb);
  // setup panel applet
  gtk_widget_show_all(GTK_WIDGET(applet));
  g_signal_connect(GTK_WIDGET(mmb->button), "pressed",
                   G_CALLBACK(on_button_pressed), mmb);
  panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MAJOR);
  macmenu_set_size(applet, panel_applet_get_size(applet), mmb);
  // load config, set popup
  mmb->gconf = gconf_client_get_default();
  macmenu_load_from_gconf(mmb);
  macmenu_write_gconf(mmb);
  static const char toggle_menu_xml [] =
   "<popup name=\"button3\">\n"
   "   <menuitem name=\"hide_label\" "
   "             verb=\"hide_label\" "
   "           _label=\"_Hide Label\"\n"
   "             type=\"toggle\"/>\n"
   "</popup>\n";
  static const BonoboUIVerb toggle_menu_verbs[] =
  {
    BONOBO_UI_VERB_END
  };
  panel_applet_setup_menu(mmb->applet, toggle_menu_xml, toggle_menu_verbs, mmb);
  BonoboUIComponent* popup_component = panel_applet_get_popup_component(mmb->applet);
  bonobo_ui_component_set_prop(popup_component, "/commands/hide_label",
                               "state", mmb->hide_label ? "1": "0", NULL);
  bonobo_ui_component_add_listener(panel_applet_get_popup_component(mmb->applet),
                                   "hide_label",
                                   (BonoboUIListenerFn) on_label_toggled,
                                   mmb);
  on_label_toggled(NULL, NULL, 0, NULL, mmb);
#endif // FOR_XFCE/FOR_GNOME

  add_all(mmb);
  XSetErrorHandler(handle_x_error);
}
Exemplo n.º 11
0
GtkWidget *
dh_base_get_window_on_current_workspace (DhBase *base)
{
        DhBasePriv *priv;

        g_return_val_if_fail (DH_IS_BASE (base), NULL);

        priv = GET_PRIVATE (base);

        if (!priv->windows) {
                return NULL;
        }

#ifdef GDK_WINDOWING_X11
        {
                WnckWorkspace *workspace;
                WnckScreen    *screen;
                GtkWidget     *window;
                GList         *windows, *w;
                GSList        *l;
                gulong         xid;
                pid_t          pid;

                screen = wnck_screen_get (0);
                if (!screen) {
                        return NULL;
                }

                workspace = wnck_screen_get_active_workspace (screen);
                if (!workspace) {
                        return NULL;
                }

                xid = 0;
                pid = getpid ();

                /* Use _stacked so we can use the one on top. */
                windows = wnck_screen_get_windows_stacked (screen);
                windows = g_list_last (windows);

                for (w = windows; w; w = w->prev) {
                        if (wnck_window_is_on_workspace (w->data, workspace) &&
                            wnck_window_get_pid (w->data) == pid) {
                                xid = wnck_window_get_xid (w->data);
                                break;
                        }
                }

                if (!xid) {
                        return NULL;
                }

                /* Return the first matching window we have. */
                for (l = priv->windows; l; l = l->next) {
                        window = l->data;

#if GTK_CHECK_VERSION (2,14,0)
                        if (GDK_WINDOW_XID (gtk_widget_get_window (window)) == xid) {
#else
                        if (GDK_WINDOW_XID (window->window) == xid) {
#endif
                                return window;
                        }
                }
        }

        return NULL;
#else
        return priv->windows->data;
#endif
}

GtkWidget *
dh_base_get_window (DhBase *base)
{
        GtkWidget *window;

        g_return_val_if_fail (DH_IS_BASE (base), NULL);

        window = dh_base_get_window_on_current_workspace (base);
        if (!window) {
                window = dh_base_new_window (base);
                gtk_window_present (GTK_WINDOW (window));
        }

        return window;
}