コード例 #1
0
ファイル: launcher.c プロジェクト: Dok-Sergey/tint2
void init_launcher()
{
	if (launcher_enabled) {
		// if XSETTINGS manager running, tint2 read the icon_theme_name.
		xsettings_client = xsettings_client_new(server.dsp, server.screen, xsettings_notify_cb, NULL, NULL);
	}
}
コード例 #2
0
int 
main (int argc, char **argv)
{
  gtk_init (&argc, &argv);

  create_gui ();

  client = xsettings_client_new (gdk_display, DefaultScreen (gdk_display),
				 notify_cb, watch_cb, NULL);
  if (!client)
    {
      fprintf (stderr, "Could not create client!");
      exit (1);
    }

  gtk_main ();

  xsettings_client_destroy (client);

  return 0;
}
コード例 #3
0
MBDesktop *
mbdesktop_init(int argc, char **argv)
{
  MBDesktop *mb;
  XGCValues gv;

  struct sigaction act;

  char *font_def       = FONT_DESC;
  char *font_title_def = FONT_TITLE_DESC;
  char *font_col_def   = FONT_COL;

  int i;
  char *display_name = (char *)getenv("DISPLAY");  

  Bool font_user_set = False;

  /* Non-portable ? will work ok on BSD's ? */
  signal( SIGCHLD, SIG_IGN );

  mb = malloc(sizeof(MBDesktop));
  memset(mb, 0, sizeof(MBDesktop));

  mb->dd_dir          = DD_DIR;
  mb->icon_size       = 0;
  mb->dd_dir_mtime    = 0;

  mb->top_level_name   = strdup("Home");
  mb->bg_def           = NULL;
  mb->view_type        = VIEW_ICONS; 
  mb->use_text_outline = True;
  mb->icon_padding     = 0;

  mb->user_overide_font_col     = False;
  mb->user_overide_font_outline = False;
  mb->use_title_header          = True;

  for (i = 1; i < argc; i++) {
    if (!strcmp ("-display", argv[i]) || !strcmp ("-d", argv[i])) {
      if (++i>=argc) usage (argv[0]);
      display_name = argv[i];
      setenv ("DISPLAY", display_name, 1);
      continue;
    }
    if (!strcmp ("--bg", argv[i])) {
      if (++i>=argc) usage (argv[0]);
      mb->bg_def = strdup(argv[i]);
      continue;
    }
    if (!strcmp("--help", argv[i]) || !strcmp("-h", argv[i])) {
      usage(argv[0]);
    }
    /* XXX --default-view list|icons|icons-only|text-only?
    if (!strcmp ("--listview", argv[i])) {
      mb->view_type = VIEW_LIST;
      continue;
    }
    */
    if (!strcmp ("--no-title", argv[i])) {
      mb->use_title_header = False;
      continue;
    }

    if (!strcmp ("--icon-size", argv[i])) {
      if (++i>=argc) usage (argv[0]);
      mb->icon_size = atoi(argv[i]);
      if (!mb->icon_size) usage(argv[0]);
      continue;
    }
    if (!strcmp ("--icon-padding", argv[i])) {
      if (++i>=argc) usage (argv[0]);
      mb->icon_padding = atoi(argv[i]);
      if (!mb->icon_padding) usage(argv[0]);
      continue;
    }
    if (!strcmp ("--font", argv[i])) {
      if (++i>=argc) usage (argv[0]);
      font_def = argv[i];
      font_user_set = True;
      continue;
    }
    if (!strcmp ("--titlefont", argv[i])) {
      if (++i>=argc) usage (argv[0]);
      font_title_def = argv[i];
      continue;
    }
    if (!strcmp ("--fontcol", argv[i])) {
      if (++i>=argc) usage (argv[0]);
      mb->user_overide_font_col = True;
      font_col_def = argv[i];
      continue;
    }
    if (!strcmp ("--no-outline", argv[i])) {
      mb->user_overide_font_outline = True;
      mb->use_text_outline          = False;
      continue;
    }

    usage(argv[0]);
  }

  if ((mb->dpy = XOpenDisplay(display_name)) == NULL)
    {
      fprintf(stderr, "matchbox-desktop: unable to open display !\n");
      exit(1);
    }


  mb->scr = DefaultScreen(mb->dpy);
  mb->root = RootWindow(mb->dpy, mb->scr); 
  mb->pixbuf = mb_pixbuf_new(mb->dpy, mb->scr);
  mb->root_pxm = None;

  mb->ddfolders = NULL;

  mb->had_kbd_input = False;
  mb->theme_name    = NULL;
  mb->bg_img        = NULL;
  mb->bg = NULL;

  mb->top_head_item = NULL;

  /* Dimentions */
  mb->desktop_width  = DisplayWidth(mb->dpy, mb->scr);
  mb->desktop_height = DisplayHeight(mb->dpy, mb->scr);

  mb->hl_col = mb_col_new_from_spec(mb->pixbuf, NULL);
  mb->fgcol = mb_col_new_from_spec(mb->pixbuf, NULL);
  mb->bgcol = mb_col_new_from_spec(mb->pixbuf, NULL);

  /* Figure out defualts */
  if (mb->icon_size == 0)
    {
      if (mb->desktop_width > 320)
	{
	  mb->icon_size = 48;
	  if (!mb->icon_padding) mb->icon_padding = 32; 
	  if (!font_user_set) font_def = FONT_DESC;
	}
      else
	{
	  mb->icon_size = 32;
	  if (!mb->icon_padding) mb->icon_padding = 28;
	}
    }
  else if (!mb->icon_padding) 
    mb->icon_padding = mb->icon_size / 2; 
    

  if (mbdesktop_get_workarea(mb, &mb->workarea_x, &mb->workarea_y, 
			     &mb->workarea_width, 
			     &mb->workarea_height ) == False )
    {
      mb->workarea_x = 0;
      mb->workarea_y = 0;
      mb->workarea_width = DisplayWidth(mb->dpy, mb->scr);
      mb->workarea_height = DisplayHeight(mb->dpy, mb->scr);
    }



  mb->atom_mb_theme = XInternAtom(mb->dpy, "_MB_THEME_NAME",False);

  mbdesktop_get_theme_via_root_prop(mb);

  if (mb->bg_def == NULL)
    {
      mbdesktop_bg_parse_spec(mb, NULL);
      mbdesktop_switch_bg_theme(mb);
    }
  else
    mbdesktop_bg_parse_spec(mb, mb->bg_def);

  mbdesktop_set_font_color(mb, font_col_def);

  mb->titlefont = mb_font_new_from_string(mb->dpy, font_title_def);
  mb_font_set_color(mb->titlefont, mb->fgcol);

  mb->font      = mb_font_new_from_string(mb->dpy, font_def);
  mb_font_set_color(mb->font, mb->fgcol);


#ifdef USE_XSETTINGS
  mb->xsettings_have_bg      = False; 
  mb->xsettings_have_manager = False;

  /* This will trigger callbacks instantly */

  mb->xsettings_client = xsettings_client_new(mb->dpy, mb->scr,
					      mbdesktop_xsettings_notify_cb,
					      mbdesktop_xsettings_watch_cb, 
					      (void *)mb );
#endif

  DBG("%s() finished creating xsettings client \n", __func__);

  mb->folder_img_path = NULL;

   /* GC's */
  gv.function = GXcopy;
  gv.graphics_exposures = 0;
  
  mb->gc = XCreateGC(mb->dpy, mb->root,
		     GCFunction|GCGraphicsExposures, 
		     &gv);

  gv.function = GXinvert;
  gv.subwindow_mode = IncludeInferiors;

  mb->invert_gc = XCreateGC(mb->dpy, mb->root,
			    GCFunction|GCSubwindowMode|GCGraphicsExposures
			    , &gv);


  //  mbdesktop_calculate_item_dimentions(mb);

  mbdesktop_set_scroll_buttons(mb);

  /* ewmh hints */
  mb->window_type_atom =
    XInternAtom(mb->dpy, "_NET_WM_WINDOW_TYPE" , False);
  mb->window_type_desktop_atom =
    XInternAtom(mb->dpy, "_NET_WM_WINDOW_TYPE_DESKTOP",False);
  mb->desktop_manager_atom =
    XInternAtom(mb->dpy, "_NET_DESKTOP_MANGER",False);

  mb->window_type_dialog_atom =
    XInternAtom(mb->dpy, "_NET_WM_WINDOW_TYPE_DIALOG",False);
  mb->window_state_atom =
    XInternAtom(mb->dpy, "_NET_WM_STATE",False);
  mb->window_state_modal_atom =
    XInternAtom(mb->dpy, "_NET_WM_STATE_MODAL",False);
  mb->window_utf8_name_atom =
    XInternAtom(mb->dpy, "_NET_WM_NAME",False);
  mb->utf8_atom =
    XInternAtom(mb->dpy, "UTF8_STRING",False);
  
  mb->win_top_level = XCreateWindow(mb->dpy, mb->root, 
		                    0, 0,  
				    mb->desktop_width, 
				    mb->desktop_height, 0, 
				    CopyFromParent,  
				    CopyFromParent, 
				    mb->pixbuf->vis,
				    0, NULL);

  /* Make sure with mess with no other already running desktops */
  if (XGetSelectionOwner(mb->dpy, mb->desktop_manager_atom))
    {
      fprintf(stderr, "matchbox-desktop: Desktop Already running on this display.\n");
      exit(1);
    }

  /* ...And they hopefully dont mess with us.... */
  XSetSelectionOwner(mb->dpy, mb->desktop_manager_atom, 
		     mb->win_top_level, CurrentTime);

  XStoreName(mb->dpy, mb->win_top_level, "Desktop" );

  XChangeProperty(mb->dpy, mb->win_top_level, mb->window_type_atom, XA_ATOM, 32, 
		  PropModeReplace, 
		  (unsigned char *) &mb->window_type_desktop_atom, 1);

  mbdesktop_set_icon(mb);

  mbdesktop_progress_dialog_init(mb);

#ifdef USE_DNOTIFY
  _Gmb = mb; 			/* arg, global mb for sig callback */

  act.sa_sigaction = sig_reload_handler;
  sigemptyset(&act.sa_mask);
  act.sa_flags = SA_SIGINFO;
  sigaction(SIGRTMIN, &act, NULL);
#endif 

  act.sa_sigaction = sig_hup_reload_handler;
  sigemptyset(&act.sa_mask);
  act.sa_flags = SA_SIGINFO;
  sigaction(SIGHUP, &act, NULL);

  mb->type_register_cnt = ITEM_TYPE_CNT;

  /* get the window ready */
  XSelectInput(mb->dpy, mb->win_top_level, 
	       ExposureMask | ButtonPressMask | ButtonReleaseMask |
	       KeyPress | KeyRelease | StructureNotifyMask |
	       /* Below for reparented module plugin */
	       SubstructureRedirectMask | SubstructureNotifyMask |
	       FocusChangeMask );

  XSelectInput(mb->dpy, mb->root, PropertyChangeMask );

  XMapWindow(mb->dpy, mb->win_top_level);

  return mb;
}