예제 #1
0
gint
main (gint argc, gchar *argv[])
{
  GtkWidget *window, *grid;

  gtk_init ();

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  grid = gtk_grid_new ();

  gtk_grid_attach (GTK_GRID (grid),
                   create_notebook_non_dragable_content (tabs1, GROUP_A, GTK_POS_TOP),
                   0, 0, 1, 1);

  gtk_grid_attach (GTK_GRID (grid),
                   create_notebook (tabs2, GROUP_B, GTK_POS_BOTTOM),
                   0, 1, 1, 1);

  gtk_grid_attach (GTK_GRID (grid),
                   create_notebook (tabs3, GROUP_B, GTK_POS_LEFT),
                   1, 0, 1, 1);

  gtk_grid_attach (GTK_GRID (grid),
                   create_notebook_with_notebooks (tabs4, GROUP_A, GTK_POS_RIGHT),
                   1, 1, 1, 1);

  gtk_grid_attach (GTK_GRID (grid),
                   create_trash_button (),
                   1, 2, 1, 1);

  gtk_container_add (GTK_CONTAINER (window), grid);
  gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);

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

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}
예제 #2
0
파일: callbacks.c 프로젝트: jimiszm/peos
void
on_ok_delete_clicked(void)
{
  runPeos(del_cmd);

  /* I changed this: it was before parse in the function */
  gtk_widget_destroy (notebook);
  freeAll_extra();

  notebook = create_notebook();
  gtk_widget_set_name (notebook, "notebook");
  gtk_widget_ref (notebook);
  gtk_object_set_data_full (GTK_OBJECT (Peos), "notebook", notebook,
                            (GtkDestroyNotify) gtk_widget_unref);
  set_selection(1);	/* with current action selected */
  gtk_container_add (GTK_CONTAINER (vbox), notebook);

  redisplay_menu();
}
예제 #3
0
파일: testnotebookdnd.c 프로젝트: GYGit/gtk
static GtkWidget*
create_notebook_with_notebooks (gchar           **labels,
                                const gchar      *group,
                                GtkPositionType   pos)
{
  GtkWidget *notebook, *title, *page;
  gint count = 0;

  notebook = gtk_notebook_new ();
  g_signal_connect (notebook, "create-window",
                    G_CALLBACK (window_creation_function), NULL);

  gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), pos);
  gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
  gtk_container_set_border_width (GTK_CONTAINER (notebook), 6);
  gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook), group);

  while (*labels)
    {
      page = create_notebook (labels, group, pos);
      gtk_notebook_popup_enable (GTK_NOTEBOOK (page));

      title = gtk_label_new (*labels);

      gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, title);
      gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), page, TRUE);
      gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (notebook), page, TRUE);

      count++;
      labels++;
    }

  g_signal_connect (GTK_NOTEBOOK (notebook), "page-reordered",
                    G_CALLBACK (on_page_reordered), NULL);
  g_signal_connect_after (G_OBJECT (notebook), "drag-begin",
                          G_CALLBACK (on_notebook_drag_begin), NULL);
  return notebook;
}
예제 #4
0
파일: callbacks.c 프로젝트: jimiszm/peos
void
on_ok_fileselection_clicked(GtkWidget *file, GtkFileSelection *fs)
{
  int fd, i, size;
  char *cmd, buf[MAX_BUF];
#ifdef DEBUG  
  GtkWidget *error_dialog = NULL;
#endif

  size = strlen(exec_path) + strlen(" -c ") + strlen(gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs))) + 1;
  cmd = (char *) malloc (size*sizeof(char));
  strcpy (cmd, exec_path);
  strcat (cmd, " -c ");
  strcat (cmd, gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)));

  for(i = 0; i < MAX_PID; i++) {   
  	if(table[i].process == NULL) {
		cur_pid = i;
		break;
	}
  }	

  runPeos(cmd);
  free(cmd);
  cmd = NULL;

  fd = open ("message", O_RDONLY);
  if(fd < 0) {
  	perror("An error has occurred when attempting to open 'message' \n");
	exit(1);
  }
  read (fd, buf, MAX_BUF);
  close (fd);

#ifdef DEBUG
  if (strncmp ("Executing", buf, 9) != 0) {
	error_dialog = create_errordialog();
  	gtk_widget_show (error_dialog);
  } else {
#endif

  gtk_widget_destroy (notebook);
  freeAll_extra();

  notebook = create_notebook();
  gtk_widget_set_name (notebook, "notebook");
  gtk_widget_ref (notebook);
  gtk_object_set_data_full (GTK_OBJECT (Peos), "notebook", notebook,
                            (GtkDestroyNotify) gtk_widget_unref);
  set_selection(1);	/* with current action selected */
  gtk_widget_show (notebook);
  gtk_container_add (GTK_CONTAINER (vbox), notebook);

  redisplay_menu();
  check_state();
  
}

void check_state(void)
{
  char *state;
  if ( table[cur_pid].page.curr != NULL && strcmp (table[cur_pid].page.curr->name , "action") == 0) {
	state = xmlGetProp(table[cur_pid].page.curr, "state");
	if ( strcmp(state, "NONE") == 0) {
		set_sensitive_dep(TRUE, TRUE, FALSE, FALSE, NULL);

	} else if ( strcmp(state, "BLOCKED") == 0) {
		set_sensitive_dep(TRUE, TRUE, FALSE, FALSE, NULL);

	} else if ( strcmp(state, "RUN") == 0) {
		set_sensitive_dep(FALSE, TRUE, TRUE, TRUE, NULL);

	} else if ( strcmp(state, "SUSPEND") == 0) {
		set_sensitive_dep(TRUE, TRUE, FALSE, TRUE, NULL);

	} else if ( strcmp(state, "DONE") == 0) {
		set_sensitive_dep(TRUE, FALSE, FALSE, FALSE, NULL);

	} else if ( strcmp(state, "READY") == 0) {
		set_sensitive_dep(TRUE, TRUE, FALSE, FALSE, NULL);

	} else if ( strcmp(state, "AVAILABLE") == 0) {
		set_sensitive_dep(TRUE, TRUE, FALSE, FALSE, NULL);

	} else if ( strcmp(state, "PENDING") == 0) {
		set_sensitive_dep(TRUE, TRUE, FALSE, FALSE, NULL);

	} 
  	if (GTK_IS_WIDGET (table[cur_pid].page.Start)) gtk_widget_destroy (table[cur_pid].page.Start);
  	table[cur_pid].page.Start = start_label(state);
  } else {
	set_sensitive_dep(FALSE, FALSE, FALSE, FALSE, FALSE);

  	if (GTK_IS_WIDGET (table[cur_pid].page.Start)) gtk_widget_destroy (table[cur_pid].page.Start);
  	table[cur_pid].page.Start = start_label("Start");
  }
  gtk_widget_ref (table[cur_pid].page.Start);
  gtk_object_set_data_full (GTK_OBJECT (Peos), "Start", table[cur_pid].page.Start,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (table[cur_pid].page.Start);
  gtk_fixed_put (GTK_FIXED (table[cur_pid].page.fixed), table[cur_pid].page.Start, 16, 8);
  gtk_widget_set_uposition (table[cur_pid].page.Start, 16, 8);
  gtk_widget_set_usize (table[cur_pid].page.Start, 55, 22);
  gtk_signal_connect (GTK_OBJECT (table[cur_pid].page.Start), "clicked",
                      GTK_SIGNAL_FUNC (on_Start_clicked),
                      NULL);
  set_sensitive();
}
예제 #5
0
파일: callbacks.c 프로젝트: jimiszm/peos
void
on_Finish_clicked(GtkButton *button, gpointer user_data)
{
  if ( table[cur_pid].page.curr) {

	char *cmd, *name, buf[3];
	int i, size;

	if (table[cur_pid].process != NULL ) {
		sprintf(buf, "%d", cur_pid);	/* Put this up here: fix */
		name =  xmlGetProp(table[cur_pid].page.curr, "name");
		size = strlen(exec_path) + strlen(" -n ") + sizeof(cur_pid)
			+ strlen(buf) + strlen(" ") + strlen(name) + strlen(" finish ") + 1;
		cmd = (char *) malloc (size);

		strcpy (cmd, exec_path);
		strcat (cmd, " -n ");
		strcat (cmd, buf);
		strcat (cmd, " ");
		strcat (cmd, name);
		strcat (cmd, " finish ");
		runPeos(cmd);
		free(cmd);
		cmd = NULL;
	}

	freeAll_extra();

	if (table[cur_pid].process != NULL ) {
  		draw_tree (cur_pid);
		/* search through actions and find the current page */
		for ( i = 0; i < counting_action; i++) {

			if (strcmp (linklist[cur_pid][i].cur->name, "action") == 0) {
				if (strcmp (xmlGetProp (linklist[cur_pid][i].cur, "name"), name) == 0) {
 					table[cur_pid].page.curr = linklist[cur_pid][i].cur;
					break;	
				}
			}
		}
		draw_text(table[cur_pid].page.curr);
  		if((GTK_IS_WIDGET (table[cur_pid].page.tree1) && GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1))))
			gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1),
			linklist[cur_pid][table[cur_pid].page.index].item);
		check_state();
	} else {
  		table[cur_pid].page.index = 0;
		gtk_widget_destroy (notebook);
  		notebook = create_notebook();
  		gtk_widget_set_name (notebook, "notebook");
  		gtk_widget_ref (notebook);
  		gtk_object_set_data_full (GTK_OBJECT (Peos), "notebook", notebook,
                            (GtkDestroyNotify) gtk_widget_unref);
		set_selection(1);	/* with current action selected */
  		gtk_widget_show (notebook);
  
  		gtk_container_add (GTK_CONTAINER (vbox), notebook);
		
		for (i = 0; i < MAX_PID; i++) {
			if (table[i].process != NULL)
				cur_pid = i;
		}
	} 
  redisplay_menu();
  }
}