Esempio n. 1
0
/**
 * returns the application name
 */
int c_get_application_name(lua_State *lua)
{
	int top = lua_gettop(lua);

	if (top != 0) {
		luaL_error(lua, "get_application_name: %s", no_indata_expected_error);
		return 0;
	}

	const char *application_name;

	WnckWindow *window = get_current_window();

	if (window) {

		WnckApplication *application=
		    wnck_window_get_application(get_current_window());
		application_name = wnck_application_get_name(application);

	} else {
		application_name = "";
	}

	// one item returned - the application name as a string.
	lua_pushstring(lua, application_name);

	return 1;
}
Esempio n. 2
0
/**
 * wnck_set_default_mini_icon_size:
 * @size: the default size for windows and application mini icons.
 *
 * The default main icon size is %WNCK_DEFAULT_MINI_ICON_SIZE. This function
 * allows to change this value.
 *
 * Since: 2.4.6
 */
void
wnck_set_default_mini_icon_size (gsize size)
{
  int default_screen;
  WnckScreen *screen;
  GList *l;

  default_mini_icon_size = size;

  default_screen = DefaultScreen (_wnck_get_default_display ());
  screen = _wnck_screen_get_existing (default_screen);

  if (WNCK_IS_SCREEN (screen))
    {
      /* Make applications and icons to reload their icons */
      for (l = wnck_screen_get_windows (screen); l; l = l->next)
        {
          WnckWindow *window = WNCK_WINDOW (l->data);
          WnckApplication *application = wnck_window_get_application (window);

          _wnck_window_load_icons (window);

          if (WNCK_IS_APPLICATION (application))
            _wnck_application_load_icons (application);
        }
    }
}
Esempio n. 3
0
static void
kill_window (WnckWindow *win)
{
    WnckApplication *app;

    app = wnck_window_get_application (win);
    if (app)
    {
	gchar buf[257], *client_machine;
	int   pid;

	pid = wnck_application_get_pid (app);
	client_machine = get_client_machine (wnck_application_get_xid (app));

	if (client_machine && pid > 0)
	{
	    if (gethostname (buf, sizeof (buf) - 1) == 0)
	    {
		if (strcmp (buf, client_machine) == 0)
		    kill (pid, 9);
	    }
	}

	if (client_machine)
	    g_free (client_machine);
    }

    gdk_error_trap_push ();
    XKillClient (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wnck_window_get_xid (win));
    gdk_display_sync (gdk_display_get_default ());
    gdk_error_trap_pop_ignored ();
}
Esempio n. 4
0
GtkWidget*
window_menu_item_new (WnckWindow* window)
{
  WnckApplication* application;
  GdkPixbuf* pixbuf;
  GtkWidget* item;
  GtkWidget* label;
  gchar    * markup;

  g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);

  item = gtk_image_menu_item_new ();

  application = wnck_window_get_application (window);

  /* FIXME: track icon changes */
  pixbuf = wnck_application_get_icon (application);
  if (pixbuf)
    {
      GtkWidget* image = gtk_image_new_from_pixbuf (pixbuf);
      gtk_widget_show (image);
      gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
    }

  g_signal_connect (item, "activate",
                    G_CALLBACK (window_item_activated), window);

  /* FIXME: track name changes */
  label = gtk_label_new (NULL);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  markup = g_strdup_printf ("<b>%s</b>\n<small>%s</small>",
                            wnck_application_get_name (application),
                            wnck_window_get_name (window));
  gtk_label_set_markup (GTK_LABEL (label), markup);
  g_free (markup);

  gtk_widget_show (label);
  gtk_container_add (GTK_CONTAINER (item), label);

  return item;
}
Esempio n. 5
0
File: gedit.c Progetto: TCC-FEI/VC
guint32 raise_window(gpointer data) {
    guint32 status;

    GList* list;
    WnckWindow* window;
    WnckApplication* app;

    control_plugin_t* self = (control_plugin_t*) data;

    if (!self)
        return CTRL_INVALID_SELF;

    if (!self->vcwm.screen)
        return CTRL_INVALID_SCREEN;

    status = CTRL_WINDOW_NOT_FOUND;
    list = wnck_screen_get_windows(self->vcwm.screen);

    for (list; list != NULL; list = list->next) {
        window = WNCK_WINDOW(list->data);

        if (!window)
            continue;

        app = wnck_window_get_application(window);

        if (!app)
            continue;

        if (strcmp(wnck_application_get_name(app), "gedit") == 0) {
            wnck_window_activate(window, (guint32) time(NULL));
            status = CTRL_SUCCESS;
            break;
        }
    }

    return status;
}
Esempio n. 6
0
void
_wnck_application_remove_window (WnckApplication *app,
                                 WnckWindow      *window)
{
  g_return_if_fail (WNCK_IS_APPLICATION (app));
  g_return_if_fail (WNCK_IS_WINDOW (window));
  g_return_if_fail (wnck_window_get_application (window) == app);
  
  app->priv->windows = g_list_remove (app->priv->windows, window);
  _wnck_window_set_application (window, NULL);

  g_signal_handlers_disconnect_by_func (G_OBJECT (window),
                                        window_name_changed, app);
  
  /* emits signals, so do it last */
  reset_name (app);
  update_name (app);

  /* see if we're using icon from a window */
  if (app->priv->icon == NULL ||
      app->priv->mini_icon == NULL)
    emit_icon_changed (app);
}
Esempio n. 7
0
void
_wnck_application_add_window (WnckApplication *app,
                              WnckWindow      *window)
{
  g_return_if_fail (WNCK_IS_APPLICATION (app));
  g_return_if_fail (WNCK_IS_WINDOW (window));
  g_return_if_fail (wnck_window_get_application (window) == NULL);
  
  app->priv->windows = g_list_prepend (app->priv->windows, window);  
  _wnck_window_set_application (window, app);

  g_signal_connect (G_OBJECT (window), "name_changed",
                    G_CALLBACK (window_name_changed), app);
  
  /* emits signals, so do it last */
  reset_name (app);
  update_name (app);

  /* see if we're using icon from a window */
  if (app->priv->icon == NULL ||
      app->priv->mini_icon == NULL)
    emit_icon_changed (app);
}
Esempio n. 8
0
static const char* get_application_name(WnckWindow* window, MacMenu* mmb)
{
  update_title_substitute_table(mmb);
  const gchar* orig_name = wnck_application_get_name(
    wnck_window_get_application(window));
  const gchar* new_name = g_hash_table_lookup(
    mmb->title_subs, (gpointer) orig_name);
  return (new_name ? new_name: orig_name);



  //printf("[%s]\n", orig_name);
  char* aname = NULL;
  // check vmware
  if (! strcmp(orig_name, "vmware"))
    return g_strdup("VMware");
  // check epiphany
  else if (! strcmp(orig_name, "Web Browser"))
    return g_strdup("Epiphany");
  // check evince
  else if (! strcmp(orig_name, "Evince Document Viewer"))
    return g_strdup("Evince");
  // suse's control center?
  else if (! strcmp(orig_name, "Gnome Control Center"))
    return g_strdup("Control Center");
  // gnome control center
  else if (! strcmp(orig_name, "control-center"))
    return g_strdup("Control Center");
  else if (! strcmp(orig_name, "file-managment-properties"))
    return g_strdup("File Management");
  else if (! strcmp(orig_name, "gcin-setup"))
    return g_strdup("Gcin Setup");
  // other control center parts
  else if (! strncmp(orig_name, "gnome-", 6))
  {
    aname = g_strdup(orig_name+6);
    for (int i=0; i<strlen(aname); i++)
    {
      if (aname[i] == '-') aname[i] = ' ';
    }
  }
  // mono apps
  else if (! strncmp(orig_name, "/opt/", 5)
           || ! strncmp(orig_name, "/usr/", 5))
  {
    aname = g_strdup(rindex(orig_name, '/')+1);
    if (strlen(aname) > 0)
    {
      char* dot = strstr(aname, ".exe");
      if (dot) *dot = 0;
    }
    else
    {
      g_free(aname);
      aname = g_strdup("Mono");
    }
  }
  else
    aname = g_strdup(orig_name);

  gboolean has_upper = FALSE;
  for (int i=0; i<strlen(aname); i++)
  {
    if (aname[i] >= 'A' && aname[i] <= 'Z')
    {
      has_upper = TRUE;
      break;
    }
  }
  if (!has_upper)
  {
    for (int i=0; i<strlen(aname); i++)
    {
      if ((aname[i] >= 'a' && aname[i] <= 'z')
          && (i == 0 || aname[i-1] == ' '))
        aname[i] -= 32;
    }
    char* ui = strstr(aname, "Ui");
    if (ui && (ui[2] == 0 || ui[2] == ' '))
      ui[1] = 'I';
    char* io = strstr(aname, "Io");
    if (io && (io[2] == 0 || io[2] == ' '))
      io[1] = 'O';
    char* at = strstr(aname, "At");
    if (at && (at[2] == 0 || at[2] == ' '))
      at[1] = 'T';
  }
  return aname;
}