Example #1
0
WAttText::WAttText(void* wa_parent_ctx, ldh_tSesContext wa_ldhses,
    pwr_sAttrRef wa_aref, int wa_editmode, pwr_tStatus* status)
    : parent_ctx(wa_parent_ctx), ldhses(wa_ldhses), aref(wa_aref),
      editmode(wa_editmode), modified(0), close_cb(0), wow(0)
{
  pwr_tStatus sts;

  *status = WATT__SUCCESS;

  ldh_sAttrRefInfo ainfo;

  sts = ldh_GetAttrRefInfo(ldhses, &aref, &ainfo);
  if (EVEN(sts)) {
    *status = sts;
    return;
  }

  switch (ainfo.type) {
  case pwr_eType_Text:
    break;
  default:
    *status = WATT__NOTEXT;
    return;
  }
}
Example #2
0
static pwr_tStatus DisableFilter( ldh_sMenuCall *ip) 
{
  pwr_tStatus sts;
  ldh_sAttrRefInfo info;
  
  sts = ldh_GetAttrRefInfo( ip->PointedSession, &ip->Pointed, &info);
  if ( EVEN(sts)) return sts;

  if ( info.flags & PWR_MASK_DISABLEATTR)
    return 1;
  return 0;
}
Example #3
0
static pwr_tStatus trace_get_attr_m5( 	WGre		*gre, 
					vldh_t_node	node, 
					char		*debug_par,
					char		*object_str, 
					char		*attr_str,
					flow_eTraceType	*trace_type,
					int		*inverted)
{
  pwr_tAName	       	aname;
  pwr_tStatus		sts;
  int			size;
  pwr_sAttrRef		*objarp;
  pwr_sAttrRef		objar, disar;
  char			*np, *s;
  ldh_sAttrRefInfo	info;

  *inverted = 0;

  /* Get the attrref stored in the attribute Object */
  sts = ldh_GetObjectPar( node->hn.wind->hw.ldhses,  
		node->ln.oid, "DevBody", "Object",
		(char **)&objarp, &size); 
  if ( EVEN(sts)) return sts;

  objar = *objarp;
  free((char *) objarp);

  sts = ldh_GetAttrRefInfo( node->hn.wind->hw.ldhses,
	&objar, &info);
  if( EVEN(sts)) return sts;

  if ( !info.flags & PWR_MASK_DISABLEATTR)
    return TRA__NOPAR;

  disar = cdh_ArefToDisableAref( &objar);

  /* Get the name of the node */
  sts = ldh_AttrRefToName( node->hn.wind->hw.ldhses,  
			   &disar, cdh_mNName, &np,
			   &size);
  if( EVEN(sts)) return sts;
  strcpy( aname, np);

  s = strrchr( aname, '.');
  if ( !s) return TRA__NOPAR;

  strcpy( attr_str, s + 1);
  *s = 0;
  strcpy( object_str, aname);

  *trace_type = flow_eTraceType_Boolean;
  return TRA__SUCCESS;
}
Example #4
0
static pwr_tStatus Cast( ldh_sMenuCall *ip) 
{
  pwr_tStatus sts;
  pwr_tCid cid;
  ldh_sAttrRefInfo info;
  
  sts = ldh_GetAttrRefTid( ip->PointedSession, &ip->Pointed, &cid);
  if ( EVEN(sts)) return sts;

  sts = ldh_GetAttrRefInfo( ip->PointedSession, &ip->Pointed, &info);
  if ( EVEN(sts)) return sts;

  if ( info.flags & PWR_MASK_CASTATTR) {
    ip->wtt->wcast_new( ip->Pointed, &sts);
  }
  return 1;
}
Example #5
0
WAttTextGtk::WAttTextGtk(GtkWidget* wa_parent_wid, void* wa_parent_ctx,
    ldh_tSesContext wa_ldhses, pwr_sAttrRef wa_aref, int wa_editmode,
    pwr_tStatus* status)
    : WAttText(wa_parent_ctx, wa_ldhses, wa_aref, wa_editmode, status),
      parent_wid(wa_parent_wid), toplevel(0), init(1)
{
  int sts;
  int size;
  char* namep;

  if (EVEN(*status))
    return;

  sts = ldh_AttrRefToName(ldhses, &aref, ldh_eName_Hierarchy, &namep, &size);
  if (EVEN(sts)) {
    *status = sts;
    return;
  }

  toplevel = (GtkWidget*)g_object_new(GTK_TYPE_WINDOW, "default-height", 700,
      "default-width", 800, "title", CoWowGtk::convert_utf8(namep), NULL);

  g_signal_connect(toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect(toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect(
      toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);

  CoWowGtk::SetWindowIcon(toplevel);

  // Menu
  // Accelerators
  GtkAccelGroup* accel_g
      = (GtkAccelGroup*)g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar* menu_bar = (GtkMenuBar*)g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget* file_close
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);

  GtkWidget* file_save
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE, accel_g);
  g_signal_connect(file_save, "activate", G_CALLBACK(activate_save), this);

  GtkWidget* file_saveandclose
      = gtk_menu_item_new_with_mnemonic("S_ave and close");
  g_signal_connect(
      file_saveandclose, "activate", G_CALLBACK(activate_saveandclose), this);
  gtk_widget_add_accelerator(file_saveandclose, "activate", accel_g, 't',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkMenu* file_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_save);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_saveandclose);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget* file = gtk_menu_item_new_with_mnemonic("_File");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Edit entry
  GtkWidget* edit_copy
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY, accel_g);
  g_signal_connect(edit_copy, "activate", G_CALLBACK(activate_copy), this);

  GtkWidget* edit_cut
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_CUT, accel_g);
  g_signal_connect(edit_cut, "activate", G_CALLBACK(activate_cut), this);

  GtkWidget* edit_paste
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, accel_g);
  g_signal_connect(edit_paste, "activate", G_CALLBACK(activate_paste), this);

  GtkMenu* edit_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_copy);
  gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_cut);
  gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_paste);

  GtkWidget* edit = gtk_menu_item_new_with_mnemonic("_Edit");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), edit);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(edit), GTK_WIDGET(edit_menu));

  // Help entry
  GtkWidget* help_help
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
  g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);

  GtkMenu* help_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

  GtkWidget* help = gtk_menu_item_new_with_mnemonic("_Help");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  if (((WUtility*)parent_ctx)->utype == wb_eUtility_WNav)
    parent_ctx = ((WNav*)parent_ctx)->parent_ctx;
  utility = ((WUtility*)parent_ctx)->utype;

  textbuffer = gtk_text_buffer_new(NULL);
  g_signal_connect_after(
      textbuffer, "insert-text", G_CALLBACK(action_text_inserted), this);
  g_signal_connect_after(
      textbuffer, "changed", G_CALLBACK(action_text_changed), this);

  textview = gtk_text_view_new_with_buffer(textbuffer);
  GtkWidget* viewport = gtk_viewport_new(NULL, NULL);
  GtkWidget* scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_container_add(GTK_CONTAINER(viewport), textview);
  gtk_container_add(GTK_CONTAINER(scrolledwindow), viewport);

  button_ok = gtk_button_new_with_label("Ok");
  gtk_widget_set_size_request(button_ok, 70, 25);
  g_signal_connect(button_ok, "clicked", G_CALLBACK(activate_ok), this);
  button_apply = gtk_button_new_with_label("Apply");
  gtk_widget_set_size_request(button_apply, 70, 25);
  g_signal_connect(button_apply, "clicked", G_CALLBACK(activate_apply), this);
  button_cancel = gtk_button_new_with_label("Cancel");
  gtk_widget_set_size_request(button_cancel, 70, 25);
  g_signal_connect(button_cancel, "clicked", G_CALLBACK(activate_cancel), this);

  GtkWidget* hboxbuttons = gtk_hbox_new(TRUE, 40);
  gtk_box_pack_start(GTK_BOX(hboxbuttons), button_ok, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(hboxbuttons), button_apply, FALSE, FALSE, 0);
  gtk_box_pack_end(GTK_BOX(hboxbuttons), button_cancel, FALSE, FALSE, 0);

  msg_label = gtk_label_new("");
  gtk_widget_set_size_request(msg_label, -1, 25);

  vbox = gtk_vbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), hboxbuttons, FALSE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(vbox), msg_label, FALSE, FALSE, 5);

  gtk_container_add(GTK_CONTAINER(toplevel), vbox);
  gtk_widget_show_all(toplevel);

  if (utility == wb_eUtility_Wtt) {
    ((Wtt*)parent_ctx)
        ->register_utility((void*)this, wb_eUtility_AttrTextEditor);
  }

  char* value;
  ldh_sAttrRefInfo ainfo;

  sts = ldh_GetAttrRefInfo(ldhses, &aref, &ainfo);
  if (EVEN(sts)) {
    *status = sts;
    return;
  }

  char* s = strchr(namep, '.');
  if (!s)
    return;

  strncpy(aname, s + 1, sizeof(aname));

  sts = ldh_GetObjectPar(
      ldhses, aref.Objid, "DevBody", aname, (char**)&value, &size);
  if (EVEN(sts)) {
    *status = sts;
    return;
  }

  input_max_length = ainfo.size - 1;

  GtkTextIter start_iter, end_iter;
  gtk_text_buffer_get_start_iter(textbuffer, &start_iter);
  gtk_text_buffer_get_end_iter(textbuffer, &end_iter);
  gtk_text_buffer_delete(textbuffer, &start_iter, &end_iter);

  gtk_text_buffer_get_start_iter(textbuffer, &start_iter);

  char* textutf8 = g_convert(value, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);
  gtk_text_buffer_insert(textbuffer, &start_iter, textutf8, -1);
  g_free(textutf8);

  free(value);

  if (!editmode) {
    gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textview), FALSE);
  }

  wow = new CoWowGtk(toplevel);
  init = 0;
}