Back to index

bamf  0.2.120
Classes | Typedefs | Functions | Variables
alt-tabber.c File Reference
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <libbamf/libbamf.h>

Go to the source code of this file.


struct  _Entry


typedef struct _Entry Entry


void on_name_changed (BamfView *bamfview, gchar *old_name, gchar *new_name, Entry *entry)
void populate_tree_store (GtkTreeStore *store)
GtkWidget * make_tree_view ()
static void destroy (GtkWidget *widget, gpointer data)
static void handle_view_opened (BamfMatcher *matcher, BamfView *view, gpointer data)
int main (int argc, char **argv)


GtkWidget * window
GtkWidget * treeView
guint timer

Class Documentation

struct _Entry

Definition at line 30 of file alt-tabber.c.

Class Members
GtkTreeIter child
GtkTreeStore * store

Typedef Documentation

typedef struct _Entry Entry

Function Documentation

static void destroy ( GtkWidget *  widget,
gpointer  data 
) [static]

Definition at line 134 of file alt-tabber.c.

  gtk_main_quit ();

Here is the caller graph for this function:

static void handle_view_opened ( BamfMatcher *  matcher,
BamfView *  view,
gpointer  data 
) [static]

Definition at line 139 of file alt-tabber.c.

  g_print ("VIEW OPENED\n");

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 

Definition at line 149 of file alt-tabber.c.

  BamfMatcher *matcher;
  gtk_init (&argc, &argv);

  matcher = bamf_matcher_get_default ();

  g_signal_connect (G_OBJECT (matcher), "view-opened",
                   (GCallback) handle_view_opened, NULL);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy), NULL);

  treeView = make_tree_view ();
  gtk_container_add (GTK_CONTAINER (window), treeView);
  gchar *favs [] = { "/usr/share/applications/evolution-mail.desktop", NULL };
  bamf_matcher_register_favorites (matcher, (const gchar **) favs);

  gtk_widget_show_all (window);
  gtk_main ();
  return 0;

Here is the call graph for this function:

GtkWidget* make_tree_view ( )

Definition at line 107 of file alt-tabber.c.

  GtkWidget *treeView;
  GtkTreeStore *treeStore;
  GtkTreeViewColumn *column;
  GtkCellRenderer *renderer;

  treeView = gtk_tree_view_new ();
  treeStore = gtk_tree_store_new (1, G_TYPE_STRING);

  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, "windows");
  gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), column);

  renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, renderer, TRUE);
  gtk_tree_view_column_add_attribute(column, renderer, "text", 0);

  gtk_tree_view_set_model (GTK_TREE_VIEW (treeView), GTK_TREE_MODEL (treeStore));

  populate_tree_store (treeStore);
  g_object_unref (treeStore);

  return treeView;

Here is the call graph for this function:

Here is the caller graph for this function:

void on_name_changed ( BamfView *  bamfview,
gchar *  old_name,
gchar *  new_name,
Entry entry 

Definition at line 36 of file alt-tabber.c.

  gtk_tree_store_set (entry->store, &entry->child, 0, new_name, -1);

Here is the caller graph for this function:

void populate_tree_store ( GtkTreeStore *  store)

Definition at line 44 of file alt-tabber.c.

  GtkTreeIter position; 
  GtkTreeIter child;
  GList *children, *c; 
  GList *apps, *l;
  BamfApplication *app;
  BamfWindow *window;
  const char *filename;
  Entry* entry = NULL;

  apps = bamf_matcher_get_applications (bamf_matcher_get_default ());

  for (l = apps; l; l = l->next) 
    app = BAMF_APPLICATION (l->data);
    if (!bamf_view_user_visible (BAMF_VIEW (app)))

    gtk_tree_store_append (store, &position, NULL);
    filename = bamf_view_get_name (BAMF_VIEW (app));
    gtk_tree_store_set (store, &position, 0, filename, -1);

    children = bamf_view_get_children (BAMF_VIEW (app));
    g_print("%i    %s\n", g_list_length (children), filename);

    for (c = children; c; c = c->next) 
      if (BAMF_IS_WINDOW (c->data))
          window = BAMF_WINDOW (c->data);

          if (!bamf_view_user_visible (BAMF_VIEW (window)))

          const gchar *name = bamf_view_get_name (BAMF_VIEW (window));
          gtk_tree_store_append (store, &child, &position);
          gtk_tree_store_set (store, &child, 0, name, -1);

          // the following is just to make the tree-store correctly update with
         // any changes happening to titles during tab-changes, the g_new0()
         // has no corresponding g_free() thus is leaking memory, don't do that
         // in production-level code, this is just a small test
         entry = g_new0 (Entry, 1); // this is leaking memory
          entry->store = store;
         entry->child = child;
          g_signal_connect (G_OBJECT (window),
                            (GCallback) on_name_changed,
      else if (BAMF_IS_INDICATOR (c->data))
          const gchar *path = bamf_indicator_get_dbus_menu_path (BAMF_INDICATOR (c->data));
          gtk_tree_store_append (store, &child, &position);
          gtk_tree_store_set (store, &child, 0, path, -1);

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

guint timer

Definition at line 28 of file alt-tabber.c.

GtkWidget* treeView

Definition at line 27 of file alt-tabber.c.

GtkWidget* window

Definition at line 26 of file alt-tabber.c.