void
LauncherApplication::show()
{
    if (m_application == NULL) {
        return;
    }

    QScopedPointer<BamfWindowList> windows(m_application->windows());
    int size = windows->size();
    if (size < 1) {
        return;
    }

    /* Pick the most important window.
       The primary criterion to determine the most important window is urgency.
       The secondary criterion is the last_active timestamp (the last time the
       window was activated). */
    BamfWindow* important = windows->at(0);
    for (int i = 0; i < size; ++i) {
        BamfWindow* current = windows->at(i);
        if (current->urgent() && !important->urgent()) {
            important = current;
        } else if (current->urgent() || !important->urgent()) {
            if (current->last_active() > important->last_active()) {
                important = current;
            }
        }
    }

    WnckScreen* screen = wnck_screen_get_default();
    wnck_screen_force_update(screen);

    WnckWindow* window = wnck_window_get(important->xid());
    LauncherUtility::showWindow(window);
}
/* Returns the number of window for this application that reside on the
   current workspace */
int
LauncherApplication::windowCountOnCurrentWorkspace()
{
    int windowCount = 0;
    WnckWorkspace *current = wnck_screen_get_active_workspace(wnck_screen_get_default());

    for (int i = 0; i < m_application->windows()->size(); i++) {
        BamfWindow *window = m_application->windows()->at(i);
        if (window == NULL) {
            continue;
        }

        /* When geting the wnck window, it's possible we get a NULL
           return value because wnck hasn't updated its internal list yet,
           so we need to force it once to be sure */
        WnckWindow *wnck_window = wnck_window_get(window->xid());
        if (wnck_window == NULL) {
            wnck_screen_force_update(wnck_screen_get_default());
            wnck_window = wnck_window_get(window->xid());
            if (wnck_window == NULL) {
                continue;
            }
        }

        WnckWorkspace *workspace = wnck_window_get_workspace(wnck_window);
        if (workspace == current) {
            windowCount++;
        }
    }
    return windowCount;
}
Exemple #3
0
void Application::init() {
    b2Vec2 gravity(0.0f, 10.0f);
    mWorld = QSharedPointer<b2World>(new b2World(gravity));
    mWorld->SetAllowSleeping(false);

    // Get windowing system
    WnckScreen *screen;
    WnckWindow *active_window;
    WnckWorkspace *active_workspace;
    GList *window_l;

    screen = wnck_screen_get_default ();

    wnck_screen_force_update (screen);

    active_window = wnck_screen_get_active_window (screen);
    active_workspace = wnck_screen_get_active_workspace (screen);

    for(window_l = wnck_screen_get_windows (screen); window_l != NULL; window_l = window_l->next) {
        WnckWindow *window = WNCK_WINDOW (window_l->data);
        if(wnck_window_is_on_workspace(window, active_workspace) &&
                !wnck_window_is_minimized(window) &&
                wnck_window_get_window_type(window) == WNCK_WINDOW_NORMAL) {
            mPhysicalWindows.append(QSharedPointer<PhysicalWindow>(new PhysicalWindow(window, mWorld)));
        }
    }

    mPhysicalWindows.append(QSharedPointer<PhysicalWindow>(new PhysicalWindow(100, 100, 100, 100, mWorld)));
}
int main(int argc, char **argv) {
  gtk_init (&argc, &argv);
  client = gconf_client_get_default ();
  /* which confs to monitor */
  gconf_client_add_dir (client, DEFAULT_BACKGROUND_GCONF_PATH,
			GCONF_CLIENT_PRELOAD_NONE, NULL);
  gconf_client_add_dir (client, MULTI_BACKGROUND_GCONF_PATH,
			GCONF_CLIENT_PRELOAD_NONE, NULL);
  
#define GET_DEFAULT_BACKGROUND(client, type, entry)			\
  default_ ## entry = gconf_client_get_ ## type(client,			\
						DEFAULT_BACKGROUND_GCONF_PATH "/" # entry, \
						NULL)
  
  GET_DEFAULT_BACKGROUND(client, string, color_shading_type);
  GET_DEFAULT_BACKGROUND(client, bool, draw_background);
  GET_DEFAULT_BACKGROUND(client, string, picture_filename);
  GET_DEFAULT_BACKGROUND(client, int, picture_opacity);
  GET_DEFAULT_BACKGROUND(client, string, picture_options);
  GET_DEFAULT_BACKGROUND(client, string, primary_color);
  GET_DEFAULT_BACKGROUND(client, string, secondary_color);

  screen = wnck_screen_get_default ();
  wnck_screen_force_update (screen);	
  
  g_signal_connect(G_OBJECT (screen), "active_workspace_changed",
		   G_CALLBACK (workspace_changed_cb),
		   NULL);
  add_monitors();
  gtk_main ();
  return 0;
}
void
LauncherApplication::setIconGeometry(int x, int y, int width, int height, uint xid)
{
    if (m_application == NULL) {
        return;
    }

    QScopedPointer<BamfUintList> xids;
    if (xid == 0) {
        xids.reset(m_application->xids());
    } else {
        QList<uint> list;
        list.append(xid);
        xids.reset(new BamfUintList(list));
    }
    int size = xids->size();
    if (size < 1) {
        return;
    }

    WnckScreen* screen = wnck_screen_get_default();
    wnck_screen_force_update(screen);

    for (int i = 0; i < size; ++i) {
        WnckWindow* window = wnck_window_get(xids->at(i));
        wnck_window_set_icon_geometry(window, x, y, width, height);
    }
}
Exemple #6
0
int main(int argc, char **argv) {
    WnckScreen *screen;
    WnckWindow *active_window;
    GList *window_l;

    gdk_init(&argc, &argv);

    screen = wnck_screen_get_default();

    sleep(5);

    wnck_screen_force_update(screen);

    active_window = wnck_screen_get_active_window(screen);

    for (window_l = wnck_screen_get_windows(screen); window_l != NULL;
        window_l = window_l->next) {
        WnckWindow *window = WNCK_WINDOW(window_l->data);
        if (strcmp(wnck_window_get_name(window), "Terminal") == 0) {
            wnck_window_activate(window, (guint32)time(NULL));
            break;
        }
//        g_print("Name: '%s', PID: %d(%lu)%s\n", wnck_window_get_name(window),
//            wnck_window_get_pid(window), wnck_window_get_xid(window),
//            window == active_window ? " (active)" : "");
    }

    return 0;
}
Exemple #7
0
// -----------------------------------------------------------------------------
void g_window_workspace(GtkWidget* pWidget, int space)
{
	DEBUGLOGB;

#if !_USEWKSPACE

#if GTK_CHECK_VERSION(3,0,0)
	Screen* xscreen = gdk_x11_screen_get_xscreen(gdk_screen_get_default());
	Window  xwindow = gdk_x11_window_get_xid(gtk_widget_get_window(pWidget));
#else
	Screen* xscreen = GDK_SCREEN_XSCREEN(gdk_screen_get_default());
	Window  xwindow = GDK_WINDOW_XWINDOW(gtk_widget_get_window(pWidget));
#endif

	_wncki_change_workspace(xscreen, xwindow, space);

#else  // !_USEWKSPACE

	WnckScreen* screen = wnck_screen_get_default();

	if( screen )
	{
		DEBUGLOGS("got default screen");
		wnck_screen_force_update(screen);

		DEBUGLOGP("sticky is off and workspace is %d\n", space);
		WnckWindow* window = wnck_window_get(gdk_x11_drawable_get_xid(gtk_widget_get_window(pWidget)));

		if( window && !wnck_window_is_pinned(window) )
		{
			DEBUGLOGS("got non-pinned window");
			WnckWorkspace* trgtWrk = wnck_screen_get_workspace       (screen, space);
			WnckWorkspace* actvWrk = wnck_screen_get_active_workspace(screen);

			if( trgtWrk && actvWrk && trgtWrk != actvWrk )
			{
				DEBUGLOGS("got target workspace is diff from current so moving window to target");
				wnck_window_move_to_workspace(window, trgtWrk);
			}
		}
#ifdef _DEBUGLOG
		else
		{
			DEBUGLOGP("WnckWindow for clock window is%svalid\n", window ? " " : " NOT ");
			guint xw1 = GDK_WINDOW_XWINDOW      (gtk_widget_get_window(pWidget));
			guint xw2 = gdk_x11_drawable_get_xid(gtk_widget_get_window(pWidget));
			DEBUGLOGP("X11 XID1 for clock window is %d\n", (int)xw1);
			DEBUGLOGP("X11 XID2 for clock window is %d\n", (int)xw2);
		}
#endif
	}

#endif // !_USEWKSPACE

	DEBUGLOGE;
}
Exemple #8
0
gboolean
dnd_has_one_fullscreen_window (void)
{
	gboolean result;

	WnckScreen *screen = wnck_screen_get_default ();
	wnck_screen_force_update (screen);
	WnckWorkspace *workspace = wnck_screen_get_active_workspace (screen);
	GList *list = wnck_screen_get_windows (screen);
	GList *item = g_list_find_custom (list, workspace, (GCompareFunc) is_fullscreen_cb);
	result = item != NULL;
#ifdef HAVE_WNCK_SHUTDOWN
	wnck_shutdown ();
#endif
	return result;
}
/**
 * ww_apply_layout_by_name
 * @layout_name: The name of the layout to apply
 *
 * Apply a given layout to the default screen by looking up the relevant
 * #WwLayout based on its name.
 */
void
ww_apply_layout_by_name (const gchar * layout_name)
{
	WnckScreen *screen;
	WnckWorkspace   *current_ws;
	GList *windows, *struts;
	WnckWindow *active;
	const WwLayout *layout;
	GError *error;
	
	screen = wnck_screen_get_default ();
	wnck_screen_force_update (screen);
	
	current_ws = wnck_screen_get_active_workspace (screen);
	windows = wnck_screen_get_windows (screen);
	struts = ww_filter_strut_windows (windows, current_ws);
	windows = ww_filter_user_windows (windows, current_ws);
	active = wnck_screen_get_active_window (screen);
	
	/* Check that we know the requested layout */
	layout = ww_get_layout (layout_name);
	if (!layout)
	{
		g_printerr ("No such layout: '%s'. Try running with --layouts to "
					"list possible layouts\n", layout_name);
		return;
	}
	
	/* Apply the layout */
	error = NULL;
	layout->handler (screen, windows, struts, active, &error);
	g_list_free (windows);
	g_list_free (struts);
	
	if (error)
	{
		g_printerr ("Failed to apply layout '%s'. Error was:\n%s",
					layout_name, error->message);
		g_error_free (error);
		return;
	}	
}
Exemple #10
0
static void wibuti_watcher_init(WibutiWatcher *self) {
	self->only_maximized = FALSE;
	self->tracked = NULL;
	self->screen = wnck_screen_get_default();
	wnck_screen_force_update(self->screen);

	wibuti_watcher_find_window(self);
	
	g_signal_connect(G_OBJECT(self->screen), "active-workspace-changed",
	                 G_CALLBACK(wibuti_watcher_active_workspace_changed_cb), self);
	g_signal_connect(G_OBJECT(self->screen), "active-window-changed",
	                 G_CALLBACK(wibuti_watcher_active_window_changed_cb), self);
	g_signal_connect(G_OBJECT(self->screen), "viewports-changed",
	                 G_CALLBACK(wibuti_watcher_viewports_changed_cb), self);
	g_signal_connect(G_OBJECT(self->screen), "window-closed",
	                 G_CALLBACK(wibuti_watcher_window_closed_cb), self);
	g_signal_connect(G_OBJECT(self->screen), "window-opened",
	                 G_CALLBACK(wibuti_watcher_window_opened_cb), self);
	
	g_signal_emit_by_name(self, WIBUTI_SIGNAL_WINDOW_CHANGED);
}
void
LauncherApplication::close()
{
    if (m_application == NULL) {
        return;
    }

    QScopedPointer<BamfUintList> xids(m_application->xids());
    int size = xids->size();
    if (size < 1) {
        return;
    }

    WnckScreen* screen = wnck_screen_get_default();
    wnck_screen_force_update(screen);

    for (int i = 0; i < size; ++i) {
        WnckWindow* window = wnck_window_get(xids->at(i));
        wnck_window_close(window, CurrentTime);
    }
}
void
Application::connectWindowSignals()
{
    if (m_application == NULL || m_application->running() == false) {
        return;
    }

    QScopedPointer<BamfWindowList> windows(m_application->windows());
    const int size = windows->size();
    if (size < 1) {
        return;
    }

    WnckScreen* screen = wnck_screen_get_default();
    wnck_screen_force_update(screen);

    for (int i = 0; i < size; ++i) {
        BamfWindow *window = windows->at(i);
        onWindowAdded(window);
    }
}
gboolean
window_list_applet_fill (PanelApplet *applet)
{
	TasklistData *tasklist;
	GError *error;
	GConfValue *value;

	gint sizepref;

	tasklist = g_new0 (TasklistData, 1);

	tasklist->applet = GTK_WIDGET (applet);

	panel_applet_set_flags (PANEL_APPLET (tasklist->applet),
				PANEL_APPLET_EXPAND_MAJOR |
				PANEL_APPLET_EXPAND_MINOR |
				PANEL_APPLET_HAS_HANDLE);

	panel_applet_add_preferences (applet, "/schemas/apps/window_list_applet/prefs", NULL);

	setup_gconf (tasklist);

	error = NULL;
	tasklist->include_all_workspaces = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error);
	if (error) {
		g_error_free (error);
		tasklist->include_all_workspaces = FALSE; /* Default value */
	}

	error = NULL;
	tasklist->grouping = -1;
	value = panel_applet_gconf_get_value (applet, "group_windows", &error);
	if (error) {
		g_error_free (error);
	} else if (value) {
		tasklist->grouping = get_grouping_type (value);
		gconf_value_free (value);
	}
	if (tasklist->grouping < 0)
		tasklist->grouping = WNCK_TASKLIST_AUTO_GROUP; /* Default value */
	
	error = NULL;
	tasklist->move_unminimized_windows = panel_applet_gconf_get_bool (applet, "move_unminimized_windows", &error);
	if (error) {
		g_error_free (error);
		tasklist->move_unminimized_windows = TRUE; /* Default value */
	}

	tasklist->size = panel_applet_get_size (applet);
	switch (panel_applet_get_orient (applet)) {
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		tasklist->orientation = GTK_ORIENTATION_VERTICAL;
		break;
	case PANEL_APPLET_ORIENT_UP:
	case PANEL_APPLET_ORIENT_DOWN:
	default:
		tasklist->orientation = GTK_ORIENTATION_HORIZONTAL;
		break;
	}

	tasklist->screen = wncklet_get_screen (tasklist->applet);

	/* because the tasklist doesn't respond to signals at the moment */
	wnck_screen_force_update (tasklist->screen);

	tasklist->tasklist = wnck_tasklist_new (tasklist->screen);

        wnck_tasklist_set_icon_loader (WNCK_TASKLIST (tasklist->tasklist),
                                       icon_loader_func,
                                       tasklist,
                                       NULL);
        
	/* get size preferences */
	error = NULL;
	sizepref = panel_applet_gconf_get_int (applet, "minimum_size", &error);
	if (error) {
		sizepref = 50; /* Default value */
		g_error_free (error);
	}

	if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL)
		wnck_tasklist_set_minimum_width (WNCK_TASKLIST (tasklist->tasklist), sizepref);	  
	else
		wnck_tasklist_set_minimum_height (WNCK_TASKLIST (tasklist->tasklist), sizepref);	  

	error = NULL;
	sizepref = panel_applet_gconf_get_int (applet, "maximum_size", &error);
	if (error) {
		sizepref = 4096; /* Default value */
		g_error_free (error);
	}

	tasklist->maximum_size = sizepref;

	g_signal_connect (G_OBJECT (tasklist->tasklist), "destroy",
			  G_CALLBACK (destroy_tasklist),
			  tasklist);

	g_signal_connect (G_OBJECT (tasklist->applet), "size_request",
			  G_CALLBACK (applet_size_request),
			  tasklist);
	tasklist_update (tasklist);
	gtk_widget_show (tasklist->tasklist);

	gtk_container_add (GTK_CONTAINER (tasklist->applet), tasklist->tasklist);

	g_signal_connect (G_OBJECT (tasklist->applet),
			  "realize",
			  G_CALLBACK (applet_realized),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_orient",
			  G_CALLBACK (applet_change_orient),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_size",
			  G_CALLBACK (applet_change_pixel_size),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_background",
			  G_CALLBACK (applet_change_background),
			  tasklist);

	panel_applet_set_background_widget (PANEL_APPLET (tasklist->applet),
					    GTK_WIDGET (tasklist->applet));
	
	panel_applet_setup_menu_from_file (PANEL_APPLET (tasklist->applet),
					   NULL,
					   "GNOME_WindowListApplet.xml",
					   NULL,
					   tasklist_menu_verbs, 
					   tasklist);

	if (panel_applet_get_locked_down (PANEL_APPLET (tasklist->applet))) {
		BonoboUIComponent *popup_component;

		popup_component = panel_applet_get_popup_component (PANEL_APPLET (tasklist->applet));

		bonobo_ui_component_set_prop (popup_component,
					      "/commands/TasklistPreferences",
					      "hidden", "1",
					      NULL);
	}

	gtk_widget_show (tasklist->applet);
	
	return TRUE;
}
int main (int argc, char **argv)
{
    GdkWindow *rootwindow;		 /* RootWindow of X11*/
    GMainLoop *loop;                       /* the event loop */
    char *pw_dir;
    char *xml_file;
    uid_t uid;
    struct passwd *pass;

    /* inits some gdk stuff */
    gdk_init(&argc, &argv);

#ifdef ENABLE_LIBWNCK
    screen = wnck_screen_get_default ();
    wnck_screen_force_update (screen);  
#endif
  
    parse_options(&argc, &argv);
  
    uid = getuid();
    pass = getpwuid (uid);
    pw_dir = pass->pw_dir;
  
    xml_file = (char*) malloc (sizeof (char) * (strlen (XML_FILE) + strlen (pw_dir) + 1));
    sprintf (xml_file, "%s%s", pw_dir, XML_FILE);
    
    eventlist = parseDoc (xml_file);
    if (eventlist == NULL)
    {
	g_print ("xml error or no elements in list\n");
	exit (1);
    }
    free (xml_file);

    rootwindow = gdk_window_foreign_new (gdk_x11_get_default_root_xwindow());
    /*rootwindow = gdk_window_foreign_new (0x1200002); */

    if (rootwindow == NULL)
    {
	g_print ("rootwindow == NULL\n");
	exit (1);
    }
  
    /* check if GDK_BUTTON_PRESS_MASK is available */
    gdk_error_trap_push ();

    /* ... Call the X function which may cause an error here ... */
    gdk_window_set_events (rootwindow, GDK_BUTTON_PRESS_MASK);
    gdk_window_set_events (rootwindow, GDK_SCROLL_MASK);
  
    /* Flush the X queue to catch errors now. */
    gdk_flush ();

    if (gdk_error_trap_pop ())
    {
	char error[] = "grootevent: an error occured while querying the X server.\n"
	    "A window manager or an application is already grapping\n"
	    "the buttons from the root window.\n\n"
	    "Please read the documentation to get more help about this.\n";
	g_print (error);
	exit (1);
    }
    
    gdk_event_handler_set (event_func, NULL, NULL);

    loop = g_main_loop_new (NULL, FALSE);
    g_main_loop_run (loop);
   
    return 0;
}
gboolean
workspace_switcher_applet_fill (PanelApplet *applet)
{
	PagerData *pager;
	GError *error;
	gboolean display_names;
        BonoboUIComponent* popup_component;
	
	panel_applet_add_preferences (applet, "/schemas/apps/workspace_switcher_applet/prefs", NULL);
	
	pager = g_new0 (PagerData, 1);

	pager->applet = GTK_WIDGET (applet);

	panel_applet_set_flags (PANEL_APPLET (pager->applet), PANEL_APPLET_EXPAND_MINOR);

	setup_gconf (pager);
	
	error = NULL;
	pager->n_rows = panel_applet_gconf_get_int (applet, "num_rows", &error);
	if (error) {
                g_printerr (_("Error loading num_rows value for Workspace Switcher: %s\n"),
                            error->message);
		g_error_free (error);
                /* leave current value */
	}

        pager->n_rows = CLAMP (pager->n_rows, 1, MAX_REASONABLE_ROWS);

	error = NULL;
	display_names = panel_applet_gconf_get_bool (applet, "display_workspace_names", &error);
	if (error) {
                g_printerr (_("Error loading display_workspace_names value for Workspace Switcher: %s\n"),
                            error->message);
		g_error_free (error);
                /* leave current value */
	}

	if (display_names) {
		pager->display_mode = WNCK_PAGER_DISPLAY_NAME;
	} else {
		pager->display_mode = WNCK_PAGER_DISPLAY_CONTENT;
	}

	error = NULL;
	pager->display_all = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error);
	if (error) {
                g_printerr (_("Error loading display_all_workspaces value for Workspace Switcher: %s\n"),
                            error->message);
		g_error_free (error);
                /* leave current value */
	}
	
	switch (panel_applet_get_orient (applet)) {
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		pager->orientation = GTK_ORIENTATION_VERTICAL;
		break;
	case PANEL_APPLET_ORIENT_UP:
	case PANEL_APPLET_ORIENT_DOWN:
	default:
		pager->orientation = GTK_ORIENTATION_HORIZONTAL;
		break;
	}

	pager->screen = wncklet_get_screen (pager->applet);

	/* because the pager doesn't respond to signals at the moment */
	wnck_screen_force_update (pager->screen);

	pager->pager = wnck_pager_new (pager->screen);
	wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), GTK_SHADOW_IN);

	g_signal_connect (G_OBJECT (pager->pager), "destroy",
			  G_CALLBACK (destroy_pager),
			  pager);

	pager_update (pager);
	
	gtk_container_add (GTK_CONTAINER (pager->applet), pager->pager);
	gtk_widget_show (pager->pager);

	gtk_widget_show (pager->applet);

	g_signal_connect (G_OBJECT (pager->applet),
			  "realize",
			  G_CALLBACK (applet_realized),
			  pager);
	g_signal_connect (G_OBJECT (pager->applet),
			  "change_orient",
			  G_CALLBACK (applet_change_orient),
			  pager);
	g_signal_connect (G_OBJECT (pager->applet),
			  "scroll-event",
			  G_CALLBACK (applet_scroll),
			  pager);
	g_signal_connect (G_OBJECT (pager->applet),
			  "change_background",
			  G_CALLBACK (applet_change_background),
			  pager);

	panel_applet_set_background_widget (PANEL_APPLET (pager->applet),
					    GTK_WIDGET (pager->applet));
	
	panel_applet_setup_menu_from_file (PANEL_APPLET (pager->applet),
					   NULL,
					   "GNOME_WorkspaceSwitcherApplet.xml",
					   NULL,
					   pager_menu_verbs,
					   pager);

	if (panel_applet_get_locked_down (PANEL_APPLET (pager->applet))) {
		BonoboUIComponent *popup_component;

		popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet));

		bonobo_ui_component_set_prop (popup_component,
					      "/commands/PagerPreferences",
					      "hidden", "1",
					      NULL);
	}

        popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet));

        launchpad_integration_add_bonobo_ui(popup_component, "/popups/button3/LaunchpadItems");        


	return TRUE;
}
Exemple #16
0
int main (int argc, char *argv[])
{
  GtkWidget *button = NULL;
  GtkWidget *win = NULL;
  GtkWidget *hbox = NULL;
  GtkWidget * Image;

  /* Initialize GTK+ */
  g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, (GLogFunc) gtk_false, NULL);
  gtk_init (&argc, &argv);
  g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, g_log_default_handler, NULL);

    /* Create the main window */
    win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width (GTK_CONTAINER (win), 0);
    gtk_window_set_title (GTK_WINDOW (win), "FakeMaximus");
    gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER);
    gtk_widget_set_size_request(win, 1024, 32);
    gtk_window_set_resizable (GTK_WINDOW(win), FALSE);
    gtk_widget_realize (win);
    g_signal_connect (win, "destroy", gtk_main_quit, NULL);

    /* Create a horizontal box  */
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_container_add (GTK_CONTAINER (win), hbox);


    Maximus.hvbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (hbox), Maximus.hvbox, TRUE, TRUE, 0);

    /* Widget for windows icom list */
    Maximus.IconList = NULL;
    Maximus.hIconBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_widget_show (Maximus.hIconBox);
    gtk_box_pack_start (GTK_BOX (Maximus.hvbox), Maximus.hIconBox, FALSE, FALSE, 0);

    /* 2- Widget window title bar */
    Maximus.WinTitle = gtk_label_new ("Maximus");
    gtk_widget_show (Maximus.WinTitle);
    gtk_box_pack_start (GTK_BOX (Maximus.hvbox), Maximus.WinTitle, FALSE, FALSE, 0);

    Maximus.CloseEvtBox = gtk_event_box_new ();
    gtk_box_pack_end(GTK_BOX (Maximus.hvbox), Maximus.CloseEvtBox, FALSE, FALSE, 0);
    Image = gtk_image_new_from_stock( GTK_STOCK_CLOSE, GTK_ICON_SIZE_SMALL_TOOLBAR );
    //gtk_container_add(GTK_CONTAINER (maximus->hIconBox), pIcon->Image);
    gtk_container_add (GTK_CONTAINER (Maximus.CloseEvtBox), Image);
    gtk_widget_show (Maximus.CloseEvtBox);
    g_signal_connect(G_OBJECT(Maximus.CloseEvtBox), "button_press_event", G_CALLBACK(mxs_OnClickedCloseWindow), (gpointer)&Maximus);

    Maximus.ActiveScreen = wnck_screen_get_default();
    wnck_screen_force_update(Maximus.ActiveScreen);

    button = gtk_button_new_from_stock (GTK_STOCK_NEW);
    g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (SimNewWin), (gpointer)&Maximus);
    gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
{
    extern void on_mxs_window_closed(WnckScreen *screen, WnckWindow *window, MaximusPlugin *maximus);
    /* Want to be notified if window closed */
    g_signal_connect(Maximus.ActiveScreen, "window-closed", G_CALLBACK (on_mxs_window_closed), (gpointer)&Maximus);
}


  /* Enter the main loop */
  gtk_widget_show_all (win);
  gtk_main ();
  return 0;
}
Exemple #17
0
/* Do the actual applet initialization */
static void init_wtapplet (PanelApplet *applet) {
	WTApplet *wtapplet = g_new0 (WTApplet, 1);

	wtapplet->applet = applet;
	wtapplet->prefs = loadPreferences(wtapplet);
	wtapplet->activescreen = wnck_screen_get_default();
	wnck_screen_force_update(wtapplet->activescreen);
	wtapplet->activeworkspace = wnck_screen_get_active_workspace(wtapplet->activescreen);
	wtapplet->activewindow = wnck_screen_get_active_window(wtapplet->activescreen);
	wtapplet->umaxedwindow = getUpperMaximized(wtapplet);
	wtapplet->rootwindow = getRootWindow(wtapplet->activescreen);
	wtapplet->prefbuilder = gtk_builder_new();
	wtapplet->box = GTK_BOX(gtk_hbox_new(FALSE, 0));
	wtapplet->icon = GTK_IMAGE(gtk_image_new());
	wtapplet->title = GTK_LABEL(gtk_label_new(NULL));
	wtapplet->eb_icon = GTK_EVENT_BOX(gtk_event_box_new());
	wtapplet->eb_title = GTK_EVENT_BOX(gtk_event_box_new());
	wtapplet->orient = panel_applet_get_orient(wtapplet->applet);
	wtapplet->size_hints = g_new(gint,2);

	// Widgets to eventboxes, eventboxes to box
	gtk_widget_set_can_focus(GTK_WIDGET(wtapplet->icon), TRUE);
	gtk_widget_set_can_focus(GTK_WIDGET(wtapplet->title), TRUE);
	gtk_container_add (GTK_CONTAINER (wtapplet->eb_icon), GTK_WIDGET(wtapplet->icon));
	gtk_container_add (GTK_CONTAINER (wtapplet->eb_title), GTK_WIDGET(wtapplet->title));
	gtk_event_box_set_visible_window (wtapplet->eb_icon, FALSE);
	gtk_event_box_set_visible_window (wtapplet->eb_title, FALSE);

	// Rotate & place elements
	setAlignment(wtapplet, (gfloat)wtapplet->prefs->alignment);
	placeWidgets(wtapplet);

	// Add box to applet
	gtk_container_add (GTK_CONTAINER(wtapplet->applet), GTK_WIDGET(wtapplet->box));

	// Set event handling (icon & title clicks)
	g_signal_connect(G_OBJECT (wtapplet->eb_icon), "button-press-event", G_CALLBACK (icon_clicked), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->eb_title), "button-press-event", G_CALLBACK (title_clicked), wtapplet);
	
	// Global window tracking
	g_signal_connect(wtapplet->activescreen, "active-window-changed", G_CALLBACK (active_window_changed), wtapplet); // <-- this thing is crashing with compiz !!!
	g_signal_connect(wtapplet->activescreen, "viewports-changed", G_CALLBACK (viewports_changed), wtapplet);
	g_signal_connect(wtapplet->activescreen, "active-workspace-changed", G_CALLBACK (active_workspace_changed), wtapplet);
	g_signal_connect(wtapplet->activescreen, "window-closed", G_CALLBACK (window_closed), wtapplet);
	g_signal_connect(wtapplet->activescreen, "window-opened", G_CALLBACK (window_opened), wtapplet);

	// g_signal_connect(G_OBJECT (wtapplet->title), "size-request", G_CALLBACK (applet_title_size_request), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->applet), "size-allocate", G_CALLBACK (applet_size_allocate), wtapplet);

	g_signal_connect(G_OBJECT (wtapplet->applet), "change-background", G_CALLBACK (applet_change_background), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->applet), "change-orient", G_CALLBACK (applet_change_orient), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->applet), "change-size", G_CALLBACK (applet_change_pixel_size), wtapplet);
	
	// Track active window changes
	wtapplet->active_handler_state = 
		g_signal_connect(G_OBJECT (wtapplet->activewindow), "state-changed", G_CALLBACK (active_window_state_changed), wtapplet);
	wtapplet->active_handler_name = 
		g_signal_connect(G_OBJECT (wtapplet->activewindow), "name-changed", G_CALLBACK (active_window_nameicon_changed), wtapplet);
	wtapplet->active_handler_icon = 
		g_signal_connect(G_OBJECT (wtapplet->activewindow), "icon-changed", G_CALLBACK (active_window_nameicon_changed), wtapplet);

	
	// Setup applet right-click menu
	GtkActionGroup *action_group = gtk_action_group_new ("WindowButtons Applet Actions");
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (action_group, windowtitle_menu_actions, G_N_ELEMENTS (windowtitle_menu_actions), wtapplet);
	panel_applet_setup_menu (applet, windowtitle_menu_items, action_group);
	panel_applet_set_background_widget (wtapplet->applet, GTK_WIDGET (wtapplet->applet)); // Automatic background update
	
	toggleExpand  (wtapplet);
	toggleHidden  (wtapplet);	// Properly hide or show stuff
	updateTitle   (wtapplet);
}